Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_【TT助手】百度网盘工具箱直链解析——持续更新@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICAgIOOAkFRU5Yqp5omL44CR55m+5bqm572R55uY5bel5YW3566x55u06ZO+6Kej5p6QIOKAlOKAlOaMgee7reabtOaWsAovLyBAbmFtZXNwYWNlICAgICAgaHR0cHM6Ly93d3cudHR0dC5lZQovLyBAZGVzY3JpcHRpb24gICAg566A5Y2V5peg6ZmQ5Yi255qE55m+5bqm572R55uY6Kej5p6Q6ISa5pys77yM5peg6KeG6buR5Y+377yM5YWNU1ZJUO+8jOWFjea1j+iniOWZqOaJqeWxle+8jOaUr+aMgUlETeOAgU5ETeOAgUFyaWHjgIFNb3RyaXjnrYnlpJrnp43lt6XlhbfkuIvovb3jgILlv6vmnaXkvZPpqozlkKfvvIHvvIHvvIHwn5GN8J+RjfCfkY0KLy8gQGxpY2Vuc2UgICAgICAgIE1JVAovLyBAdmVyc2lvbiAgICAgICAgMS4wLjEwCi8vIEBhdXRob3IgICAgICAgICBUVC1kb3duCi8vIEBzb3VyY2UgICAgICAgICBodHRwczovL3d3dy50dHR0LmVlCi8vIEBpbmNsdWRlICAgICAgICAqLy9wYW4uYmFpZHUuY29tL2Rpc2svKgovLyBAcmVxdWlyZSAgICAgICAgaHR0cHM6Ly9saWIuYmFvbWl0dS5jb20vbWR1aS8xLjAuMi9qcy9tZHVpLm1pbi5qcwovLyBAcmVxdWlyZSAgICAgICAgaHR0cHM6Ly9jZG4uYm9vdGNzcy5jb20vanF1ZXJ5LzIuMi40L2pxdWVyeS5taW4uanMKLy8gQHN1cHBvcnRVUkwgICAgIGh0dHBzOi8vd3d3LnR0dHQuZWUKLy8gQGdyYW50ICAgICAgICAgIEdNX3htbGh0dHBSZXF1ZXN0Ci8vIEBncmFudCAgICAgICAgICBHTV9yZWdpc3Rlck1lbnVDb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CAmJiAhd2luZG93LmF0b2IpKSwgCiAgICAgICAgICAgIG1lbW87CiAgICAgICAgfTsKICAgIH0oKSwgZ2V0VGFyZ2V0ID0gZnVuY3Rpb24gZ2V0VGFyZ2V0KCkgewogICAgICAgIHZhciBtZW1vID0ge307CiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIG1lbW9yaXplKHRhcmdldCkgewogICAgICAgICAgICBpZiAodm9pZCAwID09PSBtZW1vW3RhcmdldF0pIHsKICAgICAgICAgICAgICAgIHZhciBzdHlsZVRhcmdldCA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IodGFyZ2V0KTsKICAgICAgICAgICAgICAgIGlmICh3aW5kb3cuSFRNTElGcmFtZUVsZW1lbnQgJiYgc3R5bGVUYXJnZXQgaW5zdGFuY2VvZiB3aW5kb3cuSFRNTElGcmFtZUVsZW1lbnQpIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgc3R5bGVUYXJnZXQgPSBzdHlsZVRhcmdldC5jb250ZW50RG9jdW1lbnQuaGVhZDsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICBzdHlsZVRhcmdldCA9IG51bGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBtZW1vW3RhcmdldF0gPSBzdHlsZVRhcmdldDsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gbWVtb1t0YXJnZXRdOwogICAgICAgIH07CiAgICB9KCksIHN0eWxlc0luRG9tID0gW107CiAgICBmdW5jdGlvbiBnZXRJbmRleEJ5SWRlbnRpZmllcihpZGVudGlmaWVyKSB7CiAgICAgICAgZm9yICh2YXIgcmVzdWx0ID0gLTEsIGkgPSAwOyBpIDwgc3R5bGVzSW5Eb20ubGVuZ3RoOyBpKyspIGlmIChzdHlsZXNJbkRvbVtpXS5pZGVudGlmaWVyID09PSBpZGVudGlmaWVyKSB7CiAgICAgICAgICAgIHJlc3VsdCA9IGk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgfQogICAgZnVuY3Rpb24gbW9kdWxlc1RvRG9tKGxpc3QsIG9wdGlvbnMpIHsKICAgICAgICBmb3IgKHZhciBpZENvdW50TWFwID0ge30sIGlkZW50aWZpZXJzID0gW10sIGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykgewogICAgICAgICAgICB2YXIgaXRlbSA9IGxpc3RbaV0sIGlkID0gb3B0aW9ucy5iYXNlID8gaXRlbVswXSArIG9wdGlvbnMuYmFzZSA6IGl0ZW1bMF0sIGNvdW50ID0gaWRDb3VudE1hcFtpZF0gfHwgMCwgaWRlbnRpZmllciA9ICIiLmNvbmNhdChpZCwgIiAiKS5jb25jYXQoY291bnQpOwogICAgICAgICAgICBpZENvdW50TWFwW2lkXSA9IGNvdW50ICsgMTsKICAgICAgICAgICAgdmFyIGluZGV4ID0gZ2V0SW5kZXhCeUlkZW50aWZpZXIoaWRlbnRpZmllciksIG9iaiA9IHsKICAgICAgICAgICAgICAgIGNzczogaXRlbVsxXSwKICAgICAgICAgICAgICAgIG1lZGlhOiBpdGVtWzJdLAogICAgICAgICAgICAgICAgc291cmNlTWFwOiBpdGVtWzNdCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIC0xICE9PSBpbmRleCA/IChzdHlsZXNJbkRvbVtpbmRleF0ucmVmZXJlbmNlcysrLCBzdHlsZXNJbkRvbVtpbmRleF0udXBkYXRlcihvYmopKSA6IHN0eWxlc0luRG9tLnB1c2goewogICAgICAgICAgICAgICAgaWRlbnRpZmllcjogaWRlbnRpZmllciwKICAgICAgICAgICAgICAgIHVwZGF0ZXI6IGFkZFN0eWxlKG9iaiwgb3B0aW9ucyksCiAgICAgICAgICAgICAgICByZWZlcmVuY2VzOiAxCiAgICAgICAgICAgIH0pLCBpZGVudGlmaWVycy5wdXNoKGlkZW50aWZpZXIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaWRlbn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ZXRvblRhZy5iaW5kKG51bGwsIHN0eWxlLCBzdHlsZUluZGV4LCAhMSksIAogICAgICAgICAgICByZW1vdmUgPSBhcHBseVRvU2luZ2xldG9uVGFnLmJpbmQobnVsbCwgc3R5bGUsIHN0eWxlSW5kZXgsICEwKTsKICAgICAgICB9IGVsc2Ugc3R5bGUgPSBpbnNlcnRTdHlsZUVsZW1lbnQob3B0aW9ucyksIHVwZGF0ZSA9IGFwcGx5VG9UYWcuYmluZChudWxsLCBzdHlsZSwgb3B0aW9ucyksIAogICAgICAgIHJlbW92ZSA9IGZ1bmN0aW9uIHJlbW92ZSgpIHsKICAgICAgICAgICAgIWZ1bmN0aW9uIHJlbW92ZVN0eWxlRWxlbWVudChzdHlsZSkgewogICAgICAgICAgICAgICAgaWYgKG51bGwgPT09IHN0eWxlLnBhcmVudE5vZGUpIHJldHVybiAhMTsKICAgICAgICAgICAgICAgIHN0eWxlLnBhcmVudE5vZGUucmVtb3ZlQ2hpbGQoc3R5bGUpOwogICAgICAgICAgICB9KHN0eWxlKTsKICAgICAgICB9OwogICAgICAgIHJldHVybiB1cGRhdGUob2JqKSwgZnVuY3Rpb24gdXBkYXRlU3R5bGUobmV3T2JqKSB7CiAgICAgICAgICAgIGlmIChuZXdPYmopIHsKICAgICAgICAgICAgICAgIGlmIChuZXdPYmouY3NzID09PSBvYmouY3NzICYmIG5ld09iai5tZWRpYSA9PT0gb2JqLm1lZGlhICYmIG5ld09iai5zb3VyY2VNYXAgPT09IG9iai5zb3VyY2VNYXApIHJldHVybjsKICAgICAgICAgICAgICAgIHVwZGF0ZShvYmogPSBuZXdPYmopOwogICAgICAgICAgICB9IGVsc2UgcmVtb3ZlKCk7CiAgICAgICAgfTsKICAgIH0KICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24obGlzdCwgb3B0aW9ucykgewogICAgICAgIChvcHRpb25zID0gb3B0aW9ucyB8fCB7fSkuc2luZ2xldG9uIHx8ICJib29sZWFuIiA9PSB0eXBlb2Ygb3B0aW9ucy5zaW5nbGV0b24gfHwgKG9wdGlvbnMuc2luZ2xldG9uID0gaXNPbGRJRSgpKTsKICAgICAgICB2YXIgbGFzdElkZW50aWZpZXJzID0gbW9kdWxlc1RvRG9tKGxpc3QgPSBsaXN0IHx8IFtdLCBvcHRpb25zKTsKICAgICAgICByZXR1cm4gZnVuY3Rpb24gdXBkYXRlKG5ld0xpc3QpIHsKICAgICAgICAgICAgaWYgKG5ld0xpc3QgPSBuZXdMaXN0IHx8IFtdLCAiW29iamVjdCBBcnJheV0iID09PSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwobmV3TGlzdCkpIHsKICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGFzdElkZW50aWZpZXJzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZ2V0SW5kZXhCeUlkZW50aWZpZXIobGFzdElkZW50aWZpZXJzW2ldKTsKICAgICAgICAgICAgICAgICAgICBzdHlsZXNJbkRvbVtpbmRleF0ucmVmZXJlbmNlcy0tOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZm9yICh2YXIgbmV3TGFzdElkZW50aWZpZXJzID0gbW9kdWxlc1RvRG9tKG5ld0xpc3QsIG9wdGlvbnMpLCBfaSA9IDA7IF9pIDwgbGFzdElkZW50aWZpZXJzLmxlbmd0aDsgX2krKykgewogICAgICAgICAgICAgICAgICAgIHZhciBfaW5kZXggPSBnZXRJbmRleEJ5SWRlbnRpZmllcihsYXN0SWRlbnRpZmllcnNbX2ldKTsKICAgICAgICAgICAgICAgICAgICAwID09PSBzdHlsZXNJbkRvbVtfaW5kZXhdLnJlZmVyZW5jZXMgJiYgKHN0eWxlc0luRG9tW19pbmRleF0udXBkYXRlcigpLCBzdHlsZXNJbkRvbS5zcGxpY2UoX2luZGV4LCAxKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsYXN0SWRlbn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Bmb3IgKHZhciBwIGluIGIpIGIuaGFzT3duUHJvcGVydHkocCkgJiYgKGRbcF0gPSBiW3BdKTsKICAgICAgICB9LCBleHRlbmRTdGF0aWNzKGQsIGIpOwogICAgfSwgZnVuY3Rpb24oZCwgYikgewogICAgICAgIGZ1bmN0aW9uIF9fKCkgewogICAgICAgICAgICB0aGlzLmNvbnN0cnVjdG9yID0gZDsKICAgICAgICB9CiAgICAgICAgZXh0ZW5kU3RhdGljcyhkLCBiKSwgZC5wcm90b3R5cGUgPSBudWxsID09PSBiID8gT2JqZWN0LmNyZWF0ZShiKSA6IChfXy5wcm90b3R5cGUgPSBiLnByb3RvdHlwZSwgCiAgICAgICAgbmV3IF9fKTsKICAgIH0pLCBleHRlbmRTdGF0aWNzLCBfX2F3YWl0ZXIgPSB0aGlzICYmIHRoaXMuX19hd2FpdGVyIHx8IGZ1bmN0aW9uKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgewogICAgICAgIHJldHVybiBuZXcgKFAgfHwgKFAgPSBQcm9taXNlKSkoKGZ1bmN0aW9uKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICBzdGVwKGdlbmVyYXRvci50aHJvdyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgewogICAgICAgICAgICAgICAgcmVzdWx0LmRvbmUgPyByZXNvbHZlKHJlc3VsdC52YWx1ZSkgOiBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZSBpbnN0YW5jZW9mIFAgPyB2YWx1ZSA6IG5ldyBQKChmdW5jdGlvbihyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIH0ocmVzdWx0LnZhbHVlKS50aGVuKGZ1bGZpbGxlZCwgcmVqZWN0ZWQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0ZXAoKGdlbmVyYXRvciA9IGdlbmVyYXRvci5hcHBseSh0aGlzQXJnLCBfYXJndW1lbnRzIHx8IFtdKSkubmV4dCgpKTsKICAgICAgICB9KSk7CiAgICB9LCBfX2dlbmVyYXRvciA9IHRoaXMgJiYgdGhpcy5fX2dlbmVyYXRvciB8fCBmdW5jdGlvbih0aGlzQXJnLCBib2R5KSB7CiAgICAgICAgdmFyIGYsIHksIHQsIGcsIF8gPSB7CiAgICAgICAgICAgIGxhYmVsOiAwLAogICAgICAgICAgICBzZW50OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIGlmICgxICYgdFswXSkgdGhyb3cgdFsxXTsKICAgICAgICAgICAgICAgIHJldHVybiB0WzFdOwogICAgICAgICAgICB9LAogICAgICAgICAgICB0cnlzOiBbXSwKICAgICAgICAgICAgb3BzOiBbXQogICAgICAgIH07CiAgICAgICAgcmV0dXJuIGcgPSB7CiAgICAgICAgICAgIG5leHQ6IHZlcmIoMCksCiAgICAgICAgICAgIHRocm93OiB2ZXJiKDEpLAogICAgICAgICAgICByZXR1cm46IHZlcmIoMikKICAgICAgICB9LCAiZnVuY3Rpb24iID09IHR5cGVvZiBTeW1ib2wgJiYgKGdbU3ltYm9sLml0ZXJhdG9yXSA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9KSwgZzsKICAgICAgICBmdW5jdGlvbiB2ZXJiKG4pIHsKICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHYpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBzdGVwKG9wKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGYpIHRocm93IG5ldyBUeXBlRXJyb3IoIkdlbmVyYXRvciBpcyBhbHJlYWR5IGV4ZWN1dGluZy4iKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKDtfOyApIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmID0gMSwgeSAmJiAodCA9IDIgJiBvcFswXSA/IHkucmV0dXJuIDogb3BbMF0gPyB5LnRocm93IHx8ICgodCA9IHkucmV0dXJuKSAmJiB0LmNhbGwoeSksIAogICAgICAgICAgICAgICAgICAgICAgICAwKSA6IHkubmV4dCkgJiYgISh0ID0gdC5jYWxsKHksIG9wWzFdKSkuZG9uZSkgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoeSA9IDAsIHQgJiYgKG9wID0gWyAyICYgb3BbMF0sIHQudmFsdWUgXSksIG9wWzBdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHQgPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXy5sYWJlbCsrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG9wWzFdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6ICExCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfLmxhYmVsKyssIHkgPSBvcFsxXSwgb3AgPSBbIDAgXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwoKICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcCA9IF8ub3BzLnBvcCgpLCBfLnRyeXMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKHQgPSBfLnRyeXMsICh0ID0gdC5sZW5ndGggPiAwICYmIHRbdC5sZW5ndGggLSAxXSkgfHwgNiAhPT0gb3BbMF0gJiYgMiAhPT0gb3BbMF0pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMyA9PT0gb3BbMF0gJiYgKCF0IHx8IG9wWzFdID4gdFswXSAmJiBvcFsxXSA8IHRbM10pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXy5sYWJlbCA9IG9wWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKDYgPT09IG9wWzBdICYmIF8ubGFiZWwgPCB0WzFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXy5sYWJlbCA9IHRbMV0sIHQgPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ICYmIF8ubGFiZWwgPCB0WzJdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXy5sYWJlbCA9IHRbMl0sIF8ub3BzLnB1c2gob3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdFsyXSAmJiBfLm9wcy5wb3AoKSwgXy50cnlzLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3AgPSBib2R5LmNhbGwodGhpc0FyZywgXyk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICBvcCA9IFsgNiwgZSBdLCB5ID0gMDsKICAgICAgICAgICAgICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgICAgICAgICAgICAgICBmID0gdCA9IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICg1ICYgb3BbMF0pIHRocm93IG9wWzFdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBvcFswXSA/IG9wWzFdIDogdm9pZCAwLAogICAgICAgICAgICAgICAgICAgICAgICBkb25lOiAhMAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9KFsgbiwgdiBdKTsKICAgICAgICAgICAgfTsKICAgICAgICB9CiAgICB9LCBfX2ltcG9ydERlZmF1bHQgPSB0aGlzICYmIHRoaXMuX19pbXBvcnREZWZhdWx0IHx8IGZ1bmN0aW9uKG1vZCk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3M7CiAgICAgICAgICAgICAgICBicmVhazsKCiAgICAgICAgICAgICAgY2FzZSBTaXRlRW51bV8xLlNpdGVFbnVtLkJEX0RFVEFJTF9TaGFyZToKICAgICAgICAgICAgICAgIHRoaXMuaGFuZGxlID0gdGhpcy5zaGFyZVByb2Nlc3M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgTG9nZ2VyXzEuTG9nZ2VyLmluZm8oIlx1N2Y1MVx1NzZkOFx1ODllM1x1Njc5MCIpOwogICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgIENvcmVfMS5Db3JlLmF1dG9MYXp5bG9hZCgoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gJCh0aGF0LmhhbmRsZS5zZWxlY3RvcikubGVuZ3RoID4gMDsKICAgICAgICAgICAgfSksIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHRoYXQuZGV0YWlsUmVuZGVyKCk7CiAgICAgICAgICAgIH0pLCAuNSk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5wcm90b3R5cGUuZGV0YWlsUmVuZGVyID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXMsIGJ0blVwbG9hZCA9ICQodGhpcy5oYW5kbGUuc2VsZWN0b3IpOwogICAgICAgICAgICBpZiAoYnRuVXBsb2FkKSB7CiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMuaGFuZGxlLmJ0bkdlbmVyYXRlKCk7CiAgICAgICAgICAgICAgICBidG5VcGxvYWRbMF0ucHJlcGVuZChlKSwgRWxlXzEuRWxlLmJpbmRFdmVudChlLCBFdmVudEVudW1fMS5FdmVudEVudW0uY2xpY2ssIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICBfdGhpcy5oYW5kbGUuaGFuZGxlRXZlbnQoKTsKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgIH0sIEJhaU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BhblBhcnNlLnByZWZpeCArICctY2xvc2UiPlx1NTE3M1x1OTVlZDwvYnV0dG9uPlxuICAgIDwvZGl2PlxuPC9kaXY+XG4gICAgICAgICc7CiAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubWQgPSBuZXcgbWR1aV8xLmRlZmF1bHQuRGlhbG9nKGJveCwgewogICAgICAgICAgICAgICAgbW9kYWw6ICEwCiAgICAgICAgICAgIH0pLCBCYWlEdVBhblBhcnNlLm1kLm9wZW4oKTsKICAgICAgICAgICAgdmFyIGJveEggPSB7CiAgICAgICAgICAgICAgICB0b3A6ICgkKHVuc2FmZVdpbmRvdy53aW5kb3cpLmhlaWdodCgpIC0gJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItYm94LW0iKS5oZWlnaHQoKSkgLyAyICsgInB4IgogICAgICAgICAgICB9OwogICAgICAgICAgICAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1ib3gtbSIpLmNzcyhib3hIKSwgdGhpcy5tdWx0aXBsZUV2ZW50KCk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5tdWx0aXBsZUV2ZW50ID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgICAgICQoIi4iICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLWNsb3NlIikub24oImNsaWNrIiwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIF9hLCBfYjsKICAgICAgICAgICAgICAgIG51bGwgPT09IChfYSA9IEJhaUR1UGFuUGFyc2UubWQpIHx8IHZvaWQgMCA9PT0gX2EgfHwgX2EuY2xvc2UoKSwgbnVsbCA9PT0gKF9iID0gQmFpRHVQYW5QYXJzZS5tZCkgfHwgdm9pZCAwID09PSBfYiB8fCBfYi5kZXN0cm95KCk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIHRoYXQgPSB0aGlzOwogICAgICAgICAgICAkKCIuIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1tdWx0aXBsZS1wYXJzZXIiKS5vbigiY2xpY2siLCAoZnVuY3Rpb24oZWxlKSB7CiAgICAgICAgICAgICAgICB2YXIgZSA9ICQoZWxlLnRhcmdldCksIGZpZCA9IGUuYXR0cigiZGF0YS1maWQiKSwgZmlsZU5hbWUgPSBlLmF0dHIoImRhdGEtdGl0bGUiKTsKICAgICAgICAgICAgICAgIG5ldyBtZHVpXzEuZGVmYXVsdC5Ub29sdGlwKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi13YWl0LSIgKyBmaWQsIHsKICAgICAgICAgICAgICAgICAgICBjb250ZW50OiAiIgogICAgICAgICAgICAgICAgfSksIGUuYXR0cigiZGlzYWJsZWQiLCAidHJ1ZSIpLCB0aGF0Ll9fcGFyc2VyKE51bWJlci5wYXJzZUludChmaWQpKS50aGVuKChmdW5jdGlvbihyZXMpIHsKICAgICAgICAgICAgICAgICAgICAxID09IHJlcy5jb2RlID8gKCQoIiMiICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLXdhaXQtIiArIGZpZCkuaGlkZSgpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1wYXJzZXItdXJsLSIgKyBmaWQpLnNob3coKSwgCiAgICAgICAgICAgICAgICAgICAgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLXVhLSIgKyBmaWQpLnNob3coKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLWFyaWEtIiArIGZpZCkuc2hvdygpLCAKICAgICAgICAgICAgICAgICAgICAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1wYXJzZXItdXJsLSIgKyBmaWQpLmF0dHIoImRhdGEtY2xpcGJvYXJkLXRleHQiLCByZXMuZGF0YS5kbGluayksIAogICAgICAgICAgICAgICAgICAgIG5ldyB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ICAgICAgICBBbGVydF8xLkFsZXJ0LmluZm8ociwgNSwgImVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9KSkpIDogdGhhdC5lcnJvckJ1dHRvbihlLCByZXMubXNnLCBmaWQpOwogICAgICAgICAgICAgICAgfSksIChmdW5jdGlvbihyZWplY3RzKSB7CiAgICAgICAgICAgICAgICAgICAgX3RoaXMuZXJyb3JCdXR0b24oZSwgcmVqZWN0cywgZmlkKTsKICAgICAgICAgICAgICAgIH0pKS5maW5hbGx5KChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICBlLnJlbW92ZUF0dHIoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0pKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItbXVsdGlwbGUtcGFyc2VyIikub24oImNsaWNrIiwgKGZ1bmN0aW9uKGVsZSkgewogICAgICAgICAgICAgICAgJCgiLiIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItbXVsdGlwbGUtcGFyc2VyOnZpc2libGUiKS5sZW5ndGggPyAkKCIuIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1tdWx0aXBsZS1wYXJzZXI6dmlzaWJsZSIpLmNsaWNrKCkgOiAoQWxlcnRfMS5BbGVydC5pbmZvKCJcdTVkZjJcdTUxNjhcdTkwZThcdTg5ZTNcdTY3OTBcdTViOGNcdTYyMTAiKSwgCiAgICAgICAgICAgICAgICAkKGVsZS50YXJnZXQpLmhpZGUoKSk7CiAgICAgICAgICAgIH0pKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItbXVsdGlwbGUtYXJpYSIpLm9uKCJjbGljayIsIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICQoIi4iICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLW11bHRpcGxlLWFyaWE6dmlzaWJsZSIpL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AgICAgIHJldHVybiBfX2F3YWl0ZXIoX3RoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb2JqLCBmaWxlSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfX2dlbmVyYXRvcih0aGlzLCAoZnVuY3Rpb24oX2EpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqID0gbmV3IFBhblJlc18xLlBhcnNlclYzLCBmaWxlSW5mbyA9IHBjcy5saXN0WzBdLCBvYmouZmlkID0gZmlsZUluZm8uZnNfaWQsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9iai5zaXplID0gZmlsZUluZm8uc2l6ZSwgb2JqLm1kNSA9IGZpbGVJbmZvLm1kNSwgb2JqLlBDU1BhdGggPSB3aW5kb3cuYnRvYShmaWxlSW5mby5kbGluayksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubG9nKCJcdTVmMDBcdTU5Y2JcdTgzYjdcdTUzZDZcdTUyYTBcdTkwMWZcdTc2ZjRcdTk0ZmVcdWZmMGNcdThiZjdcdTdhMGRcdTU0MGUiKSwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQmFpZHVSb3V0ZXNfMS5CYWlkdVJvdXRlcy5wYXJzZXJWMyhvYmopLnRoZW4oKGZ1bmN0aW9uKHBhbkZpbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9hOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxID09IHBhbkZpbGUuY29kZSA/IHJlc29sdmUocGFuRmlsZSkgOiAoTG9nZ2VyXzEuTG9nZ2VyLmRlYnVnKHBhbkZpbGUpLCByZWplY3RzKCJcdTg5ZTNcdTY3OTBcdTU5MzFcdThkMjUiKSwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFsZXJ0XzEuQWxlcnQuaHRtbCgiXHU4OWUzXHU2NzkwXHU1OTMxXHU4ZDI1IiwgbnVsbCAhPT0gKF9hID0gcGFuRmlsZS5tc2cpICYmIHZvaWQgMCAhPT0gX2EgPyBfYSA6IHBhbkZpbGUubWVzc2FnZSkudGhlbigoZnVuY3Rpb24oKSB7fSkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSksIFsgMiBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgIHJlamVjdHMoIlx1ODllM1x1Njc5MFx1NTkzMVx1OGQyNVsiICsgSlNPTi5zdHJpbmdpZnkoZSkgKyAiXSIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5fX3NlbnRUb0FyaWEgPSBmdW5jdGlvbihmaWxlVXJsLCBmaWxlTmFtZSwgdXNlckFnZW50KSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgoZnVuY3Rpb24ocmVzb2x2ZSwgcmVqZWN0KSB7CiAgICAgICAgICAgICAgICB2YXIgYXJpYUNvbmZpZyA9IENvbmZpZ18xLkNvbmZpZy5nZXQoQmFpRHVQYW5QYXJzZS5BcmlhQ29uZmlnLCB7CiAgICAgICAgICAgICAgICAgICAgcnBjVXJsOiAiaHR0cDovL2xvY2FsaG9zdDo2ODAwL2pzb25ycGMiLAogICAgICAgICAgICAgICAgICAgIHJwY1Rva2VuOiAiIiwKICAgICAgICAgICAgICAgICAgICBycGNEaWM6ICJjOmFyaWEiCiAgICAgICAgICAgICAgICB9KSwgX2FyaWFDb25maWcgPSBhcmlhQ29uZmlnOwogICAgICAgICAgICAgICAgaWYgKCIiICE9IF9hcmlhQ29uZmlnLnJwY0RpYyAmJiAiIiAhPSBfYXJpYUNvbmZpZy5ycGNVcmwpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYXJpYURhdGEgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgICAgICAgICBpZDogIjE2MjkzNjA0NzU5MDIiLAogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICJhcmlhMi5hZGRVcmkiLAogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXM6IFsgInRva2VuOiIgKyBhcmlhQ29uZmlnLnJwY1Rva2VuLCBbICIiICsgZmlsZVVybCBdLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXI6ICIiICsgYXJpYUNvbmZpZy5ycGNEaWMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXQ6ICIiICsgZmlsZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAidXNlci1hZ2VudCI6ICIiICsgdXNlckFnZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIm1heC1jb25uZWN0aW9uLXBlci1zZXJ2ZXIiOiAiNCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGxpdDogIjQiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgInBpZWNlLWxlbmd0aCI6ICIxTSIKICAgICAgICAgICAgICAgICAgICAgICAgfSBdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBIdHRwXzEuSHR0cC5wb3N0KF9hcmlhQ29uZmlnLnJwY1VybCwgYXJpYURhdGEsICJqc29uIikudGhlbigoZnVuY3Rpb24ocmVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoIlx1NTNkMVx1OTAwMVx1NjIxMFx1NTI5Zlx1ZmYwMSIpOwogICAgICAgICAgICAgICAgICAgIH0pKS5jYXRjaCgoZnVuY3Rpb24oZSkgewogICAgICAg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aV8xLmRlZmF1bHQuRGlhbG9nKGJveCwgewogICAgICAgICAgICAgICAgbW9kYWw6ICEwCiAgICAgICAgICAgIH0pLCBCYWlEdVBhblBhcnNlLm1kLm9wZW4oKTsKICAgICAgICAgICAgbmV3IG1kdWlfMS5kZWZhdWx0LlRhYigiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItdGFiIik7CiAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubWQuaGFuZGxlVXBkYXRlKCksIEJhaUR1UGFuUGFyc2Uuc2luZ2xlRXZlbnQoKTsKICAgICAgICAgICAgdmFyIGJveEggPSB7CiAgICAgICAgICAgICAgICB0b3A6ICgkKHVuc2FmZVdpbmRvdy53aW5kb3cpLmhlaWdodCgpIC0gJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItYm94IikuaGVpZ2h0KCkpIC8gMiArICJweCIKICAgICAgICAgICAgfTsKICAgICAgICAgICAgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItYm94IikuY3NzKGJveEgpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1wYXJzZXItdjEiKS5vbigiY2xpY2siLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1wYXJzZXItdjEiKS5hdHRyKCJkaXNhYmxlZCIsICJ0cnVlIiksIEJhaUR1UGFuUGFyc2UucGFyc2VydjEoZmlsZSk7CiAgICAgICAgICAgIH0pKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLXYyIikub24oImNsaWNrIiwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLXYyIikuYXR0cigiZGlzYWJsZWQiLCAidHJ1ZSIpLCBCYWlEdVBhblBhcnNlLnBhcnNlcnYyKGZpbGUp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WNvcHkiKS5vbigic3VjY2VzcyIsIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubG9nKCJVQVx1NGZlMVx1NjA2Zlx1NTkwZFx1NTIzNlx1NjIxMFx1NTI5ZiEiKTsKICAgICAgICAgICAgfSkpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1idG4taGVscCIpLm9uKCJjbGljayIsIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIENvcmVfMS5Db3JlLm9wZW4oQmFpRHVQYW5QYXJzZS5oZWxwKTsKICAgICAgICAgICAgfSkpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1idG4taW5zdGFsbCIpLm9uKCJjbGljayIsIChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIENvcmVfMS5Db3JlLm9wZW4oQmFpRHVQYW5QYXJzZS5pbnN0YWxsKTsKICAgICAgICAgICAgfSkpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1idG4tam9pbnVzIikub24oImNsaWNrIiwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgQ29yZV8xLkNvcmUub3BlbihCYWlEdVBhblBhcnNlLmpvaW51cyk7CiAgICAgICAgICAgIH0pKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItYXJpYS1zYXZlIikub24oImNsaWNrIiwgQmFpRHVQYW5QYXJzZS5zYXZlQXJpYSksIAogICAgICAgICAgICB0aGlzLnNob3dBcmlhKCksICQoIi4iICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLWNsb3NlIikub24oImNsaWNrIiwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIF9hLCBfYjsKICAgICAgICAgICAgICAgIG51bGwgPT09IChfYSA9IEJhaUR1UGFuUGFyc2UubWQpIHx8IHZvaWQgMCA9PT0gX2EgfHwgX2EuY2xvc2UoKSwgbnVsbCA9PT0gKF9iID0gQmFpRHVQYW5QYXJzZS5tZCkgfHwgdm9pZCAwID09PSBfYiB8fCBfYi5kZXN0cm95KCk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBCYWlEdVBhblBhcnNlLnNob3dBcmlhID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHZhciBfYXJpYVNldHRpbmcgPSBDb25maWdfMS5Db25maWcuZ2V0KEJhaUR1UGFuUGFyc2UuQXJpYUNvbmZpZywgewogICAgICAgICAgICAgICAgcnBjVXJsOiAiaHR0cDovL2xvY2FsaG9zdDo2ODAwL2pzb25ycGMiLAogICAgICAgICAgICAgICAgcnBjRGljOiAiRDpcXEFyaWEiLAogICAgICAgICAgICAgICAgcnBjVG9rZW46ICIiCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICAkKCIjcnBjVXJsIikudmFsKG51bGwgPT0gX2FyaWFTZXR0aW5nID8gdm9pZCAwIDogX2FyaWFTZXR0aW5nLnJwY1VybCksICQoIiNycGNUb2tlbiIpLnZhbChudWxsID09IF9hcmlhU2V0dGluZyA/IHZvaWQgMCA6IF9hcmlhU2V0dGluZy5ycGNUb2tlbiksIAogICAgICAgICAgICAkKCIjcnBjRGlyIikudmFsKG51bGwgPT0gX2FyaWFTZXR0aW5nID8gdm9pZCAwIDogX2FyaWFTZXR0aW5nLnJwY0RpYyk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5zYXZlQXJpYSA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICB2YXIgYXJpYVNldHRpbmcgPSBuZXcgQXJpYUNvbmZpZ18xLkFyaWFDb25maWc7CiAgICAgICAgICAgIGFyaWFTZXR0aW5nLnJwY1VybCA9ICQoIiNycGNVcmwiKS52YWwoKSwgYXJpYVNldHRpbmcucnBjVG9rZW4gPSAkKCIjcnBjVG9rZW4iKS52YWwoKSwgCiAgICAgICAgICAgIGFyaWFTZXR0aW5nLnJwY0RpYyA9ICQoIiNycGNEaXIiKS52YWwoKSwgQ29uZmlnXzEuQ29uZmlnLnNldChCYWlEdVBhblBhcnNlLkFyaWFDb25maWcsIGFyaWFTZXR0aW5nKSwgCiAgICAgICAgICAgIG1kdWlfMS5kZWZhdWx0LnNuYWNrYmFyKHsKICAgICAgICAgICAgICAgIHBvc2l0aW9uOiAidG9wIiwKICAgICAgICAgICAgICAgIG1lc3NhZ2U6ICJcdTRmZGRcdTViNThcdTYyMTBcdTUyOWYiCiAgICAgICAgICAgIH0pOwogICAgICAgIH0sIEJhaUR1UGFuUGFyc2UubG9nID0gZnVuY3Rpb24obXNnKSB7CiAgICAgICAgICAgIGlmICghdGhpcy5sYXN0TG9nIHx8IG1zZyAhPT0gdGhpcy5sYXN0TG9nKSB7CiAgICAgICAgICAgICAgICB0aGlzLmxhc3RMb2cgPSBtc2c7CiAgICAgICAgICAgICAgICB2YXIgb2xkTG9nID0gJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItbG9nIikudmFsKCk7CiAgICAgICAgICAgICAgICAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1sb2ciKS52YWwobXNnICsgIlxyXG4iICsgb2xkTG9nKTsKICAgICAgICAgICAgfQogICAgICAgIH0sIEJhaUR1UGFuUGFyc2UuZ2V0U2hhcmVMaXN0SW5mbyA9IGZ1bmN0aW9uKGNvZGUsIHB3ZCkgewogICAgICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICB2YXIga2V5LCBmaWxlSW5mbywgcmVzOwogICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIChmdW5jdGlvbihfYSkgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2EubGFiZWwpIHsKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleSA9ICJzaGFyZWxpc3QtaW5mby0iICsgY29kZSArICItIiArIGNvZGUsIChmaWxlSW5mbyA9IENvbmZpZ18xLkNvbmZpZy5nZXQoa2V5LCAhMSkpID8gWyAyLCBmaWxlSW5mbyBdIDogWyA0LCBCYWlkdVJvdXRlc18xLkJhaWR1Um91dGVzLmdldFNoYXJlTGlzdChjb2RlLCBwd2QpIF07CgogICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMCAhPSAocmVzID0gX2Euc2VudCgpKS5lcnJubyA/IChCYWlEdVBhblBhcnNlLmxvZygiXHU1MTczXHU5NTJlXHU2NTcwXHU2MzZlMVx1ODNiN1x1NTNkNlx1NTkzMVx1OGQyNSxcdThiZjdcdTkxY2RcdThiZDVcdWZmMDEiKSwgCiAgICAgICAgICAgICAgICAgICAgICAgIExvZ2dlcl8xLkxvZ2dlci5kZWJ1ZyhmaWxlSW5mbyksIFsgMiwgITEgXSkgOiAoQ29uZmlnXzEuQ29uZmlnLnNldChrZXksIHJlcywgODY0MDApLCAKICAgICAgICAgICAgICAgICAgICAgICAgWyAyLCByZXMgXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9KSk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5wYXJzZXJ2MSA9IGZ1bmN0aW9uKGZpbGUpIHsKICAgICAgICAgICAgdmFyIF90aGlzID0gdGhpcywgY29kZSA9IENvbmZpZ18xLkNvbmZpZy5nZXQoQmFpRHVQYW5QYXJzZS5wYW5Db2RlLCAiIik7CiAgICAgICAgICAgIENvbmZpZ18xLkNvbmZpZy5nZXQoQmFpRHVQYW5QYXJzZS5wYW5LZXksICIiKTsKICAgICAgICAgICAgQmFpRHVQYW5QYXJzZS5sb2coIlx1NTFjNlx1NTkwN1x1ODllM1x1Njc5MFx1OTRmZVx1NjNhNSIpOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgQmFpZHVSb3V0ZXNfMS5CYWlkdVJvdXRlcy5hdXRoVG9rZW4oKS50aGVuKChmdW5jdGlvbih0b2tlbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfX2F3YWl0ZXIoX3RoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhdXRoVG9rZW4sIF90aGlzID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIChmdW5jdGlvbihfYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChhdXRoVG9rZW4gPSBVcmxfMS5VcmwuZ2V0KCJhY2Nlc3NfdG9rZW4iLCB0b2tlbikpID8gQmFpZHVSb3V0ZXNfMS5CYWlkdVJvdXRlcy5wY3NRdWVyeShbIGZpbGUuZnNfaWQgXSwgYXV0aFRva2VuKS50aGVuKChmdW5jdGlvbihwY3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX19hd2FpdGVyKF90aGlzLCB2b2lkIDAsIHZvaWQgMCwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb2JqLCBmaWxlSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIChmdW5jdGlvbihfYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iaiA9IG5ldyBQYW5SZXNfMS5QYXJzZXJWMywgZmlsZUluZm8gPSBwY3MubGlzdFswXSwgb2JqLmZpZCA9IGZpbGVJbmZvLmZzX2lkLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9iai5zaXplID0gZmlsZUluZm8uc2l6ZSwgb2JqLm1kNSA9IGZpbGVJbmZvLm1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bigoZnVuY3Rpb24oKSB7fSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpLCBbIDIgXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKSA6IChBbGVydF8xLkFsZXJ0Lmh0bWwoIlx1ODllM1x1Njc5MFx1NTkzMVx1OGQyNSIsICdcdTgzYjdcdTUzZDZ0b2tlblx1NTkzMVx1OGQyNSxcdThiZjc8YSBocmVmPSJodHRwczovL29wZW5hcGkuYmFpZHUuY29tL29hdXRoLzIuMC9hdXRob3JpemU/Y2xpZW50X2lkPUlsTHFCYlUzR2pRMHQ0NlRSd0ZhdGVUcHJIV2wzOXpGJnJlc3BvbnNlX3R5cGU9dG9rZW4mcmVkaXJlY3RfdXJpPW9vYiZzY29wZT1iYXNpYyxuZXRkaXNrIiByZWw9Im5vcmVmZXJyZXIiIHRhcmdldD0iX2JsYW5rIj5cdTcwYjlcdTUxZmJcdTYzODhcdTY3NDM8L2E+XHU1NDBlXHU5MWNkXHU4YmQ1JyksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQmFpRHVQYW5QYXJzZS5sb2coIlx1ODNiN1x1NTNkNnRva2VuXHU1OTMxXHU4ZDI1LFx1OGJmN1x1OTFjZFx1OGJkNVx1ZmYwMSIpLCBMb2dnZXJfMS5Mb2dnZXIuZGVidWcoYXV0aFRva2VuKSksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgWyAyIF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICB9KSkuY2F0Y2goKGZ1bmN0aW9uKGUpIHsKICAgICAgICAgICAgICAgICAgICBBbGVydF8xLkFsZXJ0Lmh0bWwoIlx1ODllM1x1Njc5MFx1NTkzMVx1OGQyNSIsICdcdT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gICAgICAgIHZhciBfdGhpcyA9IHRoaXMsIGNvZGUgPSBDb25maWdfMS5Db25maWcuZ2V0KEJhaUR1UGFuUGFyc2UucGFuQ29kZSwgIiIpOwogICAgICAgICAgICBDb25maWdfMS5Db25maWcuZ2V0KEJhaUR1UGFuUGFyc2UucGFuS2V5LCAiIik7CiAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubG9nKCJcdTUxYzZcdTU5MDdcdTg5ZTNcdTY3OTBcdTk0ZmVcdTYzYTUiKTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIEJhaUR1UGFuUGFyc2Uuc2hhcmVGaWxlKGZpbGUpLnRoZW4oKGZ1bmN0aW9uKHBhbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfX2F3YWl0ZXIoX3RoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmosIGZpbGVJbmZvOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgKGZ1bmN0aW9uKF9hKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKF9hLmxhYmVsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGFuID8gKG9iaiA9IG5ldyBQYW5SZXNfMS5QYXJzZXJWMywgWyA0LCBCYWlkdVJvdXRlc18xLkJhaWR1Um91dGVzLmdldFNoYXJlTGlzdFYxKHBhbi5saW5rLnJlcGxhY2UoImh0dHBzOi8vcGFuLmJhaWR1LmNvbS9zLyIsICIiKSwgcGFuLnB3ZCkgXSkgOiBbIDMsIDQgXTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMCA9PSAoZmlsZUluZm8gPSBfYS5zZW50KCkpLmVycm5vID8gWyAzLCAzIF0gOiBbIDQsIEFsZXJ0XzEuQWxlcnQuaHRtbCgiXHU4OWUzXHU2NzkwXHU1OTMxXHU4ZDI1IiwgIlx1NjU4N1x1NGVmNlx1NGZlMVx1NjA2Zlx1ODNiN1x1NTNkNlx1NTkzMVx1OGQyNSxcdThiZjdcdTkxY2RcdThiZDUiKSBdOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfYS5zZW50KCksIEJhaUR1UGFuUGFyc2UubG9nKCJcdTUxNzNcdTk1MmVcdTY1NzBcdTYzNmUxXHU4M2I3XHU1M2Q2XHU1OTMxXHU4ZDI1LFx1OGJmN1x1OTFjZFx1OGJkNVx1ZmYwMSIpLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb2dnZXJfMS5Mb2dnZXIuZGVidWcoZmlsZUluZm8pLCBbIDIgXTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqLmZpZCA9IGZpbGVJbmZvLmRhdGEubGlzdFswXS5mc19pZCwgb2JqLmxpbmsgPSBwYW4ubGluaywgb2JqLnB3ZCA9IHBhbi5wd2QsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9iai5jb2RlID0gY29kZSwgb2JqLlBDU1BhdGggPSAibm9uZSIsIEJhaWR1Um91dGVzXzEuQmFpZHVSb3V0ZXMucGFyc2VyVjMob2JqKS50aGVuKChmdW5jdGlvbihwYW5GaWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMSA9PSBwYW5GaWxlLmNvZGUgPyAoQmFpRHVQYW5QYXJzZS5sb2coIlx1ODllM1x1Njc5MFx1NWI4Y1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gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIDIgXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIH0pKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLXYyIikucmVtb3ZlQXR0cigiZGlzYWJsZWQiKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgZSA/IEJhaUR1UGFuUGFyc2UubG9nKCJcdTg5ZTNcdTY3OTBcdTU5MzFcdThkMjUsXHU4YmY3XHU5MWNkXHU4YmQ1IikgOiBCYWlEdVBhblBhcnNlLmxvZygiXHU4YmY3XHU2YzQyXHU4ZDg1XHU2NWY2LFx1OGJmN1x1OTFjZFx1OGJkNSIpLCAKICAgICAgICAgICAgICAgICQoIiMiICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLXBhcnNlci12MiIpLnJlbW92ZUF0dHIoImRpc2FibGVkIik7CiAgICAgICAgICAgIH0KICAgICAgICB9LCBCYWlEdVBhblBhcnNlLnNoYXJlRmlsZSA9IGZ1bmN0aW9uKGZpbGUpIHsKICAgICAgICAgICAgdmFyIF9hOwogICAgICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICB2YXIgc3RvcmVLZXksIHBhbkluZm8sIGJkc3Rva2VuLCBzaGFyZSwgZV8xLCBtc2c7CiAgICAgICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgKGZ1bmN0aW9uKF9iKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChfYi5sYWJlbCkgewogICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVLZXkgP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YWlkdVJvdXRlc18xLkJhaWR1Um91dGVzLnNoYXJlRmlsZShmaWxlLmZzX2lkLCBiZHN0b2tlbiwgcGFuSW5mby5wd2QpIF07CgogICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2hhcmUgPSBfYi5zZW50KCksIFsgMywgNSBdOwoKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVfMSA9IF9iLnNlbnQoKSwgTG9nZ2VyXzEuTG9nZ2VyLmVycm9yKGVfMSksIFsgMywgNSBdOwoKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIExvZ2dlcl8xLkxvZ2dlci5kZWJ1ZyhzaGFyZSksIEJhaUR1UGFuUGFyc2UubG9jayA9ICExLCBbIDcgXTsKCiAgICAgICAgICAgICAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgwID09IHNoYXJlLmVycm5vKSByZXR1cm4gQmFpRHVQYW5QYXJzZS5sb2coIlx1NTIxYlx1NWVmYVx1NGUzNFx1NjVmNlx1NTIwNlx1NGVhYlx1OTRmZVx1NjNhNVx1NjIxMFx1NTI5ZixcdTUxYzZcdTU5MDdcdTUxOTlcdTUxNjVcdTY3MmNcdTU3MzBcdTdmMTNcdTViNTgiKSwgCiAgICAgICAgICAgICAgICAgICAgICAgIHBhbkluZm8ubGluayA9IHNoYXJlLmxpbmssIHBhbkluZm8uc2hhcmVpZCA9IHNoYXJlLnNoYXJlaWQsIENvbmZpZ18xLkNvbmZpZy5zZXQoc3RvcmVLZXksIHBhbkluZm8sIDY0ODAwKSwgCiAgICAgICAgICAgICAgICAgICAgICAgIEJhaUR1UGFuUGFyc2UubG9nKCJcdTY3MmNcdTU3MzBcdTdmMTNcdTViNThcdTUxOTlcdTUxNjVcdTViOGNcdTYyMTAsXHU1ZjAwXHU1OWNiXHU4ZmRiXHU4ODRjXHU4OWUzXHU2NzkwIiksIAogICAgICAgICAgICAgICAgICAgICAgICBbIDIsIHBhbkluZm8gXTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChtc2cgPSAiIiwgc2hhcmUuZXJybm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDExMDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1zZyA9ICJcdTYwYThcdTRlY2FcdTU5MjlcdTUyMDZcdTRlYWJcdTU5MmFcdTU5MWFcdTRlODZcdWZmMGMyNFx1NWMwZlx1NjVmNlx1NTQwZVx1NTE4ZFx1OGJkNVx1NTQyN1x1ZmYwMSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxMTU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgPSAiXHU3NjdlXHU1ZWE2XHU4YmY0XHVmZjFhXHU4YmU1XHU2NTg3XHU0ZWY2XHU3OTgxXHU2YjYyXHU1MjA2XHU0ZWFiXHVmZjAxXHVmZjFhIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIC02OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnID0gIlx1OGJmN1x1OTFjZFx1NjViMFx1NzY3Ylx1NWY1NVx1ZmYwMVx1ZmYxYSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtc2cgPSAiXHU1MjA2XHU0ZWFiXHU2NTg3XHU0ZWY2XHU1OTMxXHU4ZDI1XHVmZjBjXHU1YmZjXHU4MWY0XHU2NWUwXHU2Y2Q1XHU4M2I3XHU1M2Q2XHU3NmY0XHU5NGZlXHU0ZTBiXHU4ZjdkXHU1NzMwXHU1NzQwXHVmZjBjXHU4YmY3XHU5MWNkXHU4YmQ1XHVmZjAxIiwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbIDIsIHBhbkluZm8gXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbXNnICs9ICJbIiArIHNoYXJlLmVycm5vICsgIl0iLCBBbGVydF8xLkFsZXJ0Lmh0bWwoIlx1NTNkMVx1NzUxZlx1OTUxOVx1OGJlZiEiLCBtc2cpLCAKICAgICAgICAgICAgICAgICAgICAgICAgWyAyLCAhMSBdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEJhaUR1UGFuUGFyc2Uuc2V0VXJsID0gZnVuY3Rpb24odXJsKSB7CiAgICAgICAgICAgICQoIiMiICsgQmFpRHVQYW5QYXJzZS5wcmVmaXggKyAiLXBhcnNlciIpLmhpZGUoKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItcGFyc2VyLXVybCIpLmF0dHIoImRhdGEtY2xpcGJvYXJkLXRleHQiLCB1cmwpLnNob3coKTsKICAgICAgICB9LCBCYWlEdVBhblBhcnNlLnNldEFyaWEyID0gZnVuY3Rpb24oZmlsZVVybCwgZmlsZU5hbWUsIHVzZXJBZ2VudCkgewogICAgICAgICAgICAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1idG4tYXJpYSIpLnNob3coKSwgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItYnRuLWFyaWEiKS5jbGljaygoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICBCYWlEdVBhblBhcnNlLnNlbnRUb0FyaWEoZmlsZVVybCwgZmlsZU5hbWUsIHVzZXJBZ2VudCk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBCYWlEdVBhblBhcnNlLnNldFVzZXJBZ2VudCA9IGZ1bmN0aW9uKHVzZXJBZ2VudCkgewogICAgICAgICAgICAibmV0ZGlzaztzaHVtYSIgIT09IHVzZXJBZ2VudCAmJiAoJCgiI3VhaW5mbyIpLmF0dHIoImRhdGEtY2xpcGJvYXJkLXRleHQiLCB1c2VyQWdlbnQpLCAKICAgICAgICAgICAgJCgiIyIgKyBCYWlEdVBhblBhcnNlLnByZWZpeCArICItdWEtY29weSIpLmF0dHIoImRhdGEtY2xpcGJvYXJkLXRleHQiLCB1c2VyQWdlbnQpKTsKICAgICAgICB9LCBCYWlEdVBhblBhcnNlLmdldFBhcnNlVXJsID0gZnVuY3Rpb24oZExpbmssIHBhbkluZm8pIHsKICAgICAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIGtleSwgY2FjaGVLZXksIHBhblBhcnNlSW5mbywgcGFuUmVzOwogICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIChmdW5jdGlvbihfYSkgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2EubGFiZWwpIHsKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleSA9IENvbmZpZ18xLkNvbmZpZy5nZXQoQmFpRHVQYW5QYXJzZS5wYW5LZXksICIiKSwgY2FjaGVLZXkgPSBwYW5JbmZvLmlkICsgIi1QYW5QYXJzZS1DYWNoZSIsIAogICAgICAgICAgICAgICAgICAgICAgICAocGFuUGFyc2VJbmZvID0gQ29uZmlnXzEuQ29uZmlnLmdldChjYWNoZUtleSwgITEpKSA/IFsgMywgMiBdIDogWyA0LCBCYWlkdVJvdXRlc18xLkJhaWR1Um91dGVzLnBhcnNlclBjc1VybChkTGluaywga2V5LCBwYW5JbmZvKSBdOwoKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICAgICAgcGFuUmVzID0gX2Euc2VudCgpLCBwYW5QYXJzZUluZm8gPSBwYW5SZXMsIDEgPT0gcGFuUmVzLmNvZGUgJiYgQ29uZmlnXzEuQ29uZmlnLnNldChjYWNoZUtleSwgcGFuUmVzLCAzNjAwKSwgCiAgICAgICAgICAgICAgICAgICAgICAgIF9hLmxhYmVsID0gMjsKCiAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIDIsIHBhblBhcnNlSW5mbyBdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEJhaUR1UGFuUGFyc2UuZ2V0UGFyc2VVcmxWMiA9IGZ1bmN0aW9uKHBhbkluZm8pIHsKICAgICAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIGNhY2hlS2V5LCBwYW5QYXJzZUluZm8sIHBhblJlczsKICAgICAgICAgICAgICAgIHJldHVybiBfX2dlbmVyYXRvcih0aGlzLCAoZnVuY3Rpb24oX2EpIHsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKF9hLmxhYmVsKSB7CiAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25maWdfMS5Db25maWcuZ2V0KEJhaUR1UGFuUGFyc2UucGFuS2V5LCAiIiksIGNhY2hlS2V5ID0gcGFuSW5mby5pZCArICItUGFuUGFyc2UtQ2FjaGUiLCAKICAgICAgICAgICAgICAgICAgICAgICAgKHBhblBhcnNlSW5mbyA9IENvbmZpZ18xLkNvbmZpZy5nZXQoY2FjaGVLZXksICExKSkgPyBbIDMsIDIgXSA6IFsgNCwgQmFpZHVSb3V0ZXNfMS5CYWlkdVJvdXRlcy5wYXJzZXJQY3NVcmxWMihwYW5JbmZvKSBdOwoKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICAgICAgcGFuUmVzID0gX2Euc2VudCgpLCBwYW5QYXJzZUluZm8gPSBwYW5SZXMsIDEgPT0gcGFuUmVzLmNvZGUgJiYgQ29uZmlnXzEuQ29uZmlnLnNldChjYWNoZUtleSwgcGFuUmVzLCAzNjAwKSwgCiAgICAgICAgICAgICAgICAgICAgICAgIF9hLmxhYmVsID0gMjsKCiAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIDIsIHBhblBhcnNlSW5mbyBdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEJhaUR1UGFuUGFyc2UuX2NvZGVRdWVyeSA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICB2YXIgY3VycmVudEtleSwgZmxvd0luZm8sIGxlZnREb207CiAgICAgICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgKGZ1bmN0aW9uKF9hKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChfYS5sYWJlbCkgewogICAgICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKGN1cnJlbnRLZXkgPSBDb25maWdfMS5Db25maWcuZ2V0KEJhaUR1UGFuUGFyc2UucGFuS2V5LCAiIikpID8gWyA0LCBCYWlkdVJvdXRlc18xLkJhaWR1Um91dGVzLmNvZGVRdWVyeShjdXJyZW50S2V5KSBdIDogWyAzLCAyIF07CgogICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICAwID09IChmbG93SW5mbyA9IF9hLnNlbnQoKSkuZXJyb3IgJiYgKENvbmZpZ18xLkNvbmZpZy5zZXQoQmFpRHVQYW5QYXJzZS5mbG93SW5mb0tleSwgZmxvd0luZm8pLCAKICAgICAgICAgICAgICAgICAgICAgICAgKGxlZnREb20gPSAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1mbG93LWxlZnQiKSkubGVuZ3RoICYmIGxlZnREb20udGV4dCgiXHU2ZDQxXHU5MWNmXHU2MDNiXHU4YmExOiIgKyBDb3JlXzEuQ29yZS5odW1hblNpemUoZmxvd0luZm8uVFNpemUpICsgIixcdTVkZjJcdTc1MjhcdTZkNDFcdTkxY2Y6IiArIENvcmVfMS5Db3JlLmh1bWFuU2l6ZShmbG93SW5mby5VU2l6ZSkgKyAiLFx1NTI2OVx1NGY1OVx1NmQ0MVx1OTFjZjoiICsgQ29yZV8xLkNvcmUuaHVtYW5TaXplKGZsb3dJbmZvLkxTaXplKSkpLCAKICAgICAgICAgICAgICAgICAgICAgICAgX2EubGFiZWwgPSAyOwoKICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsgMiBdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEJhaUR1UGFuUGFyc2Uuc2V0S2V5ID0gZnVuY3Rpb24oY29kZSkgewogICAgICAgICAgICBBbGVydF8xLkFsZXJ0LmlucHV0KCJcdThiZjdcdThmOTNcdTUxNjVcdTUzNjFcdTViYzYiLCBjb2RlID8gU3RyaW5nKGNvZGUpIDogIiIpLnRoZW4oKGZ1bmN0aW9uKHJlcykgewogICAgICAgICAgICAgICAgaWYgKHJlcy5pc0NvbmZpcm1lZCAmJiByZXMudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBMb2dnZXJfMS5Mb2dnZXI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gICAgICAgICAgICAgQmFpRHVQYW5QYXJzZS5zZXRLZXkoY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBCYWlEdVBhblBhcnNlLnNldENvZGUgPSBmdW5jdGlvbihjb2RlKSB7CiAgICAgICAgICAgIEFsZXJ0XzEuQWxlcnQuaW5wdXQoIlx1OGJmN1x1OGY5M1x1NTE2NVx1OWE4Y1x1OGJjMVx1NzgwMSIsIGNvZGUgPyBTdHJpbmcoY29kZSkgOiAiIikudGhlbigoZnVuY3Rpb24ocmVzKSB7CiAgICAgICAgICAgICAgICByZXMuaXNDb25maXJtZWQgJiYgcmVzLnZhbHVlICYmIChMb2dnZXJfMS5Mb2dnZXIuaW5mbygiXHU1Zjk3XHU1MjMwXHU5YThjXHU4YmMxXHU3ODAxOiIgKyByZXMudmFsdWUpLCAKICAgICAgICAgICAgICAgIENvbmZpZ18xLkNvbmZpZy5zZXQoQmFpRHVQYW5QYXJzZS5wYW5Db2RlLCByZXMudmFsdWUpLCAkKCIjIiArIEJhaUR1UGFuUGFyc2UucHJlZml4ICsgIi1jb2RlLXYiKS50ZXh0KHJlcy52YWx1ZSkpOwogICAgICAgICAgICB9KSk7CiAgICAgICAgfSwgQmFpRHVQYW5QYXJzZS5zZW50VG9BcmlhID0gZnVuY3Rpb24oZmlsZVVybCwgZmlsZU5hbWUsIHVzZXJBZ2VudCkgewogICAgICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCAoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICB2YXIgYXJpYUNvbmZpZywgX2FyaWFDb25maWcsIGFyaWFEYXRhOwogICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIChmdW5jdGlvbihfYSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmlhQ29uZmlnID0gQ29uZmlnXzEuQ29uZmlnLmdldChCYWlEdVBhblBhcnNlLkFyaWFDb25maWcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgcnBjVXJsOiAiaHR0cDovL2xvY2FsaG9zdDo2ODAwL2pzb25ycGMiLAogICAgICAgICAgICAgICAgICAgICAgICBycGNUb2tlbjogIiIsCiAgICAgICAgICAgICAgICAgICAgICAgIHJwY0RpYzogImM6YXJpYSIKICAgICAgICAgICAgICAgICAgICB9KSwgIiIgPT0gKF9hcmlhQ29uZmlnID0gYXJpYUNvbmZpZykucnBjRGljIHx8ICIiID09IF9hcmlhQ29uZmlnLnJwY1VybCA/IChCYWlEdVBhblBhcnNlLmxvZygiQXJpYTJcdTRlMGJcdThmN2RcdTU2NjhcdTkxNGRcdTdmNmVcdTVjMWFcdTY3MmFcdTkxNGRcdTdmNmVcdTViOGNcdTYyMTAsXHU4YmY3XHU1MTQ4XHU5MTRkXHU3ZjZlQXJpYTJcdTRlMGJcdThmN2RcdTU2NjhcdTRmZTFcdTYwNmYiKSwgCiAgICAgICAgICAgICAgICAgICAgWyAyIF0pIDogKGFyaWFEYXRhID0gewogICAgICAgICAgICAgICAgICAgICAgICBqc29ucnBjOiAiMi4wIiwKICAgICAgICAgICAgICAgICAgICAgICAgaWQ6ICIxNjI5MzYwNDc1OTAyIiwKICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiYXJpYTIuYWRkVXJpIiwKICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBbICJ0b2tlbjoiICsgYXJpYUNvbmZpZy5ycGNUb2tlbiwgWyAiIiArIGZpbGVVcmwgXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlyOiAiIiArIGFyaWFDb25maWcucnBjRGljLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0OiAiIiArIGZpbGVOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgInVzZXItYWdlbnQiOiAiI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BSUxfU2hhcmUiLCBTaXRlRW51bS5MWlkgPSAiTFpZIiwgU2l0ZUVudW0uU3VOaW5nID0gIlN1TmluZyIsIAogICAgICAgIFNpdGVFbnVtLlZwID0gIlZwIiwgU2l0ZUVudW0uR3dkID0gIkd3ZCI7CiAgICB9KGV4cG9ydHMuU2l0ZUVudW0gfHwgKGV4cG9ydHMuU2l0ZUVudW0gPSB7fSkpOwp9LCBmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKICAgICJ1c2Ugc3RyaWN0IjsKICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsIHsKICAgICAgICB2YWx1ZTogITAKICAgIH0pLCBleHBvcnRzLkNvcmUgPSB2b2lkIDA7CiAgICB2YXIgQnJvd2VyVHlwZV8xID0gX193ZWJwYWNrX3JlcXVpcmVfXygxOCksIENvcmUgPSBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBDb3JlKCkge30KICAgICAgICByZXR1cm4gQ29yZS5jdXJyZW50VXJsID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHJldHVybiB3aW5kb3cubG9jYXRpb24uaHJlZjsKICAgICAgICB9LCBPYmplY3QuZGVmaW5lUHJvcGVydHkoQ29yZSwgInVybCIsIHsKICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiB3aW5kb3cubG9jYXRpb24uaHJlZjsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgZW51bWVyYWJsZTogITEsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogITAKICAgICAgICB9KSwgT2JqZWN0LmRlZmluZVByb3BlcnR5KENvcmUsICJjbGVhclVybCIsIHsKICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnVybC5yZXBsYWNlKHdpbmRvdy5sb2NhdGlvbi5oYXNoLCAiIik7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGVudW1lcmFibGU6ICExLAogICAgICAgICAgICBjb25maWd1cmFibGU6ICEwCiAgICAgICAgfSksIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShDb3JlLCAiaGFzaCIsIHsKICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiB3aW5kb3cubG9jYXRpb24uaGFzaC5zbGljZSgxKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgZW51bWVyYWJsZTogITEsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogITAKICAgICAgICB9KSwgQ29yZS5vcGVuID0gZnVuY3Rpb24odXJsLCBmcm9udCkgewogICAgICAgICAgICB2b2lkIDAgPT09IGZyb250ICYmIChmcm9udCA9ICExKSwgR01fb3BlbkluVGFiKHVybCwgewogICAgICAgICAgICAgICAgYWN0aXZlOiAhZnJvbnQKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgQ29yZS5hdXRvTGF6eWxvYWQgPSBmdW5jdGlvbihpc09rLCBjYWxsYmFjaywgdGltZSkgewogICAgICAgICAgICB2b2lkIDAgPT09IHRpbWUgJiYgKHRpbWUgPSA1KSwgaXNPaygpID8gY2FsbGJhY2soKSA6IHNldFRpbWVvdXQoKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgQ29yZS5hdXRvTGF6eWxvYWQoaXNPaywgY2FsbGJhY2ssIHRpbWUpOwogICAgICAgICAgICB9KSwgMWUzICogdGltZSk7CiAgICAgICAgfSwgQ29yZS5iYWNrZ3JvdW5kID0gZnVuY3Rpb24oY2FsbGJhY2ssIHRpbWUpIHsKICAgICAgICAgICAgdm9pZCAwID09PSB0aW1lICYmICh0aW1lID0gNSksIHNldEludGVydmFsKChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIGNhbGxiYWNrKCk7CiAgICAgICAgICAgIH0pLCAxZTMgKiB0aW1lKTsKICAgICAgICB9LCBDb3JlLmxhenlsb2FkID0gZnVuY3Rpb24oY2FsbGJhY2ssIHRpbWUpIHsKICAgICAgICAgICAgdm9pZCAwID09PSB0aW1lICYmICh0aW1lID0gNSksIHNldFRpbWVvdXQoKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgfSksIDFlMyAqIHRpbWUpOwogICAgICAgIH0sIENvcmUuYWRkU3R5bGUgPSBmdW5jdGlvbihjb250ZW50KSB7CiAgICAgICAgICAgIGlmIChHTV9hZGRTdHlsZSkgR01fYWRkU3R5bGUoY29udGVudCk7IGVsc2UgewogICAgICAgICAgICAgICAgdmFyIHN0eWxlID0gdW5zYWZlV2luZG93LndpbmRvdy5kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzdHlsZSIpOwogICAgICAgICAgICAgICAgc3R5bGUuaW5uZXJIVE1MID0gY29udGVudCwgdW5zYWZlV2luZG93LndpbmRvdy5kb2N1bWVudC5oZWFkLmFwcGVuZChzdHlsZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9LCBDb3JlLmFkZFN0eWxlVXJsID0gZnVuY3Rpb24odXJsKSB7CiAgICAgICAgICAgIHZhciBzdHlsZSA9IHVuc2FmZVdpbmRvdy53aW5kb3cuZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgibGluayIpOwogICAgICAgICAgICBzdHlsZS5ocmVmID0gdXJsLCBzdHlsZS5yZWwgPSAic3R5bGVzaGVldCIsIHVuc2FmZVdpbmRvdy53aW5kb3cuZG9jdW1lbnQuaGVhZC5hcHBlbmQoc3R5bGUpOwogICAgICAgIH0sIENvcmUuYWRkU2NyaXB0VXJsID0gZnVuY3Rpb24odXJsKSB7CiAgICAgICAgICAgIHZhciBzY3JpcHQgPSB1bnNhZmVXaW5kb3cud2luZG93LmRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOwogICAgICAgICAgICBzY3JpcHQudHlwZSA9ICJ0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ICAgICAgIH0sIENvcmUuaHVtYW5TaXplID0gZnVuY3Rpb24oc291cmNlKSB7CiAgICAgICAgICAgIGlmIChudWxsID09IHNvdXJjZSB8fCAwID09IHNvdXJjZSkgcmV0dXJuICIwIEJ5dGVzIjsKICAgICAgICAgICAgInN0cmluZyIgPT0gdHlwZW9mIHNvdXJjZSAmJiAoc291cmNlID0gcGFyc2VGbG9hdChzb3VyY2UpKTsKICAgICAgICAgICAgdmFyIGluZGV4OwogICAgICAgICAgICByZXR1cm4gaW5kZXggPSBNYXRoLmZsb29yKE1hdGgubG9nKHNvdXJjZSkgLyBNYXRoLmxvZygxMDI0KSksIChzb3VyY2UgLyBNYXRoLnBvdygxMDI0LCBpbmRleCkpLnRvRml4ZWQoMikgKyAiICIgKyBbICJCeXRlcyIsICJLQiIsICJNQiIsICJHQiIsICJUQiIsICJQQiIsICJFQiIsICJaQiIsICJZQiIgXVtpbmRleF07CiAgICAgICAgfSwgQ29yZTsKICAgIH0oKTsKICAgIGV4cG9ydHMuQ29yZSA9IENvcmU7Cn0sIGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewogICAgInVzZSBzdHJpY3QiOwogICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgewogICAgICAgIHZhbHVlOiAhMAogICAgfSksIGV4cG9ydHMuRXZlbnRFbnVtID0gdm9pZCAwLCBmdW5jdGlvbihFdmVudEVudW0pIHsKICAgICAgICBFdmVudEVudW0uY2xpY2sgPSAiY2xpY2siOwogICAgfShleHBvcnRzLkV2ZW50RW51bSB8fCAoZXhwb3J0cy5FdmVudEVudW0gPSB7fSkpOwp9LCBmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKICAgICJ1c2Ugc3RyaWN0IjsKICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24odXNlU291cmNlTWFwKSB7CiAgICAgICAgdmFyIGxpc3QgPSBbXTsKICAgICAgICByZXR1cm4gbGlzdC50b1N0cmluZyA9IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoKGZ1bmN0aW9uKGl0ZW0pIHsKICAgICAgICAgICAgICAgIHZhciBjb250ZW50ID0gZnVuY3Rpb24gY3NzV2l0aE1hcHBpbmdUb1N0cmluZyhpdGVtLCB1c2VTb3VyY2VNYXApIHsKICAgICAgICAgICAgICAgICAgICB2YXIgY29udGVudCA9IGl0ZW1bMV0gfHwgIiIsIGNzc01hcHBpbmcgPSBpdGVtWzNdOwogICAgICAgICAgICAgICAgICAgIGlmICghY3NzTWFwcGluZykgcmV0dXJuIGNvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKHVzZVNvdXJjZU1hcCAmJiAiZnVuY3Rpb24iID09IHR5cGVvZiBidG9hKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzb3VyY2VNYXBwaW5nID0gZnVuY3Rpb24gdG9Db21tZW50KHNvdXJjZU1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJhc2U2NCA9IGJ0b2EodW5lc2NhcGUoZW5jb2RlVVJJQ29tcG9uZW50KEpTT04uc3RyaW5naWZ5KHNvdXJjZU1hcCkpKSksIGRhdGEgPSAic291cmNlTWFwcGluZ1VSTD1kYXRhOmFwcGxpY2F0aW9uL2pzb247Y2hhcnNldD11dGYtODtiYXNlNjQsIi5jb25jYXQoYmFzZTY0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiLyojICIuY29uY2F0KGRhdGEsICIgKi8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfShjc3NNYXBwaW5nKSwgc291cmNlVVJMcyA9IGNzc01hcHBpbmcuc291cmNlcy5tYXAoKGZ1bmN0aW9uKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIvKiMgc291cmNlVVJMPSIuY29uY2F0KGNzc01hcHBpbmcuc291cmNlUm9vdCB8fCAiIikuY29uY2F0KHNvdXJjZSwgIiAqLyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIGNvbnRlbnQgXS5jb25jYXQoc291cmNlVVJMcykuY29uY2F0KFsgc291cmNlTWFwcGluZyBdKS5qb2luKCJcbiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gWyBjb250ZW50IF0uam9pbigiXG4iKTsKICAgICAgICAgICAgICAgIH0oaXRlbSwgdXNlU291cmNlTWFwKTsKICAgICAgICAgICAgICAgIHJldHVybiBpdGVtWzJdID8gIkBtZWRpYSAiLmNvbmNhdChpdGVtWzJdLCAiIHsiKS5jb25jYXQoY29udGVudCwgIn0iKSA6IGNvbnRlbnQ7CiAgICAgICAgICAgIH0pKS5qb2luKCIiKTsKICAgICAgICB9LCBsaXN0LmkgPSBmdW5jdGlvbihtb2R1bGVzLCBtZWRpYVF1ZXJ5LCBkZWR1cGUpIHsKICAgICAgICAgICAgInN0cmluZyIgPT0gdHlwZW9mIG1vZHVsZXMgJiYgKG1vZHVsZXMgPSBbIFsgbnVsbCwgbW9kdWxlcywgIiIgXSBdKTsKICAgICAgICAgICAgdmFyIGFscmVhZHlJbXBvcnRlZE1vZHVsZXMgPSB7fTsKICAgICAgICAgICAgaWYgKGRlZHVwZSkgZm9yICh2YXIgaSA9IDA7IGkgPCB0aGlzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICB2YXIgaWQgPSB0aGlzW2ldWzBdOwogICAgICAgICAgICAgICAgbnVsbCAhPSBpZCAmJiAoYWxyZWFkeUltcG9ydGVkTW9kdWxlc1tpZF0gPSAhMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IG1vZHVsZXMubGVuZ3Ro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IT09IChfYSA9IHVuc2FmZVdpbmRvdy53aW5kb3cubmF2aWdhdG9yLnVzZXJBZ2VudCkgJiYgdm9pZCAwICE9PSBfYSA/IF9hIDogIk1vemlsbGEvNC4wIChjb21wYXRpYmxlKSBHcmVhc2Vtb25rZXkiLCAKICAgICAgICAgICAgaGVhZC5BY2NlcHQgPSAiYXBwbGljYXRpb24vYXRvbSt4bWwsYXBwbGljYXRpb24veG1sLHRleHQveG1sIiksIG9wdGlvbi51cmwuaW5kZXhPZigicGFpIikgPiAtMSAmJiAoaGVhZC5BdXRob3IgPSBudWxsICE9PSAoX2IgPSBDb25maWdfMS5Db25maWcuZW52LnNjcmlwdC5hdXRob3IpICYmIHZvaWQgMCAhPT0gX2IgPyBfYiA6ICJkaW5nZGluZyIsIAogICAgICAgICAgICBoZWFkLlZlcnNpb24gPSBDb25maWdfMS5Db25maWcuZW52LnNjcmlwdC52ZXJzaW9uKSwgb3B0aW9uLmhlYWRlcnMgfHwgKG9wdGlvbi5oZWFkZXJzID0gaGVhZCk7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBHTV94bWxodHRwUmVxdWVzdChvcHRpb24pOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICBMb2dnZXJfMS5Mb2dnZXIuZXJyb3IoZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9LCBIdHRwLmdldEZvcm1EYXRhID0gZnVuY3Rpb24oZGF0YSkgewogICAgICAgICAgICBpZiAoZGF0YSBpbnN0YW5jZW9mIE1hcCkgewogICAgICAgICAgICAgICAgdmFyIGZkXzEgPSBuZXcgRm9ybURhdGE7CiAgICAgICAgICAgICAgICBkYXRhLmZvckVhY2goKGZ1bmN0aW9uKHYsIGspIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX3Y7CiAgICAgICAgICAgICAgICAgICAgX3YgPSAic3RyaW5nIiA9PSB0eXBlb2YgdiA/IHYudG9TdHJpbmcoKSA6IEpTT04uc3RyaW5naWZ5KHYpLCBmZF8xLmFwcGVuZChrLCBfdik7CiAgICAgICAgICAgICAgICB9KSksIGRhdGEgPSBmZF8xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBkYXRhOwogICAgICAgIH0sIEh0dHAuX2dldERhdGEgPSBmdW5jdGlvbihkYXRhLCBjb250ZW50VHlwZSkgewogICAgICAgICAgICBpZiAodm9pZCAwID09PSBjb250ZW50VHlwZSAmJiAoY29udGVudFR5cGUgPSAianNvbiIpLCBkYXRhIGluc3RhbmNlb2YgTWFwKSB7CiAgICAgICAgICAgICAgICB2YXIgZmRfMiA9IG5ldyBGb3JtRGF0YTsKICAgICAgICAgICAgICAgIGRhdGEuZm9yRWFjaCgoZnVuY3Rpb24odiwgaykgewogICAgICAgICAgICAgICAgICAgIGZkXzIuYXBwZW5kKGssIHYpOwogICAgICAgICAgICAgICAgfSkpLCBkYXRhID0gZmRfMjsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgcmVzID0gIiI7CiAgICAgICAgICAgIGlmICgianNvbiIgPT0gY29udGVudFR5cGUpIHsKICAgICAgICAgICAgICAgIHZhciBvYmpfMSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICBkYXRhLmZvckVhY2goKGZ1bmN0aW9uKGssIHYpIHsKICAgICAgICAgICAgICAgICAgICBvYmpfMVt2XSA9IGs7CiAgICAgICAgICAgICAgICB9KSksIHJlcyA9IEpTT04uc3RyaW5naWZ5KG9ial8xKTsKICAgICAgICAgICAgfSBlbHNlIGRhdGEuZm9yRWFjaCgoZnVuY3Rpb24oaywgdikgewogICAgICAgICAgICAgICAgcmVzICs9IHYgKyAiPSIgKyBlbmNvZGVVUklDb21wb25lbnQoay50b1N0cmluZygpKSArICImIjsKICAgICAgICAgICAgfSkpLCByZXMgPSBDb21tb25fMS5Db21tb24udHJpbShyZXMsICImIik7CiAgICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgfSwgSHR0cC5nZXREYXRhID0gZnVuY3Rpb24odXJsKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgoZnVuY3Rpb24ocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgJC5nZXRKU09OKHVybCwgKGZ1bmN0aW9uKGQpIHsKICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGQpOwogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9KSk7CiAgICAgICAgfSwgSHR0cC5wb3N0ID0gZnVuY3Rpb24odXJsLCBkYXRhLCBjb250ZW50VHlwZSwgdGltZU91dCwgaGVhZGVycykgewogICAgICAgICAgICB2b2lkIDAgPT09IGNvbnRlbnRUeXBlICYmIChjb250ZW50VHlwZSA9ICJqc29uIiksIHZvaWQgMCA9PT0gdGltZU91dCAmJiAodGltZU91dCA9IDEyMCksIAogICAgICAgICAgICB2b2lkIDAgPT09IGhlYWRlcnMgJiYgKGhlYWRlcnMgPSB2b2lkIDApOwogICAgICAgICAgICB2YXIgX2RhdGEgPSAiIjsKICAgICAgICAgICAgcmV0dXJuIF9kYXRhID0gImpzb24iID09IGNvbnRlbnRUeXBlID8gSlNPTi5zdHJpbmdpZnkoZGF0YSkgOiBIdHRwLmdldEZvcm1EYXRhKGRhdGEpLCAKICAgICAgICAgICAgbmV3IFByb21pc2UoKGZ1bmN0aW9uKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgSHR0cC5hamF4KHsKICAgICAgICAgICAgICAgICAgICB1cmw6IHVybCwKICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICJQT1NUIiwKICAgICAgICAgICAgICAgICAgICBkYXRhOiBfZGF0YSwKICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzLAogICAgICAgICAgICAgICAgICAgIHRpbWVvdXQ6IDFlMyAqIHRpbWVPdXQsCiAgICAgICAgICAgICAgICAgICAgb25sb2FkOiBmdW5jdGlvbihyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2E7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzID0gbnVsbCAhPT0gKF9hID0gSlNPTi5wYXJzZShyZXNwb25zZS5yZXNwb25zZVRleHQpKSAmJiB2b2lkIDAgIT09IF9hID8gX2EgOiByZXNwb25zZS5yZXNwb25zZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHJlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb2dnZXJfMS5Mb2dnZXIuZGVidWcoZXJyb3IpLCByZWplY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgb25lcnJvcjogZnVuY3Rpb24ocmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIG9udGltZW91dDogZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdCgiXHU4YmY3XHU2YzQyXHU4ZDg1XHU2NWY2Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBIdHRwLmdldCA9IGZ1bmN0aW9uKHVybCwgZGF0YSwgdGltZV9vdXQsIGFub255bW91cykgewogICAgICAgICAgICByZXR1cm4gdm9pZCAwID09PSBkYXRhICYmIChkYXRhID0gbmV3IE1hcCksIHZvaWQgMCA9PT0gdGltZV9vdXQgJiYgKHRpbWVfb3V0ID0gMTIwKSwgCiAgICAgICAgICAgIHZvaWQgMCA9PT0gYW5vbnltb3VzICYmIChhbm9ueW1vdXMgPSAhMSksIG5ldyBQcm9taXNlKChmdW5jdGlvbihyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICAgIEh0dHAuYWpheCh7CiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsCiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICB0aW1lb3V0OiAxZTMgKiB0aW1lX291dCwKICAgICAgICAgICAgICAgICAgICBhbm9ueW1vdXM6IGFub255bW91cywKICAgICAgICAgICAgICAgICAgICBvbmxvYWQ6IGZ1bmN0aW9uKHJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfYTsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXMgPSBudWxsICE9PSAoX2EgPSBKU09OLnBhcnNlKHJlc3BvbnNlLnJlc3BvbnNlVGV4dCkpICYmIHZvaWQgMCAhPT0gX2EgPyBfYSA6IHJlc3BvbnNlLnJlc3BvbnNlVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUocmVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIExvZ2dlcl8xLkxvZ2dlci5kZWJ1ZyhlcnJvciksIHJlamVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICBvbmVycm9yOiBmdW5jdGlvbihyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWplY3QocmVzcG9uc2UpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgb250aW1lb3V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KCJcdThiZjdcdTZjNDJcdThkODVcdTY1ZjYiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEh0dHAuZ2V0MzAyID0gZnVuY3Rpb24odXJsKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgoZnVuY3Rpb24ocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgR01feG1saHR0cFJlcXVlc3QoewogICAgICAgICAgICAgICAgICAgIHVybDogdXJsLAogICAgICAgICAgICAgICAgICAgIG9ubG9hZDogZnVuY3Rpb24ocmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShyZXNwb25zZS5maW5hbFVybCk7CiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICBvbmFib3J0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICBvbmVycm9yOiBmdW5jdGlvbihyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBIdHRwOwogICAgfSgpOwogICAgZXhwb3J0cy5IdHRwID0gSHR0cDsKICAgIHZhciBIdHRwSGVhZGVycyA9IGZ1bmN0aW9uIEh0dHBIZWFkZXJzKCkge307CiAgICBleHBvcnRzLkh0dHBIZWFkZXJzID0gSHR0cEhlYWRlcnM7Cn0sIGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewogICAgInVzZSBzdHJpY3QiOwogICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgewogICAgICAgIHZhbHVlOiAhMAogICAgfSksIGV4cG9ydHMuQ29tbW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gICAgICAgICAgZm9yICh2YXIgYXJyID0gZG9jdW1lbnQuY29va2llLnJlcGxhY2UoL1xzL2csICIiKS5zcGxpdCgiOyIpLCBpID0gMCwgbCA9IGFyci5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgICAgIHZhciB0ZW1wQXJyID0gYXJyW2ldLnNwbGl0KCI9Iik7CiAgICAgICAgICAgICAgICBpZiAodGVtcEFyclswXSA9PSBrZXkpIHJldHVybiBkZWNvZGVVUklDb21wb25lbnQodGVtcEFyclsxXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0sIENvbW1vbjsKICAgIH0oKTsKICAgIGV4cG9ydHMuQ29tbW9uID0gQ29tbW9uOwp9LCBmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKICAgICJ1c2Ugc3RyaWN0IjsKICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsIHsKICAgICAgICB2YWx1ZTogITAKICAgIH0pLCBleHBvcnRzLkNvbmZpZyA9IHZvaWQgMDsKICAgIHZhciBMb2dnZXJfMSA9IF9fd2VicGFja19yZXF1aXJlX18oMCksIENvbmZpZyA9IGZ1bmN0aW9uKCkgewogICAgICAgIGZ1bmN0aW9uIENvbmZpZygpIHt9CiAgICAgICAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShDb25maWcsICJlbnYiLCB7CiAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gR01faW5mbzsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgZW51bWVyYWJsZTogITEsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogITAKICAgICAgICB9KSwgQ29uZmlnLnNldCA9IGZ1bmN0aW9uKGtleSwgdiwgZXhwKSB7CiAgICAgICAgICAgIHZvaWQgMCA9PT0gZXhwICYmIChleHAgPSAtMSk7CiAgICAgICAgICAgIHZhciBvYmogPSB7CiAgICAgICAgICAgICAgICBrZXk6IGtleSwKICAgICAgICAgICAgICAgIHZhbHVlOiB2LAogICAgICAgICAgICAgICAgZXhwOiAtMSA9PSBleHAgPyBleHAgOiAobmV3IERhdGUpLmdldFRpbWUoKSArIDFlMyAqIGV4cAogICAgICAgICAgICB9OwogICAgICAgICAgICBHTV9zZXRWYWx1ZSgicGFudG9vbHNfIiArIHRoaXMuZW5jb2RlKGtleSksIEpTT04uc3RyaW5naWZ5KG9iaikpOwogICAgICAgIH0sIENvbmZpZy5nZXQgPSBmdW5jdGlvbihrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICB2b2lkIDAgPT09IGRlZmF1bHRWYWx1ZSAmJiAoZGVmYXVsdFZhbHVlID0gITEpOwogICAgICAgICAgICB2YXIgb2JqU3RyID0gR01fZ2V0VmFsdWUoInBhbnRvb2xzXyIgKyB0aGlzLmVuY29kZShrZXkpKTsKICAgICAgICAgICAgaWYgKG9ialN0cikgewogICAgICAgICAgICAgICAgdmFyIG9iaiA9IEpTT04ucGFyc2Uob2JqU3RyKTsKICAgICAgICAgICAgICAgIGlmICgtMSA9PSBvYmouZXhwIHx8IG9iai5leHAgPiAobmV3IERhdGUpLmdldFRpbWUoKSkgcmV0dXJuIExvZ2dlcl8xLkxvZ2dlci5pbmZvKGtleSArICIgY2FjaGUgdHJ1ZSIpLCAKICAgICAgICAgICAgICAgIG9iai52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gTG9nZ2VyXzEuTG9nZ2VyLmluZm8oa2V5ICsgIiBjYWNoZSBmYWxzZSIpLCBkZWZhdWx0VmFsdWU7CiAgICAgICAgfSwgQ29uZmlnLmdldExvY2FsU3RvcmFnZSA9IGZ1bmN0aW9uKGtleSwgZGVmYXVsdFZhbHVlKSB7CiAgICAgICAgICAgIHZvaWQgMCA9PT0gZGVmYXVsdFZhbHVlICYmIChkZWZhdWx0VmFsdWUgPSAhMSk7CiAgICAgICAgICAgIHZhciBvYmpTdHIgPSBsb2NhbFN0b3JhZ2UuZ2V0SXRlbSgiIiArIHRoaXMuZW5jb2RlKGtleSkpOwogICAgICAgICAgICBpZiAob2JqU3RyKSB7CiAgICAgICAgICAgICAgICB2YXIgb2JqID0gSlNPTi5wYXJzZShvYmpTdHIpOwogICAgICAgICAgICAgICAgaWYgKC0xID09IG9iai5leHAgfHwgb2JqLmV4cCA+IChuZXcgRGF0ZSkuZ2V0VGltZSgpKSByZXR1cm4gTG9nZ2VyXzEuTG9nZ2VyLmluZm8oa2V5ICsgIiBzdG9yYWdlIGNhY2hlIHRydWUiKSwgCiAgICAgICAgICAgICAgICBvYmoudmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIExvZ2dlcl8xLkxvZ2dlci5pbmZvKGtleSArICIgc3RvcmFnZSBjYWNoZSBmYWxzZSIpLCBkZWZhdWx0VmFsdWU7CiAgICAgICAgfSwgQ29uZmlnLnNldExvY2FsU3RvcmFnZSA9IGZ1bmN0aW9uKGtleSwgdiwgZXhwKSB7CiAgICAgICAgICAgIHZvaWQgMCA9PT0gZXhwICYmIChleHAgPSAtMSk7CiAgICAgICAgICAgIHZhciBvYmogPSB7CiAgICAgICAgICAgICAgICBrZXk6IGtleSwKICAgICAgICAgICAgICAgIHZhbHVlOiB2LAogICAgICAgICAgICAgICAgZXhwOiAtMSA9PSBleHAgPyBleHAgOiAobmV3IERhdGUpLmdldFRpbWUoKSArIDFlMyAqIGV4cAogICAgICAgICAgICB9OwogICAgICAgICAgICBsb2NhbFN0b3JhZ2Uuc2V0SXRlbSgiIiArIHRoaXMuZW5jb2RlKGtleSksIEpTT04uc3RyaW5naWZ5KG9iaikpOwogICAgICAgIH0sIENvbmZpZy5kZWNvZGUgPSBmdW5jdGlvbihzdHIpIHsKICAgICAgICAgICAgcmV0dXJuIGF0b2Ioc3RyKTsKICAgICAgICB9LCBDb25ma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Bjb25maXJtVHh0LCBjYW5jZWxUeHQpIHsKICAgICAgICAgICAgcmV0dXJuIHZvaWQgMCA9PT0gY29uZmlybVR4dCAmJiAoY29uZmlybVR4dCA9ICJcdTc4NmVcdTViOWEiKSwgdm9pZCAwID09PSBjYW5jZWxUeHQgJiYgKGNhbmNlbFR4dCA9ICJcdTUzZDZcdTZkODgiKSwgCiAgICAgICAgICAgIHN3ZWV0YWxlcnQyXzEuZGVmYXVsdC5maXJlKHsKICAgICAgICAgICAgICAgIGh0bWw6IG1zZywKICAgICAgICAgICAgICAgIGNvbmZpcm1CdXR0b25UZXh0OiBjb25maXJtVHh0LAogICAgICAgICAgICAgICAgc2hvd0NvbmZpcm1CdXR0b246ICEwLAogICAgICAgICAgICAgICAgc2hvd0NhbmNlbEJ1dHRvbjogITAsCiAgICAgICAgICAgICAgICBjYW5jZWxCdXR0b25UZXh0OiBjYW5jZWxUeHQsCiAgICAgICAgICAgICAgICBpY29uOiAicXVlc3Rpb24iLAogICAgICAgICAgICAgICAgYWxsb3dPdXRzaWRlQ2xpY2s6ICExLAogICAgICAgICAgICAgICAgY3VzdG9tQ2xhc3M6IHRoaXMuY3VzdG9tZUNzcwogICAgICAgICAgICB9KTsKICAgICAgICB9LCBBbGVydC5pbmZvID0gZnVuY3Rpb24obXNnLCB0aW1lLCBpY29uKSB7CiAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgICAgIHZvaWQgMCA9PT0gdGltZSAmJiAodGltZSA9IDIpLCB2b2lkIDAgPT09IGljb24gJiYgKGljb24gPSAic3VjY2VzcyIpLCBudWxsICE9IHRoaXMudGlwQ29udGFpbmVyICYmIHN3ZWV0YWxlcnQyXzEuZGVmYXVsdC5jbG9zZSh0aGlzLnRpcENvbnRhaW5lciksIAogICAgICAgICAgICBzd2VldGFsZXJ0Ml8xLmRlZmF1bHQuZmlyZSh7CiAgICAgICAgICAgICAgICB0b2FzdDogITAsCiAgICAgICAgICAgICAgICBwb3NpdGlvbjogInRvcCIsCiAgICAgICAgICAgICAgICBzaG93Q2FuY2VsQnV0dG9uOiAhMSwKICAgICAgICAgICAgICAgIHNob3dDb25maXJtQnV0dG9uOiAhMSwKICAgICAgICAgICAgICAgIHRpbWVyUHJvZ3Jlc3NCYXI6ICEwLAogICAgICAgICAgICAgICAgdGl0bGU6IG1zZywKICAgICAgICAgICAgICAgIGljb246IGljb24sCiAgICAgICAgICAgICAgICB0aW1lcjogMWUzICogdGltZSwKICAgICAgICAgICAgICAgIGN1c3RvbUNsYXNzOiB0aGlzLmN1c3RvbWVDc3MKICAgICAgICAgICAgfSkudGhlbigoZnVuY3Rpb24oYSkgewogICAgICAgICAgICAgICAgX3RoaXMudGlwQ29udGFpbmVyID0gYTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIEFsZXJ0LmlucHV0ID0gZnVuY3Rpb24obXNnLCBkZWZWYWx1ZSwgdmFsaWRhdG9yKSB7CiAgICAgICAgICAgIHJldHVybiB2b2lkIDAgPT09IGRlZlZhbHVlICYmIChkZWZWYWx1ZSA9ICIiKSwgdm9pZCAwID09PSB2YWxpZGF0b3IgJiYgKHZhbGlkYXRvciA9IGZ1bmN0aW9uKHJlcykgewogICAgICAgICAgICAgICAgcmV0dXJuICIiID09IHJlcyB8fCBudWxsID09IHJlcyA/IG1zZyA6IG51bGw7CiAgICAgICAgICAgIH0pLCBzd2VldGFsZXJ0Ml8xLmRlZmF1bHQuZmlyZSh7CiAgICAgICAgICAgICAgICBpbnB1dDogInRleHQiLAogICAgICAgICAgICAgICAgaW5wdXRMYWJlbDogbXNnLAogICAgICAgICAgICAgICAgaW5wdXRWYWx1ZTogZGVmVmFsdWUsCiAgICAgICAgICAgICAgICBzaG93Q2FuY2VsQnV0dG9uOiAhMCwKICAgICAgICAgICAgICAgIGNhbmNlbEJ1dHRvblRleHQ6ICJcdTdiOTdcdTRlODYiLAogICAgICAgICAgICAgICAgY29uZmlybUJ1dHRvblRleHQ6ICJcdTZkZmJcdTUyYTAiLAogICAgICAgICAgICAgICAgaW5wdXRWYWxpZGF0b3I6IGZ1bmN0aW9uKHIpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsaWRhdG9yKHIpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGN1c3RvbUNsYXNzOiB0aGlzLmN1c3RvbWVDc3MKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgQWxlcnQuaHRtbCA9IGZ1bmN0aW9uKHRpdGxlLCBodG1sLCB3aWR0aCwgdGltZSkgewogICAgICAgICAgICByZXR1cm4gdm9pZCAwID09PSB3aWR0aCAmJiAod2lkdGggPSB2b2lkIDApLCB2b2lkIDAgPT09IHRpbWUgJiYgKHRpbWUgPSB2b2lkIDApLCAKICAgICAgICAgICAgc3dlZXRhbGVydDJfMS5kZWZhdWx0LmZpcmUoewogICAgICAgICAgICAgICAgdG9hc3Q6ICExLAogICAgICAgICAgICAgICAgYWxsb3dPdXRzaWRlQ2xpY2s6ICExLAogICAgICAgICAgICAgICAgY29uZmlybUJ1dHRvblRleHQ6ICJcdTUxNzNcdTk1ZWQiLAogICAgICAgICAgICAgICAgd2lkdGg6IHdpZHRoLAogICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLAogICAgICAgICAgICAgICAgaHRtbDogaHRtbCwKICAgICAgICAgICAgICAgIHRpbWVyOiBudWxsID09IHRpbWUgPyB0aW1lIDogMWUzICogdGltZSwKICAgICAgICAgICAgICAgIGN1c3RvbUNsYXNzOiB0aGlzLmN1c3RvbWVDc3MKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgQWxlcnQudG9hc3QgPSBmdW5jdGlvbih0aXRsZSwgaHRtbCwgY2FuY2VsLCBjYW5jZWxUeHQsIGNvbmZpcm0sIGNvbmZpcm1UeHQpIHsKICAgICAgICAgICAgcmV0dXJuIHZvaWQgMCA9PT0gY2FuY2VsICYmIChjYW5jZWwgPSAhMSksIHZvaWQgMCA9PT0gY2FuY2VsVHh0ICYmIChjYW5jZWxUeHQgPSAiIiksIAogICAgICAgICAgICB2b2lkIDAgPT09IGNvbmZpcm0gJiYgKGNvbmZpcm0gPSAhMSksIHZvaWQgMCA9PT0gY29uZmlybVR4dCAmJiAoY29uZmlybVR4dCA9ICIiKSwgCiAgICAgICAgICAgIHN3ZWV0YWxlcnQyXzEuZGVmYXVsdC5maXJlKHsKICAgICAgICAgICAgICAgIHRvYXN0OiAhMCwKICAgICAgICAgICAgICAgIHBvc2l0aW9uOiAidG9wIiwKICAgICAgICAgICAgICAgIGh0bWw6IGh0bWwsCiAgICAgICAgICAgICAgICBzaG93Q2FuY2VsQnV0dG9uOiBjYW5jZWwsCiAgICAgICAgICAgICAgICBzaG93Q29uZmlybUJ1dHRvbjogY29uZmlybSwKICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSwKICAgICAgICAgICAgICAgIGNhbmNlbEJ1dHRvblRleHQ6IGNhbmNlbFR4dCwKICAgICAgICAgICAgICAgIGNvbmZpcm1CdXR0b25UZXh0OiBjb25maXJtVHh0LAogICAgICAgICAgICAgICAgY3VzdG9tQ2xhc3M6IHRoaXMuY3VzdG9tZUNzcwogICAgICAgICAgICB9KTsKICAgICAgICB9LCBBbGVydC5sb2FkaW5nID0gZnVuY3Rpb24obXNnLCB0aW1lKSB7CiAgICAgICAgICAgIHJldHVybiB2b2lkIDAgPT09IG1zZyAmJiAobXNnID0gIiIpLCB2b2lkIDAgPT09IHRpbWUgJiYgKHRpbWUgPSB2b2lkIDApLCBzd2VldGFsZXJ0Ml8xLmRlZmF1bHQuZmlyZSh7CiAgICAgICAgICAgICAgICB0aXRsZTogbXNnLAogICAgICAgICAgICAgICAgdGltZXI6IG51bGwgPT0gdGltZSA/IHRpbWUgOiAxZTMgKiB0aW1lLAogICAgICAgICAgICAgICAgdGltZXJQcm9ncmVzc0JhcjogITAsCiAgICAgICAgICAgICAgICBhbGxvd091dHNpZGVDbGljazogITEsCiAgICAgICAgICAgICAgICBkaWRPcGVuOiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml8xLmRlZmF1bHQuc2hvd0xvYWRpbmcoKTsKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBjdXN0b21DbGFzczogdGhpcy5jdXN0b21lQ3NzCiAgICAgICAgICAgIH0pOwogICAgICAgIH0sIEFsZXJ0LmNsb3NlID0gZnVuY3Rpb24oc3dhbCkgewogICAgICAgICAgICBzd2VldGFsZXJ0Ml8xLmRlZmF1bHQuY2xvc2Uoc3dhbCk7CiAgICAgICAgfSwgQWxlcnQuY3VzdG9tZUNzcyA9IHsKICAgICAgICAgICAgY29udGFpbmVyOiAicGFudG9vbHMtY29udGFpbmVyIiwKICAgICAgICAgICAgcG9wdXA6ICJwYW50b29scy1wb3B1cCIsCiAgICAgICAgICAgIHRpdGxlOiAicGFudG9vbHMtdGl0bGUiLAogICAgICAgICAgICBjbG9zZUJ1dHRvbjogInBhbnRvb2xzLWNsb3NlIiwKICAgICAgICAgICAgaWNvbjogInBhbnRvb2xzLWljb24iLAogICAgICAgICAgICBpbWFnZTogInBhbnRvb2xzLWltYWdlIiwKICAgICAgICAgICAgaHRtbENvbnRhaW5lcjogInBhbnRvb2xzLWh0bWwiLAogICAgICAgICAgICBpbnB1dDogInBhbnRvb2xzLWlucHV0IiwKICAgICAgICAgICAgdmFsaWRhdGlvbk1lc3NhZ2U6ICJwYW50b29scy12YWxpZGF0aW9uIiwKICAgICAgICAgICAgYWN0aW9uczogInBhbnRvb2xzLWFjdGlvbnMiLAogICAgICAgICAgICBjb25maXJtQnV0dG9uOiAicGFudG9vbHMtY29uZmlybSIsCiAgICAgICAgICAgIGRlbnlCdXR0b246ICJwYW50b29scy1kZW55IiwKICAgICAgICAgICAgY2FuY2VsQnV0dG9uOiAicGFudG9vbHMtY2FuY2VsIiwKICAgICAgICAgICAgbG9hZGVyOiAicGFudG9vbHMtbG9hZGVyIiwKICAgICAgICAgICAgZm9vdGVyOiAicGFudG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9wZXJ0eS5jYWxsKHNvdXJjZSwga2V5KSAmJiAodGFyZ2V0W2tleV0gPSBzb3VyY2Vba2V5XSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICB9LCBfZXh0ZW5kcy5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBfaW5oZXJpdHMoc3ViQ2xhc3MsIHN1cGVyQ2xhc3MpIHsKICAgICAgICAgICAgaWYgKCJmdW5jdGlvbiIgIT0gdHlwZW9mIHN1cGVyQ2xhc3MgJiYgbnVsbCAhPT0gc3VwZXJDbGFzcykgdGhyb3cgbmV3IFR5cGVFcnJvcigiU3VwZXIgZXhwcmVzc2lvbiBtdXN0IGVpdGhlciBiZSBudWxsIG9yIGEgZnVuY3Rpb24iKTsKICAgICAgICAgICAgc3ViQ2xhc3MucHJvdG90eXBlID0gT2JqZWN0LmNyZWF0ZShzdXBlckNsYXNzICYmIHN1cGVyQ2xhc3MucHJvdG90eXBlLCB7CiAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiBzdWJDbGFzcywKICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogITAsCiAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiAhMAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSwgc3VwZXJDbGFzcyAmJiBfc2V0UHJvdG90eXBlT2Yoc3ViQ2xhc3MsIHN1cGVyQ2xhc3MpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBfZ2V0UHJvdG90eXBlT2YobykgewogICAgICAgICAgICByZXR1cm4gX2dldFByb3RvdHlwZU9mID0gT2JqZWN0LnNldFByb3RvdHlwZU9mID8gT2JqZWN0LmdldFByb3RvdHlwZU9mIDogZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mKG8pIHsKICAgICAgICAgICAgICAgIHJldHVybiBvLl9fcHJvdG9fXyB8fCBPYmplY3QuZ2V0UHJvdG90eXBlT2Yobyk7CiAgICAgICAgICAgIH0sIF9nZXRQcm90b3R5cGVPZihvKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gX3NldFByb3RvdHlwZU9mKG8sIHApIHsKICAgICAgICAgICAgcmV0dXJuIF9zZXRQcm90b3R5cGVPZiA9IE9iamVjdC5zZXRQcm90b3R5cGVPZiB8fCBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YobywgcCkgewogICAgICAgICAgICAgICAgcmV0dXJuIG8uX19wcm90b19fID0gcCwgbzsKICAgICAgICAgICAgfSwgX3NldFByb3RvdHlwZU9mKG8sIHApOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBfaXNOYXRpdmVSZWZsZWN0Q29uc3RydWN0KCkgewogICAgICAgICAgICBpZiAoInVuZGVmaW5lZCIgPT0gdHlwZW9mIFJlZmxlY3QgfHwgIVJlZmxlY3QuY29uc3RydWN0KSByZXR1cm4gITE7CiAgICAgICAgICAgIGlmIChSZWZsZWN0LmNvbnN0cnVjdC5zaGFtKSByZXR1cm4gITE7CiAgICAgICAgICAgIGlmICgiZnVuY3Rpb24iID09IHR5cGVvZiBQcm94eSkgcmV0dXJuICEwOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmV0dXJuIEJvb2xlYW4ucHJvdG90eXBlLnZhbHVlT2YuY2FsbChSZWZsZWN0LmNvbnN0cnVjdChCb29sZWFuLCBbXSwgKGZ1bmN0aW9uKCkge30pKSksIAogICAgICAgICAgICAgICAgITA7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIHJldHVybiAhMTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBfY29uc3RydWN0KFBhcmVudCwgYXJncywgQ2xhc3MpIHsKICAgICAgICAgICAgcmV0dXJuIF9jb25zdHJ1Y3QgPSBfaXNOYX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dENvbnN0cnVjdCA9IF9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QoKTsKICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIF9jcmVhdGVTdXBlckludGVybmFsKCkgewogICAgICAgICAgICAgICAgdmFyIHJlc3VsdCwgU3VwZXIgPSBfZ2V0UHJvdG90eXBlT2YoRGVyaXZlZCk7CiAgICAgICAgICAgICAgICBpZiAoaGFzTmF0aXZlUmVmbGVjdENvbnN0cnVjdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQgPSBfZ2V0UHJvdG90eXBlT2YodGhpcykuY29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gUmVmbGVjdC5jb25zdHJ1Y3QoU3VwZXIsIGFyZ3VtZW50cywgTmV3VGFyZ2V0KTsKICAgICAgICAgICAgICAgIH0gZWxzZSByZXN1bHQgPSBTdXBlci5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgcmV0dXJuIF9wb3NzaWJsZUNvbnN0cnVjdG9yUmV0dXJuKHRoaXMsIHJlc3VsdCk7CiAgICAgICAgICAgIH07CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIF9zdXBlclByb3BCYXNlKG9iamVjdCwgcHJvcGVydHkpIHsKICAgICAgICAgICAgZm9yICg7IU9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmplY3QsIHByb3BlcnR5KSAmJiBudWxsICE9PSAob2JqZWN0ID0gX2dldFByb3RvdHlwZU9mKG9iamVjdCkpOyApIDsKICAgICAgICAgICAgcmV0dXJuIG9iamVjdDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gX2dldCh0YXJnZXQsIHByb3BlcnR5LCByZWNlaXZlcikgewogICAgICAgICAgICByZXR1cm4gX2dldCA9ICJ1bmRlZmluZWQiICE9IHR5cGVvZiBSZWZsZWN0ICYmIFJlZmxlY3QuZ2V0ID8gUmVmbGVjdC5nZXQgOiBmdW5jdGlvbiBfZ2V0KHRhcmdldCwgcHJvcGVydHksIHJlY2VpdmVyKSB7CiAgICAgICAgICAgICAgICB2YXIgYmFzZSA9IF9zdXBlclByb3BCYXNlKHRhcmdldCwgcHJvcGVydHkpOwogICAgICAgICAgICAgICAgaWYgKGJhc2UpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGVzYyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoYmFzZSwgcHJvcGVydHkpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBkZXNjLmdldCA/IGRlc2MuZ2V0LmNhbGwocmVjZWl2ZXIpIDogZGVzYy52YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSwgX2dldCh0YXJnZXQsIHByb3BlcnR5LCByZWNlaXZlciB8fCB0YXJnZXQpOwogICAgICAgIH0KICAgICAgICB2YXIgdW5pcXVlQXJyYXkgPSBmdW5jdGlvbiB1bmlxdWVBcnJheShhcnIpIHsKICAgICAgICAgICAgZm9yICh2YXIgcmVzdWx0ID0gW10sIGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSAtMSA9PT0gcmVzdWx0LmluZGV4T2YoYXJyW2ldKSAmJiByZXN1bHQucHVzaChhcnJbaV0pOwogICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sIGNhcGl0YWxpemVGaXJzdExldHRlciA9IGZ1bmN0aW9uIGNhcGl0YWxpemVGaXJzdExldHRlcihzdHIpIHsKICAgICAgICAgICAgcmV0dXJuIHN0ci5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIHN0ci5zbGljZSgxKTsKICAgICAgICB9LCBvYmplY3RWYWx1ZXMgPSBmdW5jdGlvbiBvYmplY3RWYWx1ZXMob2JqKSB7CiAgICAgICAgICAgIHJldHVybiBPYmplY3Qua2V5cyhvYmopLm1hcCgoZnVuY3Rpb24oa2V5KSB7CiAgICAgICAgICAgICAg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gdmFyIHBhcmFtcyA9IHt9OwogICAgICAgICAgICByZXR1cm4gIm9iamVjdCIgIT09IF90eXBlb2YoYXJnc1swXSkgfHwgaXNFbGVtZW50KGFyZ3NbMF0pID8gWyAidGl0bGUiLCAiaHRtbCIsICJpY29uIiBdLmZvckVhY2goKGZ1bmN0aW9uKG5hbWUsIGluZGV4KSB7CiAgICAgICAgICAgICAgICB2YXIgYXJnID0gYXJnc1tpbmRleF07CiAgICAgICAgICAgICAgICAic3RyaW5nIiA9PSB0eXBlb2YgYXJnIHx8IGlzRWxlbWVudChhcmcpID8gcGFyYW1zW25hbWVdID0gYXJnIDogdm9pZCAwICE9PSBhcmcgJiYgZXJyb3IoIlVuZXhwZWN0ZWQgdHlwZSBvZiAiLmNvbmNhdChuYW1lLCAnISBFeHBlY3RlZCAic3RyaW5nIiBvciAiRWxlbWVudCIsIGdvdCAnKS5jb25jYXQoX3R5cGVvZihhcmcpKSk7CiAgICAgICAgICAgIH0pKSA6IF9leHRlbmRzKHBhcmFtcywgYXJnc1swXSksIHBhcmFtczsKICAgICAgICB9LCBzd2FsUHJlZml4ID0gInN3YWwyLSIsIHByZWZpeCA9IGZ1bmN0aW9uIHByZWZpeChpdGVtcykgewogICAgICAgICAgICB2YXIgcmVzdWx0ID0ge307CiAgICAgICAgICAgIGZvciAodmFyIGkgaW4gaXRlbXMpIHJlc3VsdFtpdGVtc1tpXV0gPSBzd2FsUHJlZml4ICsgaXRlbXNbaV07CiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgfSwgc3dhbENsYXNzZXMgPSBwcmVmaXgoWyAiY29udGFpbmVyIiwgInNob3duIiwgImhlaWdodC1hdXRvIiwgImlvc2ZpeCIsICJwb3B1cCIsICJtb2RhbCIsICJuby1iYWNrZHJvcCIsICJuby10cmFuc2l0aW9uIiwgInRvYXN0IiwgInRvYXN0LXNob3duIiwgInNob3ciLCAiaGlkZSIsICJjbG9zZSIsICJ0aXRsZSIsICJoZWFkZXIiLCA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zID0gdG9BcnJheShnZXRQb3B1cCgpLnF1ZXJ5U2VsZWN0b3JBbGwoZm9jdXNhYmxlKSkuZmlsdGVyKChmdW5jdGlvbihlbCkgewogICAgICAgICAgICAgICAgcmV0dXJuICItMSIgIT09IGVsLmdldEF0dHJpYnV0ZSgidGFiaW5kZXgiKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm4gdW5pcXVlQXJyYXkoZm9jdXNhYmxlRWxlbWVudHNXaXRoVGFiaW5kZXguY29uY2F0KG90aGVyRm9jdXNhYmxlRWxlbWVudHMpKS5maWx0ZXIoKGZ1bmN0aW9uKGVsKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gaXNWaXNpYmxlKGVsKTsKICAgICAgICAgICAgfSkpOwogICAgICAgIH0sIGlzTW9kYWwgPSBmdW5jdGlvbiBpc01vZGFsKCkgewogICAgICAgICAgICByZXR1cm4gIWlzVG9hc3QoKSAmJiAhZG9jdW1lbnQuYm9keS5jbGFzc0xpc3QuY29udGFpbnMoc3dhbENsYXNzZXNbIm5vLWJhY2tkcm9wIl0pOwogICAgICAgIH0sIGlzVG9hc3QgPSBmdW5jdGlvbiBpc1RvYXN0KCkgewogICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuYm9keS5jbGFzc0xpc3QuY29udGFpbnMoc3dhbENsYXNzZXNbInRvYXN0LXNob3duIl0pOwogICAgICAgIH0sIGlzTG9hZGluZyA9IGZ1bmN0aW9uIGlzTG9hZGluZygpIHsKICAgICAgICAgICAgcmV0dXJuIGdldFBvcHVwKCkuaGFzQXR0cmlidXRlKCJkYXRhLWxvYWRpbmciKTsKICAgICAgICB9LCBzdGF0ZXMgPSB7CiAgICAgICAgICAgIHByZXZpb3VzQm9keVBhZGRpbmc6IG51bGwKICAgICAgICB9LCBzZXRJbm5lckh0bWwgPSBmdW5jdGlvbiBzZXRJbm5lckh0bWwoZWxlbSwgaHRtbCkgewogICAgICAgICAgICBpZiAoZWxlbS50ZXh0Q29udGVudC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ICAgICAgICAgIGlmICghaW5wdXRUeXBlKSByZXR1cm4gbnVsbDsKICAgICAgICAgICAgc3dpdGNoIChpbnB1dFR5cGUpIHsKICAgICAgICAgICAgICBjYXNlICJzZWxlY3QiOgogICAgICAgICAgICAgIGNhc2UgInRleHRhcmVhIjoKICAgICAgICAgICAgICBjYXNlICJmaWxlIjoKICAgICAgICAgICAgICAgIHJldHVybiBnZXRDaGlsZEJ5Q2xhc3MoY29udGVudCwgc3dhbENsYXNzZXNbaW5wdXRUeXBlXSk7CgogICAgICAgICAgICAgIGNhc2UgImNoZWNrYm94IjoKICAgICAgICAgICAgICAgIHJldHVybiBjb250ZW50LnF1ZXJ5U2VsZWN0b3IoIi4iLmNvbmNhdChzd2FsQ2xhc3Nlcy5jaGVja2JveCwgIiBpbnB1dCIpKTsKCiAgICAgICAgICAgICAgY2FzZSAicmFkaW8iOgogICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRlbnQucXVlcnlTZWxlY3RvcigiLiIuY29uY2F0KHN3YWxDbGFzc2VzLnJhZGlvLCAiIGlucHV0OmNoZWNrZWQiKSkgfHwgY29udGVudC5xdWVyeVNlbGVjdG9yKCIuIi5jb25jYXQoc3dhbENsYXNzZXMucmFkaW8sICIgaW5wdXQ6Zmlyc3QtY2hpbGQiKSk7CgogICAgICAgICAgICAgIGNhc2UgInJhbmdlIjoKICAgICAgICAgICAgICAgIHJldHVybiBjb250ZW50LnF1ZXJ5U2VsZWN0b3IoIi4iLmNvbmNhdChzd2FsQ2xhc3Nlcy5yYW5nZSwgIiBpbnB1dCIpKTsKCiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHJldHVybiBnZXRDaGlsZEJ5Q2xhc3MoY29udGVudCwgc3dhbENsYXNzZXMuaW5wdXQpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZhciBvbGRJbnB1dFZhbCwgZm9jdXNJbnB1dCA9IGZ1bmN0aW9uIGZvY3VzSW5wdXQoaW5wd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Ftcy5pbnB1dFBsYWNlaG9sZGVyKSB7CiAgICAgICAgICAgICAgICB2YXIgcGxhY2Vob2xkZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgIHNldElubmVySHRtbChwbGFjZWhvbGRlciwgcGFyYW1zLmlucHV0UGxhY2Vob2xkZXIpLCBwbGFjZWhvbGRlci52YWx1ZSA9ICIiLCBwbGFjZWhvbGRlci5kaXNhYmxlZCA9ICEwLCAKICAgICAgICAgICAgICAgIHBsYWNlaG9sZGVyLnNlbGVjdGVkID0gITAsIHNlbGVjdC5hcHBlbmRDaGlsZChwbGFjZWhvbGRlcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHNldElucHV0TGFiZWwoc2VsZWN0LCBzZWxlY3QsIHBhcmFtcyksIHNlbGVjdDsKICAgICAgICB9LCByZW5kZXJJbnB1dFR5cGUucmFkaW8gPSBmdW5jdGlvbihyYWRpbykgewogICAgICAgICAgICByZXR1cm4gcmFkaW8udGV4dENvbnRlbnQgPSAiIiwgcmFkaW87CiAgICAgICAgfSwgcmVuZGVySW5wdXRUeXBlLmNoZWNrYm94ID0gZnVuY3Rpb24oY2hlY2tib3hDb250YWluZXIsIHBhcmFtcykgewogICAgICAgICAgICB2YXIgY2hlY2tib3ggPSBnZXRJbnB1dChnZXRDb250ZW50KCksICJjaGVja2JveCIpOwogICAgICAgICAgICBjaGVja2JveC52YWx1ZSA9IDEsIGNoZWNrYm94LmlkID0gc3dhbENsYXNzZXMuY2hlY2tib3gsIGNoZWNrYm94LmNoZWNrZWQgPSBCb29sZWFuKHBhcmFtcy5pbnB1dFZhbHVlKTsKICAgICAgICAgICAgdmFyIGxhYmVsID0gY2hlY2tib3hDb250YWluZXIucXVlcnlTZWxlY3Rvcigic3BhbiIpOwogICAgICAgICAgICByZXR1cm4gc2V0SW5uZXJIdG1sKGxhYmVsLCBwYXJhbXMuaW5wdXRQbGFjZWhvbGRlciks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bnRXaWR0aCwgInB4IikgOiBudWxsOwogICAgICAgICAgICAgICAgfSkpLm9ic2VydmUodGV4dGFyZWEsIHsKICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzOiAhMCwKICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVGaWx0ZXI6IFsgInN0eWxlIiBdCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gdGV4dGFyZWE7CiAgICAgICAgfTsKICAgICAgICB2YXIgcmVuZGVyQ29udGVudCA9IGZ1bmN0aW9uIHJlbmRlckNvbnRlbnQoaW5zdGFuY2UsIHBhcmFtcykgewogICAgICAgICAgICB2YXIgaHRtbENvbnRhaW5lciA9IGdldEh0bWxDb250YWluZXIoKTsKICAgICAgICAgICAgYXBwbHlDdXN0b21DbGFzcyhodG1sQ29udGFpbmVyLCBwYXJhbXMsICJodG1sQ29udGFpbmVyIiksIHBhcmFtcy5odG1sID8gKHBhcnNlSHRtbFRvQ29udGFpbmVyKHBhcmFtcy5odG1sLCBodG1sQ29udGFpbmVyKSwgCiAgICAgICAgICAgIHNob3coaHRtbENvbnRhaW5lciwgImJsb2NrIikpIDogcGFyYW1zLnRleHQgPyAoaHRtbENvbnRhaW5lci50ZXh0Q29udGVudCA9IHBhcmFtcy50ZXh0LCAKICAgICAgICAgICAgc2hvdyhodG1sQ29udGFpbmVyLCAiYmxvY2siKSkgOiBoaWRlKGh0bWxDb250YWluZXIpLCByZW5kZXJJbnB1dChpbnN0YW5jZSwgcGFyYW1zKSwgCiAgICAgICAgICAgIGFwcGx5Q3VzdG9tQ2xhc3MoZ2V0Q29udGVudCgpLCBwYXJhbXMsICJjb250ZW50Iik7CiAgICAgICAgfSwgcmVuZGVyRm9vdGVyID0gZnVuY3Rpb24gcmVuZGVyRm9vdGVyKGluc3RhbmNlLCBwYXJhbXMpIHsKICAgICAgICAgICAgdmFyIGZvb3RlciA9IGdldEZvb3RlcigpOwogICAgICAgICAgICB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uIHx8IHBhcmFtcy5pY29uSHRtbCA/IHBhcmFtcy5pY29uICYmIC0xID09PSBPYmplY3Qua2V5cyhpY29uVHlwZXMpLmluZGV4T2YocGFyYW1zLmljb24pID8gKGVycm9yKCdVbmtub3duIGljb24hIEV4cGVjdGVkICJzdWNjZXNzIiwgImVycm9yIiwgIndhcm5pbmciLCAiaW5mbyIgb3IgInF1ZXN0aW9uIiwgZ290ICInLmNvbmNhdChwYXJhbXMuaWNvbiwgJyInKSksIAogICAgICAgICAgICBoaWRlKGljb24pKSA6IChzaG93KGljb24pLCBzZXRDb250ZW50KGljb24sIHBhcmFtcyksIGFwcGx5U3R5bGVzKGljb24sIHBhcmFtcyksIAogICAgICAgICAgICB2b2lkIGFkZENsYXNzKGljb24sIHBhcmFtcy5zaG93Q2xhc3MuaWNvbikpIDogaGlkZShpY29uKTsKICAgICAgICB9LCBhcHBseVN0eWxlcyA9IGZ1bmN0aW9uIGFwcGx5U3R5bGVzKGljb24sIHBhcmFtcykgewogICAgICAgICAgICBmb3IgKHZhciBpY29uVHlwZSBpbiBpY29uVHlwZXMpIHBhcmFtcy5pY29uICE9PSBpY29uVHlwZSAmJiByZW1vdmVDbGFzcyhpY29uLCBpY29uVHlwZXNbaWNvblR5cGVdKTsKICAgICAgICAgICAgYWRkQ2xhc3MoaWNvbiwgaWNvblR5cGVzW3BhcmFtcy5pY29uXSksIHNldENvbG9yKGljb24sIHBhcmFtcyksIGFkanVzdFN1Y2Nlc3NJY29uQmFja2dvdW5kQ29sb3IoKSwgCiAgICAgICAgICAgIGFwcGx5Q3VzdG9tQ2xhc3MoaWNvbiwgcGFyYW1zLCAiaWNvbiIpOwogICAgICAgIH0sIGFkanVzdFN1Y2Nlc3NJY29uQmFja2dvdW5kQ29sb3IgPSBmdW5jdGlvbiBhZGp1c3RTdWNjZXNzSWNvbkJhY2tnb3VuZENvbG9yKCkgewogICAgICAgICAgICBmb3IgKHZhciBwb3B1cCA9IGdldFBvcHVwKCksIHBvcHVwQm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2Rpdj5cbiAgICAnKSA6ICJlcnJvciIgPT09IHBhcmFtcy5pY29uID8gc2V0SW5uZXJIdG1sKGljb24sICdcbiAgICAgIDxzcGFuIGNsYXNzPSJzd2FsMi14LW1hcmsiPlxuICAgICAgICA8c3BhbiBjbGFzcz0ic3dhbDIteC1tYXJrLWxpbmUtbGVmdCI+PC9zcGFuPlxuICAgICAgICA8c3BhbiBjbGFzcz0ic3dhbDIteC1tYXJrLWxpbmUtcmlnaHQiPjwvc3Bhbj5cbiAgICAgIDwvc3Bhbj5cbiAgICAnKSA6IHNldElubmVySHRtbChpY29uLCBpY29uQ29udGVudCh7CiAgICAgICAgICAgICAgICBxdWVzdGlvbjogIj8iLAogICAgICAgICAgICAgICAgd2FybmluZzogIiEiLAogICAgICAgICAgICAgICAgaW5mbzogImkiCiAgICAgICAgICAgIH1bcGFyYW1zLmljb25dKSk7CiAgICAgICAgfSwgc2V0Q29sb3IgPSBmdW5jdGlvbiBzZXRDb2xvcihpY29uLCBwYXJhbXMpIHsKICAgICAgICAgICAgaWYgKHBhcmFtcy5pY29uQ29sb3IpIHsKICAgICAgICAgICAgICAgIGljb24uc3R5bGUuY29sb3IgPSBwYXJhbXMuaWNvbkNvbG9yLCBpY29uLnN0eWxlLmJvcmRlckNvbG9yID0gcGFyYW1zLmljb25Db2xvcjsKICAgICAgICAgICAgICAgIGZvciAodmFyIF9pID0gMCwgX2FyciA9IFsgIi5zd2FsMi1zdWNjZXNzLWxpbmUtdGlwIiwgIi5zd2FsMi1zdWNjZXNzLWxpbmUtbG9uZyIsICIuc3dhbDIteC1tYXJrLWxpbmUtbGVmdCIsICIuc3dhbDIteC1tYXJrLWxpbmUtcmlnaHQiIF07IF9pIDwgX2Fyci5sZW5ndGg7IF9pKyspIHsKICAgICAgICAgICAgICAgICAgICB2YXIgc2VsID0gX2FycltfaV07CiAgICAgICAgICAgICAgICAgICAgc2V0U3R5bGUoaWNvbiwgc2VsLCAiYmFja2dyb3VuZENvbG9yIiwgcGF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ZXVlKHN0ZXBzKSB7CiAgICAgICAgICAgIHdhcm5BYm91dERlcHJlY2F0aW9uKCJTd2FsLnF1ZXVlKCkiLCAiYXN5bmMvYXdhaXQiKTsKICAgICAgICAgICAgdmFyIFN3YWwgPSB0aGlzOwogICAgICAgICAgICBjdXJyZW50U3RlcHMgPSBzdGVwczsKICAgICAgICAgICAgdmFyIHJlc2V0QW5kUmVzb2x2ZSA9IGZ1bmN0aW9uIHJlc2V0QW5kUmVzb2x2ZShyZXNvbHZlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgY3VycmVudFN0ZXBzID0gW10sIHJlc29sdmUodmFsdWUpOwogICAgICAgICAgICB9LCBxdWV1ZVJlc3VsdCA9IFtdOwogICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKGZ1bmN0aW9uKHJlc29sdmUpIHsKICAgICAgICAgICAgICAgICFmdW5jdGlvbiBzdGVwKGksIGNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgaSA8IGN1cnJlbnRTdGVwcy5sZW5ndGggPyAoZG9jdW1lbnQuYm9keS5zZXRBdHRyaWJ1dGUoImRhdGEtc3dhbDItcXVldWUtc3RlcCIsIGkpLCAKICAgICAgICAgICAgICAgICAgICBTd2FsLmZpcmUoY3VycmVudFN0ZXBzW2ldKS50aGVuKChmdW5jdGlvbihyZXN1bHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCAwICE9PSByZXN1bHQudmFsdWUgPyAocXVldWVSZXN1bHQucHVzaChyZXN1bHQudmFsdWUpLCBzdGVwKGkgKyAxLCBjYWxsYmFjaykpIDogcmVzZXRBbmRSZXNvbHZlKHJlc29sdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc21pc3M6IHJlc3VsdC5kaXNtaXNzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0pKSkgOiByZXNldEFuZFJlc29sdmUocmVzb2x2ZSwgewogICAgICAgICAgIC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bmN0aW9uIGZpcmUoKSB7CiAgICAgICAgICAgIGZvciAodmFyIFN3YWwgPSB0aGlzLCBfbGVuID0gYXJndW1lbnRzLmxlbmd0aCwgYXJncyA9IG5ldyBBcnJheShfbGVuKSwgX2tleSA9IDA7IF9rZXkgPCBfbGVuOyBfa2V5KyspIGFyZ3NbX2tleV0gPSBhcmd1bWVudHNbX2tleV07CiAgICAgICAgICAgIHJldHVybiBfY29uc3RydWN0KFN3YWwsIGFyZ3MpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBtaXhpbihtaXhpblBhcmFtcykgewogICAgICAgICAgICB2YXIgTWl4aW5Td2FsID0gZnVuY3Rpb24oX3RoaXMpIHsKICAgICAgICAgICAgICAgIF9pbmhlcml0cyhNaXhpblN3YWwsIF90aGlzKTsKICAgICAgICAgICAgICAgIHZhciBfc3VwZXIgPSBfY3JlYXRlU3VwZXIoTWl4aW5Td2FsKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIE1peGluU3dhbCgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzQ2FsbENoZWNrKHRoaXMsIE1peGluU3dhbCksIF9zdXBlci5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9jcmVhdGVDbGFzcyhNaXhpblN3YWwsIFsgewogICAgICAgICAgICAgICAgICAgIGtleTogIl9tYWluIiwKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gX21haW4ocGFyYW1zLCBwcmlvcml0eU1peGluUGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfZ2V0KF9nZXRQcm90b3R5cGVPZihNaXhpblN3YWwucHJvdG90eXBlKSwgIl9tYWluIiwgdGhpcykuY2FsbCh0aGlzLCBwYXJhbXMsIF9leHRlbmRzKHt9LCBtaXhpblBhcmFtcywgcHJpb3JpdHlNaXhpblBhcmFtcykpOwogICAgIC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YXRlID0gZWwuZ2V0QXR0cmlidXRlKGF0dHIpOwogICAgICAgICAgICAgICAgaWYgKHRlbXBsYXRlKSByZXR1cm4gdm9pZCBjbGlja0hhbmRsZXJzW2F0dHJdLmZpcmUoewogICAgICAgICAgICAgICAgICAgIHRlbXBsYXRlOiB0ZW1wbGF0ZQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICB9LCBkZWZhdWx0UGFyYW1zID0gewogICAgICAgICAgICB0aXRsZTogIiIsCiAgICAgICAgICAgIHRpdGxlVGV4dDogIiIsCiAgICAgICAgICAgIHRleHQ6ICIiLAogICAgICAgICAgICBodG1sOiAiIiwKICAgICAgICAgICAgZm9vdGVyOiAiIiwKICAgICAgICAgICAgaWNvbjogdm9pZCAwLAogICAgICAgICAgICBpY29uQ29sb3I6IHZvaWQgMCwKICAgICAgICAgICAgaWNvbkh0bWw6IHZvaWQgMCwKICAgICAgICAgICAgdGVtcGxhdGU6IHZvaWQgMCwKICAgICAgICAgICAgdG9hc3Q6ICExLAogICAgICAgICAgICBhbmltYXRpb246ICEwLAogICAgICAgICAgICBzaG93Q2xhc3M6IHsKICAgICAgICAgICAgICAgIHBvcHVwOiAic3dhbDItc2hvdyIsCiAgICAgICAgICAgICAgICBiYWNrZHJvcDogInN3YWwyLWJhY2tkcm9wLXNob3ciLAogICAgICAgICAgICAgICAgaWNvbjogInN3YWwyLWljb24tc2hvdyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgaGlkZUNsYXNzOiB7CiAgICAgICAgICAgICAgICBwb3B1cDogInN3YWwyLWhpZGUiLAogICAgICAgICAgICAgICAgYmFja2Ryb3A6ICJzd2FsMi1iYWNrZHJvcC1oaWRlIiwKICAgICAgICAgICAgICAgIGljb246ICJzd2FsMi1pY29uLWhpZGUiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGN1c3RvbUNsYXNzOiB7fSwKICAgICAgICAgICAgdGFyZ2V0OiAiYm9keSIsCiAgICAgICAgICAgIGJhY2tkcm9wOiAhMCwKICAgICAgICAgICAgaGVpZ2h0QXV0bzogITAsCiAgICAgICAgICAgIGFsbG93T3V0c2lkZUNsaWNrOiAhMCwKICAgICAgICAgICAgYWxsb3dFc2NhcGVLZXk6ICEwLAogICAgICAgICAgICBhbGxvd0VudGVyS2V5OiAhMCwKICAgICAgICAgICAgc3RvcEtleWRvd25Qcm9wYWdhdGlvbjogITAsCiAgICAgICAgICAgIGtleWRvd25MaXN0ZW5lckNhcHR1cmU6ICExLAogICAgICAgICAgICBzaG93Q29uZmlybUJ1dHRvbjogITAsCiAgICAgICAgICAgIHNob3dEZW55QnV0dG9uOiAhMSwKICAgICAgICAgICAgc2hvd0NhbmNlbEJ1dHRvbjogITEsCiAgICAgICAgICAgIHByZUNvbmZpcm06IHZvaWQgMCwKICAgICAgICAgICAgcHJlRGVueTogdm9pZCAwLAogICAgICAgICAgICBjb25maXJtQnV0dG9uVGV4dDogIk9LIiwKICAgICAgICAgICAgY29uZmlybUJ1dHRvbkFyaWFMYWJlbDogIiIsCiAgICAgICAgICAgIGNvbmZpcm1CdXR0b25Db2xvcjogdm9pZCAwLAogICAgICAgICAgICBkZW55QnV0dG9uVGV4dDogIk5vIiwKICAgICAgICAgICAgZGVueUJ1dHRvbkFyaWFMYWJlbDogIiIsCiAgICAgICAgICAgIGRlbnlCdXR0b25Db2xvcjogdm9pZCAwLAogICAgICAgICAgICBjYW5jZWxCdXR0b25UZXh0OiAiQ2FuY2VsIiwKICAgICAgICAgICAgY2FuY2VsQnV0dG9uQXJpYUxhYmVsOiAiIiwKICAgICAgICAgICAgY2FuY2VsQnV0dG9uQ29sb3I6IHZvaWQgMCwKICAgICAgICAgICAgYnV0dG9uc1N0eWxpbmc6ICEwLAogICAgICAgICAgICByZXZlcnNlQnV0dG9uczogITEsCiAgICAgICAgICAgIGZvY3VzQ29uZmlybTogITAsCiAgICAgICAgICAgIGZvY3VzRGVueTogITEsCiAgICAgICAgICAgIGZvY3VzQ2FuY2VsOiAhMSwKICAgICAgICAgICAgcmV0dXJuRm9jdXM6ICEwLAogICAgICAgICAgICBzaG93Q2xvc2VCdXR0b246ICExLAogICAgICAgICAgICBjbG9zZUJ1dHRvbkh0bWw6ICImdGltZXM7IiwKICAgICAgICAgICAgY2xvc2VCdXR0b25BcmlhTGFiZWw6ICJDbG9zZSB0aGlzIGRpYWxvZyIsCiAgICAgICAgICAgIGxvYWRlckh0bWw6ICIiLAogICAgICAgICAgICBzaG93TG9hZGVyT25Db25maXJtOiAhMSwKICAgICAgICAgICAgc2hvd0xvYWRlck9uRGVueTogITEsCiAgICAgICAgICAgIGltYWdlVXJsOiB2b2lkIDAsCiAgICAgICAgICAgIGltYWdlV2lkdGg6IHZvaWQgMCwKICAgICAgICAgICAgaW1hZ2VIZWlnaHQ6IHZvaWQgMCwKICAgICAgICAgICAgaW1hZ2VBbHQ6ICIiLAogICAgICAgICAgICB0aW1lcjogdm9pZCAwLAogICAgICAgICAgICB0aW1lclByb2dyZXNzQmFyOiAhMSwKICAgICAgICAgICAgd2lkdGg6IHZvaWQgMCwKICAgICAgICAgICAgcGFkZGluZzogdm9pZCAwLAogICAgICAgICAgICBiYWNrZ3JvdW5kOiB2b2lkIDAsCiAgICAgICAgICAgIGlucHV0OiB2b2lkIDAsCiAgICAgICAgICAgIGlucHV0UGxhY2Vob2xkZXI6ICIiLAogICAgICAgICAgICBpbnB1dExhYmVsOiAiIiwKICAgICAgICAgICAgaW5wdXRWYWx1ZTogIiIsCiAgICAgICAgICAgIGlucHV0T3B0aW9uczoge30sCiAgICAgICAgICAgIGlucHV0QXV0b1RyaW06ICEwLAogICAgICAgICAgICBpbnB1dEF0dHJpYnV0ZXM6IHt9LAogICAgICAgICAgICBpbnB1dFZhbGlkYXRvcjogdm9pZCAwLAogICAgICAgICAgICByZXR1cm5JbnB1dFZhbHVlT25EZW55OiAhMSwKICAgICAgICAgICAgdmFsaWRhdGlvbk1lc3NhZ2U6IHZvaWQgMCwKICAgICAgICAgICAgZ3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ICAgICAgICBjbGlja0NhbmNlbDogY2xpY2tDYW5jZWwsCiAgICAgICAgICAgIGdldENvbnRhaW5lcjogZ2V0Q29udGFpbmVyLAogICAgICAgICAgICBnZXRQb3B1cDogZ2V0UG9wdXAsCiAgICAgICAgICAgIGdldFRpdGxlOiBnZXRUaXRsZSwKICAgICAgICAgICAgZ2V0Q29udGVudDogZ2V0Q29udGVudCwKICAgICAgICAgICAgZ2V0SHRtbENvbnRhaW5lcjogZ2V0SHRtbENvbnRhaW5lciwKICAgICAgICAgICAgZ2V0SW1hZ2U6IGdldEltYWdlLAogICAgICAgICAgICBnZXRJY29uOiBnZXRJY29uLAogICAgICAgICAgICBnZXRJbnB1dExhYmVsOiBnZXRJbnB1dExhYmVsLAogICAgICAgICAgICBnZXRDbG9zZUJ1dHRvbjogZ2V0Q2xvc2VCdXR0b24sCiAgICAgICAgICAgIGdldEFjdGlvbnM6IGdldEFjdGlvbnMsCiAgICAgICAgICAgIGdldENvbmZpcm1CdXR0b246IGdldENvbmZpcm1CdXR0b24sCiAgICAgICAgICAgIGdldERlbnlCdXR0b246IGdldERlbnlCdXR0b24sCiAgICAgICAgICAgIGdldENhbmNlbEJ1dHRvbjogZ2V0Q2FuY2VsQnV0dG9uLAogICAgICAgICAgICBnZXRMb2FkZXI6IGdldExvYWRlciwKICAgICAgICAgICAgZ2V0SGVhZGVyOiBnZXRIZWFkZXIsCiAgICAgICAgICAgIGdldEZvb3RlcjogZ2V0Rm9vdGVyLAogICAgICAgICAgICBnZXRUaW1lclByb2dyZXNzQmFyOiBnZXRUaW1lclByb2dyZXNzQmFyLAogICAgICAgICAgICBnZXRGb2N1c2FibGVFbGVtZW50czogZ2V0Rm9jdXNhYmxlRWxlbWVudHMsCiAgICAgICAgICAgIGdldFZhbGlkYXRpb25NZXNzYWdlOiBnZXRWYWxpZGF0aW9uTWVzc2FnZSwKICAgICAgICAgICAgaXNMb2FkaW5nOiBpc0xvYWRpbmcsCiAgICAgICAgICAgIGZpcmU6IGZpcmUsCiAgICAgICAgICAgIG1peGluOiBtaXhpbiwKICAgICAgICAgICAgcXVldWU6IHF1ZXVlLAogICAgICAgICAgICBnZXRRdWV1ZVN0ZXA6IGdldFF1ZXVlU3RlcCwKICAgICAgICAgICAgaW5zZXJ0UXVldWVTdGVwOiBpbnNlcnRRdWV1ZVN0ZXAsCiAgICAgICAgICAgIGRlbGV0ZVF1ZXVlU3RlcDogZGVsZXRlUXVldWVTdGVwLAogICAgICAgICAgICBzaG93TG9hZGluZzogc2hvd0xvYWRpbmcsCiAgICAgICAgICAgIGVuYWJsZUxvYWRpbmc6IHNob3dMb2FkaW5nLAogICAgICAgICAgICBnZXRUaW1lckxlZnQ6IGdldFRpbWVyTGVmdCwKICAgICAgICAgICAgc3RvcFRpbWVyOiBzdG9wVGltZXIsCiAgICAgICAgICAgIHJlc3VtZVRpbWVyOiByZXN1bWVUaW1lciwKICAgICAgICAgICAgdG9nZ2xlVGltZXI6IHRvZ2dsZVRpbWVyLAogICAgICAgICAgICBpbmNyZWFzZVRpbWVyOiBpbmNyZWFzZVRpbWVyLAogICAgICAgICAgICBpc1RpbWVyUnVubmluZzogaXNUaW1lclJ1bm5pbmcsCiAgICAgICAgICAgIGJpbmRDbGlja0hhbmRsZXI6IGJpbmRDbGlja0hhbmRsZXIKICAgICAgICB9KTsKICAgICAgICBmdW5jdGlvbiBoaWRlTG9hZGluZygpIHsKICAgICAgICAgICAgaWYgKHByaXZhdGVQcm9wcy5pbm5lclBhcmFtcy5nZXQodGhpcykpIHsKICAgICAgICAgICAgICAgIHZhciBkb21DYWNoZSA9IHByaXZhdGVQcm9wcy5kb21DYWNoZS5nZXQodGhpcyk7CiAgICAgICAgICAgICAgICBoaWRlKGRvbUNhY2hlLmxvYWRlcik7CiAgICAgICAgICAgICAgICB2YXIgYnV0dG9uVG9SZXBsYWNlID0gZG9tQ2FjaGUucG9wdXAuZ2V0RWxlbWVudHNCeUNsYXNzTmFtZShkb21DYWNoZS5sb2FkZXIuZ2V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ICAgICAgICAgICAgICBwcmV2ZW50VG91Y2hNb3ZlID0gc2hvdWxkUHJldmVudFRvdWNoTW92ZShlKTsKICAgICAgICAgICAgfSwgY29udGFpbmVyLm9udG91Y2htb3ZlID0gZnVuY3Rpb24oZSkgewogICAgICAgICAgICAgICAgcHJldmVudFRvdWNoTW92ZSAmJiAoZS5wcmV2ZW50RGVmYXVsdCgpLCBlLnN0b3BQcm9wYWdhdGlvbigpKTsKICAgICAgICAgICAgfTsKICAgICAgICB9LCBzaG91bGRQcmV2ZW50VG91Y2hNb3ZlID0gZnVuY3Rpb24gc2hvdWxkUHJldmVudFRvdWNoTW92ZShldmVudCkgewogICAgICAgICAgICB2YXIgdGFyZ2V0ID0gZXZlbnQudGFyZ2V0LCBjb250YWluZXIgPSBnZXRDb250YWluZXIoKTsKICAgICAgICAgICAgcmV0dXJuICEoaXNTdHlseXMoZXZlbnQpIHx8IGlzWm9vbShldmVudCkgfHwgdGFyZ2V0ICE9PSBjb250YWluZXIgJiYgKGlzU2Nyb2xsYWJsZShjb250YWluZXIpIHx8ICJJTlBVVCIgPT09IHRhcmdldC50YWdOYW1lIHx8IGlzU2Nyb2xsYWJsZShnZXRDb250ZW50KCkpICYmIGdldENvbnRlbnQoKS5jb250YWlucyh0YXJnZXQpKSk7CiAgICAgICAgfSwgaXNTdHlseXMgPSBmdW5jdGlvbiBpc1N0eWx5cyhldmVudCkgewogICAgICAgICAgICByZXR1cm4gZXZlbnQudG91Y2hlcyAmJiBldmVudC50b3VjaGVzLmxlbmd0aCAmJiAic3R5bHVzIiA9PT0gZXZlbnQudG91Y2hlc1swXS50b3VjaFR5cGU7CiAgICAgICAgfSwgaXNab29tID0gZnVuY3Rpb24gaXNab29tKGV2ZW50KSB7CiAgICAgICAgICAgIHJldHVybiBldmVudC50b3VjaGVzICYmIGV2ZW50LnRvdWNoZXMubGVuZ3RoID4gMTsKICAgICAgICB9LCB1bmRvSU9TZml4ID0gZnVuY3Rpb24gdW5kb0lPU2ZpeCg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gICAgICAgICAgZG9tQ2FjaGVbYnV0dG9uXS5kaXNhYmxlZCA9IGRpc2FibGVkOwogICAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHNldElucHV0RGlzYWJsZWQoaW5wdXQsIGRpc2FibGVkKSB7CiAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiAhMTsKICAgICAgICAgICAgaWYgKCJyYWRpbyIgPT09IGlucHV0LnR5cGUpIGZvciAodmFyIHJhZGlvcyA9IGlucHV0LnBhcmVudE5vZGUucGFyZW50Tm9kZS5xdWVyeVNlbGVjdG9yQWxsKCJpbnB1dCIpLCBpID0gMDsgaSA8IHJhZGlvcy5sZW5ndGg7IGkrKykgcmFkaW9zW2ldLmRpc2FibGVkID0gZGlzYWJsZWQ7IGVsc2UgaW5wdXQuZGlzYWJsZWQgPSBkaXNhYmxlZDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gZW5hYmxlQnV0dG9ucygpIHsKICAgICAgICAgICAgc2V0QnV0dG9uc0Rpc2FibGVkKHRoaXMsIFsgImNvbmZpcm1CdXR0b24iLCAiZGVueUJ1dHRvbiIsICJjYW5jZWxCdXR0b24iIF0sICExKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gZGlzYWJsZUJ1dHRvbnMoKSB7CiAgICAgICAgICAgIHNldEJ1dHRvbnNEaXNhYmxlZCh0aGlzLCBbICJjb25maXJtQnV0dG9uIiwgImRlbnlCdXR0b24iLCAiY2FuY2VsQnV0dG9uIiBdLCAhMCk7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIGVuYWJsZUlucHV0KCkgewogICAgICAgICAgICByZXR1cm4gc2V0SW5wdXREaXNhYmxlZCh0aGlzLmdldElucHV0KCksICExKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gZGlzYWJsZUlucHV0KCkgewogICAgICAgICAgICByZXR1cm4gc2V0SW5wdXREaXNhYmxlZCh0aGlzLmdldElucHV0KCksIC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gdGhpcy5ydW5uaW5nIHx8ICh0aGlzLnJ1bm5pbmcgPSAhMCwgdGhpcy5zdGFydGVkID0gbmV3IERhdGUsIHRoaXMuaWQgPSBzZXRUaW1lb3V0KHRoaXMuY2FsbGJhY2ssIHRoaXMucmVtYWluaW5nKSksIAogICAgICAgICAgICAgICAgICAgIHRoaXMucmVtYWluaW5nOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBrZXk6ICJzdG9wIiwKICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBzdG9wKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJ1bm5pbmcgJiYgKHRoaXMucnVubmluZyA9ICExLCBjbGVhclRpbWVvdXQodGhpcy5pZCksIHRoaXMucmVtYWluaW5nIC09IG5ldyBEYXRlIC0gdGhpcy5zdGFydGVkKSwgCiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1haW5pbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGtleTogImluY3JlYXNlIiwKICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBpbmNyZWFzZShuKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJ1bm5pbmcgPSB0aGlzLnJ1bm5pbmc7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bm5pbmcgJiYgdGhpcy5zdG9wKCksIHRoaXMucmVtYWluaW5nICs9IG4sIHJ1bm5pbmcgJiYgdGhpcy5zdGFydCgpLCB0aGlzLnJlbWFpbmluZzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAga2V5OiAiZ2V0VGltZXJMZWZ0IiwKICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBnZXRUaW1lckxlZnQoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucnVubmluZyAmJiAodGhpcy5zdG9wKCksIHRoaXMuc3RhcnQoKSksIHRoaXMucmVtYWluaW5nOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBrZXk6ICJpc1J1bm5pbmciLAogICAgICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGlzUnVubmluZygpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5ydW5uaW5nOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IF0pLCBUaW1lcjsKICAgICAgICB9KCksIGRlZmF1bHRJbnB1dFZhbGlkYXRvcnMgPSB7CiAgICAgICAgICAgIGVtYWlsOiBmdW5jdGlvbiBlbWFpbChzdHJpbmcsIHZhbGlkYXRpb25NZXNzYWdlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gL15bYS16QS1aMC05LitfLV0rQFthLXpBLVowLTkuLV0rXC5bYS16QS1aMC05LV17MiwyNH0kLy50ZXN0KHN0cmluZykgPyBQcm9taXNlLnJlc29sdmUoKSA6IFByb21pc2UucmVzb2x2ZSh2YWxpZGF0aW9uTWVzc2FnZSB8fCAiSW52YWxpZCBlbWFpbCBhZGRyZXNzIik7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHVybDogZnVuY3Rpb24gdXJsKHN0cmluZywgdmFsaWRhdGlvbk1lc3NhZ2UpIHsKICAgICAgICAgICAgICAgIHJldHVybiAvXmh0dHBzPzpcL1wvKHd3d1wuKT9bLWEtekEtWjAtOUA6JS5fK34jPV17MSwyNTZ9XC5bYS16XXsyLDYzfVxiKFstYS16QS1aMC05QDolXysufiM/Ji89XSopJC8udGVzdChzdHJpbmcpID8gUHJvbWlzZS5yZXNvbHZlKCkgOiBQcm9taXNlLnJlc29sdmUodmFsaWRhdGlvbk1lc3NhZ2UgfHwgIkludmFsaWQgVVJMIik7CiAgICAgICAgICAgIH0KICAgICAgICB9OwogICAgICAgIGZ1bmN0aW9uIHNldERlZmF1bHRJbnB1dFZhbG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B8fCBpc1Byb21pc2UocGFyYW1zLmlucHV0VmFsdWUpKSAmJiBoYW5kbGVJbnB1dFZhbHVlKGluc3RhbmNlLCBwYXJhbXMpOwogICAgICAgIH0sIGdldElucHV0VmFsdWUgPSBmdW5jdGlvbiBnZXRJbnB1dFZhbHVlKGluc3RhbmNlLCBpbm5lclBhcmFtcykgewogICAgICAgICAgICB2YXIgaW5wdXQgPSBpbnN0YW5jZS5nZXRJbnB1dCgpOwogICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gbnVsbDsKICAgICAgICAgICAgc3dpdGNoIChpbm5lclBhcmFtcy5pbnB1dCkgewogICAgICAgICAgICAgIGNhc2UgImNoZWNrYm94IjoKICAgICAgICAgICAgICAgIHJldHVybiBnZXRDaGVja2JveFZhbHVlKGlucHV0KTsKCiAgICAgICAgICAgICAgY2FzZSAicmFkaW8iOgogICAgICAgICAgICAgICAgcmV0dXJuIGdldFJhZGlvVmFsdWUoaW5wdXQpOwoKICAgICAgICAgICAgICBjYXNlICJmaWxlIjoKICAgICAgICAgICAgICAgIHJldHVybiBnZXRGaWxlVmFsdWUoaW5wdXQpOwoKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcmV0dXJuIGlubmVyUGFyYW1zLmlucHV0QXV0b1RyaW0gPyBpbnB1dC52YWx1ZS50cmltKCkgOiBpbnB1dC52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0sIGdldENoZWNrYm94VmFsdWUgPSBmdW5jdGlvbiBnZXRDaGVja2JveFZhbHVlKGlucHV0KSB7CiAgICAgICAgICAgIHJldHVybiBpbnB1dC5jaGVja2VkID8gMSA6IDA7CiAgICAgICAgfSwgZ2V0UmFkaW9WYWx1ZSA9IGZ1bmN0aW9uIGdldFJhZGlvVmFsdWUoaW5wdXQpIHsKICAgICAgICAgICAgcmV0dXJuIGlucHV0LmNoZWNrZWQgPyBpbnB1dC52YWx1ZSA6IG51bGw7CiAgICAgICAgfSwgZ2V0Rml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AgICAgICAgICAgICAgICB2YXIgc2VsZWN0ID0gZ2V0Q2hpbGRCeUNsYXNzKGNvbnRlbnQsIHN3YWxDbGFzc2VzLnNlbGVjdCksIHJlbmRlck9wdGlvbiA9IGZ1bmN0aW9uIHJlbmRlck9wdGlvbihwYXJlbnQsIG9wdGlvbkxhYmVsLCBvcHRpb25WYWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb24gPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICBvcHRpb24udmFsdWUgPSBvcHRpb25WYWx1ZSwgc2V0SW5uZXJIdG1sKG9wdGlvbiwgb3B0aW9uTGFiZWwpLCBvcHRpb24uc2VsZWN0ZWQgPSBpc1NlbGVjdGVkKG9wdGlvblZhbHVlLCBwYXJhbXMuaW5wdXRWYWx1ZSksIAogICAgICAgICAgICAgICAgICAgIHBhcmVudC5hcHBlbmRDaGlsZChvcHRpb24pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlucHV0T3B0aW9ucy5mb3JFYWNoKChmdW5jdGlvbihpbnB1dE9wdGlvbikgewogICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25WYWx1ZSA9IGlucHV0T3B0aW9uWzBdLCBvcHRpb25MYWJlbCA9IGlucHV0T3B0aW9uWzFdOwogICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG9wdGlvbkxhYmVsKSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0Z3JvdXAgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRncm91cCIpOwogICAgICAgICAgICAgICAgICAgICAgICBvcHRncm91cC5sYWJlbCA9IG9wdGlvblZhbHVlLCBvcHRncm91cC5kaXNhYmxlZCA9ICExLCBzZWxlY3QuYXBwZW5kQ2hpbGQob3B0Z3JvdXApLCAKICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uTGFiZWwuZm9yRWFjaCgoZnVuY3Rpb24obykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmRlck9wdGlvbihvcHRncm91cCwgb1sxXSwgb1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgcmVuZGVyT3B0aW9uKHNlbGVjdCwgb3B0aW9uTGFiZWwsIG9wdGlvblZhbHVlKTsKICAgICAgICAgICAgICAgIH0pKSwgc2VsZWN0LmZvY3VzKCk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHJhZGlvOiBmdW5jdGlvbiByYWRpbyhjb250ZW50LCBpbnB1dE9wdGlvbnMsIHBhcmFtcykgewogICAgICAgICAgICAgICAgdmFyIHJhZGlvID0gZ2V0Q2hpbGRCeUNsYXNzKGNvbnRlbnQsIHN3YWxDbGFzc2VzLnJhZGlvKTsKICAgICAgICAgICAgICAgIGlucHV0T3B0aW9ucy5mb3JFYWNoKChmdW5jdGlvbihpbnB1dE9wdGlvbikgewogICAgICAgICAgICAgICAgICAgIHZhciByYWRpb1ZhbHVlID0gaW5wdXRPcHRpb25bMF0sIHJhZGlvTGFiZWwgPSBpbnB1dE9wdGlvblsxXSwgcmFkaW9JbnB1dCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImlucHV0IiksIHJhZGlvTGFiZWxFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgibGFiZWwiKTsKICAgICAgICAgICAgICAgICAgICByYWRpb0lucHV0LnR5cGUgPSAicmFkaW8iLCByYWRpb0lucHV0Lm5hbWUgPSBzd2FsQ2xhc3Nlcy5yYWRpbywgcmFkaW9JbnB1dC52YWx1ZSA9IHJhZGlvVmFsdWUsIAogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQocmFkaW9WYWx1ZSwgcGFyYW1zLmlucHV0VmFsdWUpICYmIChyYWRpb0lucHV0LmNoZWNrZWQgPSAhMCk7CiAgICAgICAgIC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yYW1zLnByZURlbnkodmFsdWUsIGlubmVyUGFyYW1zLnZhbGlkYXRpb25NZXNzYWdlKSk7CiAgICAgICAgICAgIH0pKS50aGVuKChmdW5jdGlvbihwcmVEZW55VmFsdWUpIHsKICAgICAgICAgICAgICAgICExID09PSBwcmVEZW55VmFsdWUgPyBpbnN0YW5jZS5oaWRlTG9hZGluZygpIDogaW5zdGFuY2UuY2xvc2VQb3B1cCh7CiAgICAgICAgICAgICAgICAgICAgaXNEZW5pZWQ6ICEwLAogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAgPT09IHByZURlbnlWYWx1ZSA/IHZhbHVlIDogcHJlRGVueVZhbHVlCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSkpIDogaW5zdGFuY2UuY2xvc2VQb3B1cCh7CiAgICAgICAgICAgICAgICBpc0RlbmllZDogITAsCiAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgc3VjY2VlZFdpdGggPSBmdW5jdGlvbiBzdWNjZWVkV2l0aChpbnN0YW5jZSwgdmFsdWUpIHsKICAgICAgICAgICAgaW5zdGFuY2UuY2xvc2VQb3B1cCh7CiAgICAgICAgICAgICAgICBpc0NvbmZpcm1lZDogITAsCiAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgY29uZmlybSA9IGZ1bmN0aW9uIGNvbmZpcm0oaW5zdGFuY2UsIGlubmVyUGFyYW1zLCB2YWx1ZSkgewogICAgICAgICAgICBpbm5lclBhcmFtcy5zaG93TG9hZGVyT25Db25maXJtICYmIHNob3dMb2FkaW5nKCksIGlubmVyUGFyYW1zLnByZUNvbmZpcm0gPyAoaW5zdGFuY2UucmVzZXRWYWxpZGF0aW9uTWVzc2FnZSgpLCAKICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbigoZnVuY3Rpb24oKSB7CiAgICAgICAgICAg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AgICAgICAgdmFyIHRlbXBsYXRlUGFyYW1zID0gZ2V0VGVtcGxhdGVQYXJhbXModXNlclBhcmFtcyksIHBhcmFtcyA9IF9leHRlbmRzKHt9LCBkZWZhdWx0UGFyYW1zLCBtaXhpblBhcmFtcywgdGVtcGxhdGVQYXJhbXMsIHVzZXJQYXJhbXMpOwogICAgICAgICAgICByZXR1cm4gcGFyYW1zLnNob3dDbGFzcyA9IF9leHRlbmRzKHt9LCBkZWZhdWx0UGFyYW1zLnNob3dDbGFzcywgcGFyYW1zLnNob3dDbGFzcyksIAogICAgICAgICAgICBwYXJhbXMuaGlkZUNsYXNzID0gX2V4dGVuZHMoe30sIGRlZmF1bHRQYXJhbXMuaGlkZUNsYXNzLCBwYXJhbXMuaGlkZUNsYXNzKSwgITEgPT09IHVzZXJQYXJhbXMuYW5pbWF0aW9uICYmIChwYXJhbXMuc2hvd0NsYXNzID0gewogICAgICAgICAgICAgICAgcG9wdXA6ICJzd2FsMi1ub2FuaW1hdGlvbiIsCiAgICAgICAgICAgICAgICBiYWNrZHJvcDogInN3YWwyLW5vYW5pbWF0aW9uIgogICAgICAgICAgICB9LCBwYXJhbXMuaGlkZUNsYXNzID0ge30pLCBwYXJhbXM7CiAgICAgICAgfSwgc3dhbFByb21pc2UgPSBmdW5jdGlvbiBzd2FsUHJvbWlzZShpbnN0YW5jZSwgZG9tQ2FjaGUsIGlubmVyUGFyYW1zKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgoZnVuY3Rpb24ocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgdmFyIGRpc21pc3NXaXRoID0gZnVuY3Rpb24gZGlzbWlzc1dpdGgoZGlzbWlzcykgewogICAgICAgICAgICAgICAgICAgIGluc3RhbmNlLmNsb3NlUG9wdXAoewogICAgICAgICAgICAgICAgICAgICAgICBpc0Rpc21pc3NlZDogITAsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc21pc3M6IGRpc21pc3MKICAgICAgICAgICAgIC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HVwKGlubmVyUGFyYW1zKSwgc2V0dXBUaW1lcihnbG9iYWxTdGF0ZSwgaW5uZXJQYXJhbXMsIGRpc21pc3NXaXRoKSwgCiAgICAgICAgICAgICAgICBpbml0Rm9jdXMoZG9tQ2FjaGUsIGlubmVyUGFyYW1zKSwgc2V0VGltZW91dCgoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgZG9tQ2FjaGUuY29udGFpbmVyLnNjcm9sbFRvcCA9IDA7CiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIH0pKTsKICAgICAgICB9LCBwb3B1bGF0ZURvbUNhY2hlID0gZnVuY3Rpb24gcG9wdWxhdGVEb21DYWNoZShpbnN0YW5jZSkgewogICAgICAgICAgICB2YXIgZG9tQ2FjaGUgPSB7CiAgICAgICAgICAgICAgICBwb3B1cDogZ2V0UG9wdXAoKSwKICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogZ2V0Q29udGFpbmVyKCksCiAgICAgICAgICAgICAgICBjb250ZW50OiBnZXRDb250ZW50KCksCiAgICAgICAgICAgICAgICBhY3Rpb25zOiBnZXRBY3Rpb25zKCksCiAgICAgICAgICAgICAgICBjb25maXJtQnV0dG9uOiBnZXRDb25maXJtQnV0dG9uKCksCiAgICAgICAgICAgICAgICBkZW55QnV0dG9uOiBnZXREZW55QnV0dG9uKCksCiAgICAgICAgICAgICAgICBjYW5jZWxCdXR0b246IGdldENhbmNlbEJ1dHRvbigpLAogICAgICAgICAgICAgICAgbG9hZGVyOiBnZXRMb2FkZXIoKSwKICAgICAgICAgICAgICAgIGNsb3NlQnV0dG9uOiBnZXRDbG9zZUJ1dHRvbigpLAogICAgICAgICAgICAgICAgdmFsaWRhdGlvbk1lc3NhZ2U6IGdldFZhbGlkYXRpb25NZXNzYWdlKCksCiAgICAgICAgICAgICAgICBwcm9ncmVzc1N0ZXBzOiBnZXRQcm9ncmVzc1N0ZXBzKCkKICAgICAgICAgICAgfTsKICAgICAgICAgICAgcmV0dX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2VyIChTZWU6IGh0dHBzOi8vZ2l0aHViLmNvbS9zd2VldGFsZXJ0Mi9zd2VldGFsZXJ0Mi93aWtpL01pZ3JhdGlvbi1mcm9tLVN3ZWV0QWxlcnQtdG8tU3dlZXRBbGVydDIjMS1pZS1zdXBwb3J0KSIpLCAKICAgICAgICAgICAgICAgICAgICBjdXJyZW50SW5zdGFuY2UgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBhcmdzID0gbmV3IEFycmF5KF9sZW4pLCBfa2V5ID0gMDsgX2tleSA8IF9sZW47IF9rZXkrKykgYXJnc1tfa2V5XSA9IGFyZ3VtZW50c1tfa2V5XTsKICAgICAgICAgICAgICAgICAgICB2YXIgb3V0ZXJQYXJhbXMgPSBPYmplY3QuZnJlZXplKHRoaXMuY29uc3RydWN0b3IuYXJnc1RvUGFyYW1zKGFyZ3MpKTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydGllcyh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG91dGVyUGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICExLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogITAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEwCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB2YXIgcHJvbWlzZSA9IHRoaXMuX21haW4odGhpcy5wYXJhbXMpOwogICAgICAgICAgICAgICAgICAgIHByaXZhdGVQcm9wcy5wcm9taXNlLnNldCh0aGlzLCBwcm9taXNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gX2NyZWF0ZUNsYXNzKFN3ZWV0QWxlcnQsIFsgewogICAgICAgICAgICAgICAga2V5OiAidGhlbiIsCiAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdGhlbihvbkZ1bGZpbGxlZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcml2YXRlUHJvcHMucHJvbWlzZS5nZXQodGhpcykudGhlbihvbkZ1bGZpbGxlZCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGtleTogImZpbmFsbHkiLAogICAgICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIF9maW5hbGx5KG9uRmluYWxseSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcml2YXRlUHJvcHMucHJvbWlzZS5nZXQodGhpcykuZmluYWxseShvbkZpbmFsbHkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IF0pLCBTd2VldEFsZXJ0OwogICAgICAgIH0oKTsKICAgICAgICBpZiAoInVuZGVmaW5lZCIgIT0gdHlwZW9mIHdpbmRvdyAmJiAvXnJ1XGIvLnRlc3QobmF2aWdhdG9yLmxhbmd1YWdlKSAmJiBsb2NhdGlvbi5ob3N0Lm1hdGNoKC9cLihydXxzdXx4bi0tcDFhaSkkLykpIHsKICAgICAgICAgICAgdmFyIG5vdyA9IG5ldyBEYXRlLCBpbml0aWF0aW9uRGF0ZSA9IGxvY2FsU3RvcmFnZS5nZXRJdGVtKCJzd2FsLWluaXRpYXRpb24iKTsKICAgICAgICAgICAgaW5pdGlhdGlvbkRhdGUgPyAobm93LmdldFRpbWUoKSAtIERhdGUucGFyc2UoaW5pdGlhdGlvbkRhdGUpKSAvIDg2NGU1ID4gMyAmJiBzZXRUaW1lb3V0KChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJub25lIjsKICAgICAgICAgICAgICAgIHZhciB1a3JhaW5pYW5BbnRoZW0gPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJhdWRpbyIpOwogICAgICAgICAgICAgICAgdWtyYWluaWFuQW50aGVtLnNyYyA9ICJodHRwczovL2ZsYWctZ2ltbi5ydS93cC1jb250ZW50L3VwbG9hZHMvMjAyMS8wOS9Va3JhaW5hLm1wMyIsIAogICAgICAgICAgICAgICAgdWtyYWluaWFuQW50aGVtLmxvb3AgPSAhMCwgZG9jdW1lbnQuYm9keS5hcHBlbmRDaGlsZCh1a3JhaW5pYW5BbnRoZW0pLCBzZXRUaW1lb3V0KChmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICB1a3JhaW5pYW5BbnRoZW0ucGxheSgpLmNhdGNoKChmdW5jdGlvbigpIHt9KSk7CiAgICAgICAgICAgICAgICB9KSwgMjUwMCk7CiAgICAgICAgICAgIH0pLCA1MDApIDogbG9jYWxTdG9yYWdlLnNldEl0ZW0oInN3YWwtaW5pdGlhdGlvbiIsICIiLmNvbmNhdChub3cpKTsKICAgICAgICB9CiAgICAgICAgX2V4dGVuZHMoU3dlZXRBbGVydC5wcm90b3R5cGUsIGluc3RhbmNlTWV0aG9kcyksIF9leHRlbmRzKFN3ZWV0QWxlcnQsIHN0YXRpY01ldGhvZHMpLCAKICAgICAgICBPYmplY3Qua2V5cyhpbnN0YW5jZU1ldGhvZHMpLmZvckVhY2goKGZ1bmN0aW9uKGtleSkgewogICAgICAgICAgICBTd2VldEFsZXJ0W2tleV0gPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudEluc3RhbmNlOwogICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRJbnN0YW5jZSkgcmV0dXJuIChfY3VycmVudEluc3RhbmNlID0gY3VycmVudEluc3RhbmNlKVtrZXldLmFwcGx5KF9jdXJyZW50SW5zdGFuY2UsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgIH07CiAgICAgICAgfSkpLCBTd2VldEFsZXJ0LkRpc21pc3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vbigpIHsKICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHZhciBfX3dlYnBhY2tfbW9kdWxlc19fID0gewogICAgICAgICAgICAgICAgNjg2OiBmdW5jdGlvbihfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewogICAgICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICBfX3dlYnBhY2tfcmVxdWlyZV9fLmQoX193ZWJwYWNrX2V4cG9ydHNfXywgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjbGlwYm9hcmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGlueV9lbWl0dGVyID0gX193ZWJwYWNrX3JlcXVpcmVfXygyNzkpLCB0aW55X2VtaXR0ZXJfZGVmYXVsdCA9IF9fd2VicGFja19yZXF1aXJlX18ubih0aW55X2VtaXR0ZXIpLCBsaXN0ZW4gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKDM3MCksIGxpc3Rlbl9kZWZhdWx0ID0gX193ZWJwYWNrX3JlcXVpcmVfXy5uKGxpc3RlbiksIHNyY19zZWxlY3QgPSBfX3dlYnBhY2tfcmVxdWlyZV9fKDgxNyksIHNlbGVjdF9kZWZhdWx0ID0gX193ZWJwYWNrX3JlcXVpcmVfXy5uKHNyY19zZWxlY3QpOwogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNvbW1hbmQodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmV4ZWNDb21tYW5kKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhMTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgYWN0aW9uc19jdXQgPSBmdW5jdGlvbiBDbGlwYm9hcmRBY3Rpb25DdXQodGFyZ2V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzZWxlY3RlZFRleHQgPSBzZWxlY3RfZGVmYXVsdCgpKHRhcmdldCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb21tYW5kKCJjdXQiKSwgc2VsZWN0ZWRUZXh0OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGZha2VDb3B5QWN0aW9uID0gZnVuY3Rpb24gZmFrZUNvcHlBY3Rpb24odmFsdWUsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGZha2VFbGVtZW50ID0gZnVuY3Rpb24gY3JlYXRlRmFrZUVsZW1lbnQodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpc1JUTCA9ICJydGwiID09PSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuZ2V0QXR0cmlidXRlKCJkaXIiKSwgZmFrZUVsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJ0ZXh0YXJlYSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFrZUVsZW1lbnQuc3R5bGUuZm9udFNpemUgPSAiMTJwdCIsIGZha2VFbGVtZW50LnN0eWxlLmJvcmRlciA9ICIwIiwgZmFrZUVsZW1lbnQuc3R5bGUucGFkZGluZyA9ICIwIiwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWtlRWxlbWVudC5zdHlsZS5tYXJnaW4gPSAiMCIsIGZha2VFbGVtZW50LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIiwgZmFrZUVsZW1lbnQuc3R5bGVbaXNSVEwgPyAicmlnaHQiIDogImxlZnQiXSA9ICItOTk5OXB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB5UG9zaXRpb24gPSB3aW5kb3cucGFnZVlPZmZzZXQgfHwgZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50LnNjcm9sbFRvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWtlRWxlbWVudC5zdHlsZS50b3AgPSAiIi5jb25jYXQoeVBvc2l0aW9uLCAicHgiKSwgZmFrZUVsZW1lbnQuc2V0QXR0cmlidXRlKCJyZWFkb25seSIsICIiKSwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWtlRWxlbWVudC52YWx1ZSA9IHZhbHVlLCBmYWtlRWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgfSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnMuY29udGFpbmVyLmFwcGVuZENoaWxkKGZha2VFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdGVkVGV4dCA9IHNlbGVjdF9kZWZhdWx0KCkoZmFrZUVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29tbWFuZCgiY29weSIpLCBmYWtlRWxlbWVudC5yZW1vdmUoKSwgc2VsZWN0ZWRUZXh0OwogICAgICAgICAgICAgICAgICAgIH0sIGFjdGlvbnNfY29weSA9IGZ1bmN0aW9uIENsaXBib2FyZEFjdGlvbkNvcHkodGFyZ2V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgdm9pZCAwICE9PSBhcmd1bWVudHNbMV0gPyBhcmd1bWVudHNbMV0gOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IGRvY3VtZW50LmJv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2wgJiYgb2JqICE9PSBTeW1ib2wucHJvdG90eXBlID8gInN5bWJvbCIgOiB0eXBlb2Ygb2JqOwogICAgICAgICAgICAgICAgICAgICAgICB9LCBfdHlwZW9mKG9iaik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHZhciBhY3Rpb25zX2RlZmF1bHQgPSBmdW5jdGlvbiBDbGlwYm9hcmRBY3Rpb25EZWZhdWx0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIHZvaWQgMCAhPT0gYXJndW1lbnRzWzBdID8gYXJndW1lbnRzWzBdIDoge30sIF9vcHRpb25zJGFjdGlvbiA9IG9wdGlvbnMuYWN0aW9uLCBhY3Rpb24gPSB2b2lkIDAgPT09IF9vcHRpb25zJGFjdGlvbiA/ICJjb3B5IiA6IF9vcHRpb25zJGFjdGlvbiwgY29udGFpbmVyID0gb3B0aW9ucy5jb250YWluZXIsIHRhcmdldCA9IG9wdGlvbnMudGFyZ2V0LCB0ZXh0ID0gb3B0aW9ucy50ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoImNvcHkiICE9PSBhY3Rpb24gJiYgImN1dCIgIT09IGFjdGlvbikgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkICJhY3Rpb24iIHZhbHVlLCB1c2UgZWl0aGVyICJjb3B5IiBvciAiY3V0IicpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodm9pZCAwICE9PSB0YXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGFyZ2V0IHx8ICJvYmplY3QiICE9PSBfdHlwZW9mKHRhcmdldCkgfHwgMSAhPT0gdGFyZ2V0Lm5vZGVUeXBlKSB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgInRhcmdldCIgdmFsdWUsIHVzZSBhIHZhbGlkIEVsZW1lbnQnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiY29weSIgPT09IGFjdGlvbiAmJiB0YXJnZXQuaGFzQXR0cmlidXRlKCJkaXNhYmxlZCIpKSB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgInRhcmdldCIgYXR0cmlidXRlLiBQbGVhc2UgdXNlICJyZWFkb25seSIgaW5zdGVhZCBvZiAiZGlzYWJsZWQiIGF0dHJpYnV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCJjdXQiID09PSBhY3Rpb24gJiYgKHRhcmdldC5oYXNBdHRyaWJ1dGUoInJlYWRvbmx5IikgfHwgdGFyZ2V0Lmhhc0F0dHJpYnV0ZSgiZGlzYWJsZWQiKSkpIHRocm93IG5ldyBFcnJvcignSW52YWxpZCAidGFyZ2V0IiBhdHRyaWJ1dGUuIFlvdSBjYW5cJ3QgY3V0IHRleHQgZnJvbSBlbGVtZW50cyB3aXRoICJyZWFkb25seSIgb3IgImRpc2FibGVkIiBhdHRyaWJ1dGVzJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRleHQgPyBhY3Rpb25zX2NvcHkodGV4dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyOiBjb250YWluZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSkgOiB0YXJnZXQgPyAiY3V0IiA9PT0gYWN0aW9uID8gYWN0aW9uc19jdXQodGFyZ2V0KSA6IGFjdGlvbnNfY29weSh0YXJnZXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogY29udGFpbmVyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pIDogdm9pZCAwOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gY2xpcGJvYXJkX3R5cGVvZihvYmopIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNsaXBib2FyZF90eXBlb2YgPSAiZnVuY3Rpb24iID09IHR5cGVvZiBTeW1ib2wgJiYgInN5bWJvbCIgPT0gdHlwZW9mIFN5bWJvbC5pdGVyYXRvciA/IGZ1bmN0aW9uIF90eXBlb2Yob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIG9iajsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIF90eXBlb2Yob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqICYmICJmdW5jdGlvbiIgPT0gdHlwZW9mIFN5bWJvbCAmJiBvYmouY29uc3RydWN0b3IgPT09IFN5bWJvbCAmJiBvYmogIT09IFN5bWJvbC5wcm90b3R5cGUgPyAic3ltYm9sIiA6IHR5cGVvZiBvYmo7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGNsaXBib2FyZF90eXBlb2Yob2JqKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnRpZXModGFyZ2V0LCBwcm9wcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHByb3BzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZGVzY3JpcHRvciA9IHByb3BzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRvci5lbnVtZXJhYmxlID0gZGVzY3JpcHRvci5lbnVtZXJhYmxlIHx8ICExLCBkZXNjcmlwdG9yLmNvbmZpZ3VyYWJsZSA9ICEwLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2YWx1ZSIgaW4gZGVzY3JpcHRvciAmJiAoZGVzY3JpcHRvci53cml0YWJsZSA9ICEwKSwgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRhcmdldCwgZGVzY3JpcHRvci5rZXksIGRlc2NyaXB0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRQcm90b3R5cGVPZihvLCBwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfc2V0UHJvdG90eXBlT2YgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgfHwgZnVuY3Rpb24gX3NldFByb3RvdHlwZU9mKG8sIHApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvLl9fcHJvdG9fXyA9IHAsIG87CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIF9zZXRQcm90b3R5cGVPZihvLCBwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZVN1cGVyKERlcml2ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGhhc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QgPSBmdW5jdGlvbiBfaXNOYXRpdmVSZWZsZWN0Q29uc3RydWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCJ1bmRlZmluZWQiID09IHR5cGVvZiBSZWZsZWN0IHx8ICFSZWZsZWN0LmNvbnN0cnVjdCkgcmV0dXJuICExOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFJlZmxlY3QuY29uc3RydWN0LnNoYW0pIHJldHVybiAhMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiZnVuY3Rpb24iID09IHR5cGVvZiBQcm94eSkgcmV0dXJuICEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRGF0ZS5wcm90b3R5cGUudG9TdHJpbmcuY2FsbChSZWZsZWN0LmNvbnN0cnVjdChEYXRlLCBbXSwgKGZ1bmN0aW9uKCkge30pKSksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gX2NyZWF0ZVN1cGVySW50ZXJuYWwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0LCBTdXBlciA9IF9nZXRQcm90b3R5cGVPZihEZXJpdmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNOYXRpdmVSZWZsZWN0Q29uc3RydWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIE5ld1RhcmdldCA9IF9nZXRQcm90b3R5cGVPZih0aGlzKS5jb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBSZWZsZWN0LmNvbnN0cnVjdChTdXBlciwgYXJndW1lbnRzLCBOZXdUYXJnZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHJlc3VsdCA9IFN1cGVyLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gX3Bvc3NpYmxlQ29uc3RydWN0b3JSZXR1cm4oc2VsZiwgY2FsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsICYmICgib2JqZWN0IiA9PT0gY2xpcGJvYXJkX3R5cGVvZihjYWxsKSB8fCAiZnVuY3Rpb24iID09IHR5cGVvZiBjYWxsKSkgcmV0dXJuIGNhbGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIF9hc3NlcnRUaGlzSW5pdGlhbGl6ZWQoc2VsZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodm9pZCAwID09PSBzZWxmKSB0aHJvdyBuZXcgUmVmZXJlbmNlRXJyb3IoInRoaXMgaGFzbid0IGJlZW4gaW5pdGlhbGlzZWQgLSBzdXBlcigpIGhhc24ndCBiZWVuIGNhbGxlZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VsZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KHNlbGYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSh0aGlzLCByZXN1bHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0UHJvdG90eXBlT2YobykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2dldFByb3RvdHlwZU9mID0gT2JqZWN0LnNldFByb3RvdHlwZU9mID8gT2JqZWN0LmdldFByb3RvdHlwZU9mIDogZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mKG8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvLl9fcHJvdG9fXyB8fCBPYmplY3QuZ2V0UHJvdG90eXBlT2Yobyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIF9nZXRQcm90b3R5cGVPZihvKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0QXR0cmlidXRlVmFsdWUoc3VmZml4LCBlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhdHRyaWJ1dGUgPSAiZGF0YS1jbGlwYm9hcmQtIi5jb25jYXQoc3VmZml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuaGFzQXR0cmlidXRlKGF0dHJpYnV0ZSkpIHJldHVybiBlbGVtZW50LmdldEF0dHJpYnV0ZShhdHRyaWJ1dGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgQ2xpcGJvYXJkID0gZnVuY3Rpb24oX0VtaXR0ZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIWZ1bmN0aW9uIF9pbmhlcml0cyhzdWJDbGFzcywgc3VwZXJDbGFzcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCJmdW5jdGlvbiIgIT0gdHlwZW9mIHN1cGVyQ2xhc3MgJiYgbnVsbCAhPT0gc3VwZXJDbGFzcykgdGhyb3cgbmV3IFR5cGVFcnJvcigiU3VwZXIgZXhwcmVzc2lvbiBtdXN0IGVpdGhlciBiZSBudWxsIG9yIGEgZnVuY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YkNsYXNzLnByb3RvdHlwZSA9IE9iamVjdC5jcmVhdGUoc3VwZXJDbGFzcyAmJiBzdXBlckNsYXNzLnByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBzdWJDbGFzcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICEwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEwCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSksIHN1cGVyQ2xhc3MgJiYgX3NldFByb3RvdHlwZU9mKHN1YkNsYXNzLCBzdXBlckNsYXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfShDbGlwYm9hcmQsIF9FbWl0dGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9zdXBlciA9IF9jcmVhdGVTdXBlcihDbGlwYm9hcmQpOwogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBDbGlwYm9hcmQodHJpZ2dlciwgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIF9jbGFzc0NhbGxDaGVjayhpbnN0YW5jZSwgQ29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShpbnN0YW5jZSBpbnN0YW5jZW9mIENvbnN0cnVjdG9yKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IGNhbGwgYSBjbGFzcyBhcyBhIGZ1bmN0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KHRoaXMsIENsaXBib2FyZCksIChfdGhpcyA9IF9zdXBlci5jYWxsKHRoaXMpKS5yZXNvbHZlT3B0aW9ucyhvcHRpb25zKSwgX3RoaXMubGlzdGVuQ2xpY2sodHJpZ2dlciksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIF9jcmVhdGVDbGFzcyhDb25zdHJ1Y3RvciwgcHJvdG9Qcm9wcywgc3RhdGljUHJvcHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm90b1Byb3BzICYmIF9kZWZpbmVQcm9wZXJ0aWVzKENvbnN0cnVjdG9yLnByb3RvdHlwZSwgcHJvdG9Qcm9wcyksIHN0YXRpY1Byb3BzICYmIF9kZWZpbmVQcm9wZXJ0aWVzKENvbnN0cnVjdG9yLCBzdGF0aWNQcm9wcyksIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0oQ2xpcGJvYXJkLCBbIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleTogInJlc29sdmVPcHRpb25zIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiByZXNvbHZlT3B0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIHZvaWQgMCAhPT0gYXJndW1lbnRzWzBdID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3Rpb24gPSAiZnVuY3Rpb24iID09IHR5cGVvZiBvcHRpb25zLmFjdGlvbiA/IG9wdGlvbnMuYWN0aW9uIDogdGhpcy5kZWZhdWx0QWN0aW9uLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRhcmdldCA9ICJmdW5jdGlvbiIgPT0gdHlwZW9mIG9wdGlvbnMudGFyZ2V0ID8gb3B0aW9ucy50YXJnZXQgOiB0aGlzLmRlZmF1bHRUYXJnZXQsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dCA9ICJmdW5jdGlvbiIgPT0gdHlwZW9mIG9wdGlvbnMudGV4dCA/IG9wdGlvbnMudGV4dCA6IHRoaXMuZGVmYXVsdFRleHQsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gIm9iamVjdCIgPT09IGNsaXBib2FyZF90eXBlb2Yob3B0aW9ucy5jb250YWluZXIpID8gb3B0aW9ucy5jb250YWluZXIgOiBkb2N1bWVudC5ib2R5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6ICJsaXN0ZW5DbGljayIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gbGlzdGVuQ2xpY2sodHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpczIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlzdGVuZXIgPSBsaXN0ZW5fZGVmYXVsdCgpKHRyaWdnZXIsICJjbGljayIsIChmdW5jdGlvbihlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdGhpczIub25DbGljayhlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleTogIm9uQ2xpY2siLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIG9uQ2xpY2soZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmlnZ2VyID0gZS5kZWxlZ2F0ZVRhcmdldCB8fCBlLmN1cnJlbnRUYXJnZXQsIGFjdGlvbiA9IHRoaXMuYWN0aW9uKHRyaWdnZXIpIHx8ICJjb3B5IiwgdGV4dCA9IGFjdGlvbnNfZGVmYXVsdCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogYWN0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IHRoaXMudGFyZ2V0KHRyaWdnZXIpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiB0aGlzLnRleHQodHJpZ2dlcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQodGV4dCA/ICJzdWNjZXNzIiA6ICJlcnJvciIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBhY3Rpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQ6IHRleHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXI6IHRyaWdnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyU2VsZWN0aW9uOiBmdW5jdGlvbiBjbGVhclNlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIgJiYgdHJpZ2dlci5mb2N1cygpLCB3aW5kb3cuZ2V0U2VsZWN0aW9uKCkucmVtb3ZlQWxsUmFuZ2VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiAiZGVmYXVsdEFjdGlvbiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdEFjdGlvbih0cmlnZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGdldEF0dHJpYnV0ZVZhbHVlKCJhY3Rpb24iLCB0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiAiZGVmYXVsdFRhcmdldCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdFRhcmdldCh0cmlnZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdG9yID0gZ2V0QXR0cmlidXRlVmFsdWUoInRhcmdldCIsIHRyaWdnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3RvcikgcmV0dXJuIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3Ioc2VsZWN0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6ICJkZWZhdWx0VGV4dCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdFRleHQodHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRBdHRyaWJ1dGVWYWx1ZSgidGV4dCIsIHRyaWdnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6ICJkZXN0cm95IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlzdGVuZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IF0sIFsgewogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiAiY29weSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gY29weSh0YXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIHZvaWQgMCAhPT0gYXJndW1lbnRzWzFdID8gYXJndW1lbnRzWzFdIDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IGRvY3VtZW50LmJvZHkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhY3Rpb25zX2NvcHkodGFyZ2V0LCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiAiY3V0IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBjdXQodGFyZ2V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFjdGlvbnNfY3V0KHRhcmdldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleTogImlzU3VwcG9ydGVkIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBpc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYWN0aW9uID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgdm9pZCAwICE9PSBhcmd1bWVudHNbMF0gPyBhcmd1bWVudHNbMF0gOiBbICJjb3B5IiwgImN1dCIgXSwgYWN0aW9ucyA9ICJzdHJpbmciID09IHR5cGVvZiBhY3Rpb24gPyBbIGFjdGlvbiBdIDogYWN0aW9uLCBzdXBwb3J0ID0gISFkb2N1bWVudC5xdWVyeUNvbW1hbmRTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFjdGlvbnMuZm9yRWFjaCgoZnVuY3Rpb24oYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnQgPSBzdXBwb3J0ICYmICEhZG9jdW1lbnQucXVlcnlDb21tYW5kU3VwcG9ydGVkKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpLCBzdXBwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IF0pLCBDbGlwYm9hcmQ7CiAgICAgICAgICAgICAgICAgICAgfSh0aW55X2VtaXR0ZXJfZGVmYXVsdCgpKSwgY2xpcGJvYXJkID0gQ2xpcGJvYXJkOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIDgyODogZnVuY3Rpb24obW9kdWxlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCJ1bmRlZmluZWQiICE9IHR5cGVvZiBFbGVtZW50ICYmICFFbGVtZW50LnByb3RvdHlwZS5tYXRjaGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcm90byA9IEVsZW1lbnQucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgICAgICBwcm90by5tYXRjaGVzID0gcHJvdG8ubWF0Y2hlc1NlbGVjdG9yIHx8IHByb3RvLm1vek1hdGNoZXNTZWxlY3RvciB8fCBwcm90by5tc01hdGNoZXNTZWxlY3RvciB8fCBwcm90by5vTWF0Y2hlc1NlbGVjdG9yIHx8IHByb3RvLndlYmtpdE1hdGNoZXNTZWxlY3RvcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiBjbG9zZXN0KGVsZW1lbnQsIHNlbGVjdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoO2VsZW1lbnQgJiYgOSAhPT0gZWxlbWVudC5ub2RlVHlwZTsgKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoImZ1bmN0aW9uIiA9PSB0eXBlb2YgZWxlbWVudC5tYXRjaGVzICYmIGVsZW1lbnQubWF0Y2hlcyhzZWxlY3RvcikpIHJldHVybiBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQucGFyZW50Tm9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgNDM4OiBmdW5jdGlvbihtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewogICAgICAgICAgICAgICAgICAgIHZhciBjbG9zZXN0ID0gX193ZWJwYWNrX3JlcXVpcmVfXyg4MjgpOwogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kZWxlZ2F0ZShlbGVtZW50LCBzZWxlY3RvciwgdHlwZSwgY2FsbGJhY2ssIHVzZUNhcHR1cmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxpc3RlbmVyRm4gPSBsaXN0ZW5lci5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKHR5cGUsIGxpc3RlbmVyRm4sIHVzZUNhcHR1cmUpLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0cm95OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIodHlwZSwgbGlzdGVuZXJGbiwgdXNlQ2FwdHVyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGxpc3RlbmVyKGVsZW1lbnQsIHNlbGVjdG9yLCB0eXBlLCBjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24oZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZS5kZWxlZ2F0ZVRhcmdldCA9IGNsb3Nlc3QoZS50YXJnZXQsIHNlbGVjdG9yKSwgZS5kZWxlZ2F0ZVRhcmdldCAmJiBjYWxsYmFjay5jYWxsKGVsZW1lbnQsIGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIGRlbGVnYXRlKGVsZW1lbnRzLCBzZWxlY3RvciwgdHlwZSwgY2FsbGJhY2ssIHVzZUNhcHR1cmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICJmdW5jdGlvbiIgPT0gdHlwZW9mIGVsZW1lbnRzLmFkZEV2ZW50TGlzdGVuZXIgPyBfZGVsZWdhdGUuYXBwbHkobnVsbCwgYXJndW1lbnRzKSA6ICJmdW5jdGlvbiIgPT0gdHlwZW9mIHR5cGUgPyBfZGVsZWdhdGUuYmluZChudWxsLCBkb2N1bWVudCkuYXBwbHkobnVsbCwgYXJndW1lbnRzKSA6ICgic3RyaW5nIiA9PSB0eXBlb2YgZWxlbWVudHMgJiYgKGVsZW1lbnRzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbChlbGVtZW50cykpLCAKICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLm1hcC5jYWxsKGVsZW1lbnRzLCAoZnVuY3Rpb24oZWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kZWxlZ2F0ZShlbGVtZW50LCBzZWxlY3RvciwgdHlwZSwgY2FsbGJhY2ssIHVzZUNhcHR1cmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9KSkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgODc5OiBmdW5jdGlvbihfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgewogICAgICAgICAgICAgICAgICAgIGV4cG9ydHMubm9kZSA9IGZ1bmN0aW9uKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2b2lkIDAgIT09IHZhbHVlICYmIHZhbHVlIGluc3RhbmNlb2YgSFRNTEVsZW1lbnQgJiYgMSA9PT0gdmFsdWUubm9kZVR5cGU7CiAgICAgICAgICAgICAgICAgICAgfSwgZXhwb3J0cy5ub2RlTGlzdCA9IGZ1bmN0aW9uKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZvaWQgMCAhPT0gdmFsdWUgJiYgKCJbb2JqZWN0IE5vZGVMaXN0XSIgPT09IHR5cGUgfHwgIltvYmplY3QgSFRNTENvbGxlY3Rpb25dIiA9PT0gdHlwZSkgJiYgImxlbmd0aCIgaW4gdmFsdWUgJiYgKDAgPT09IHZhbHVlLmxlbmd0aCB8fCBleHBvcnRzLm5vZGUodmFsdWVbMF0pKTsKICAgICAgICAgICAgICAgICAgICB9LCBleHBvcnRzLnN0cmluZyA9IGZ1bmN0aW9uKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAic3RyaW5nIiA9PSB0eXBlb2YgdmFsdWUgfHwgdmFsdWUgaW5zdGFuY2VvZiBTdHJpbmc7CiAgICAgICAgICAgICAgICAgICAgfSwgZXhwb3J0cy5mbiA9IGZ1bmN0aW9uKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiW29iamVjdCBGdW5jdGlvbl0iID09PSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwodmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgMzcwOiBmdW5jdGlvbihtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewogICAgICAgICAgICAgICAgICAgIHZhciBpcyA9IF9fd2VicGFja19yZXF1aXJlX18oODc5KSwgZGVsZWdhdGUgPSBfX3dlYnBhY2tfcmVxdWlyZV9fKDQzOCk7CiAgICAgICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiBsaXN0ZW4odGFyZ2V0LCB0eXBlLCBjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRhcmdldCAmJiAhdHlwZSAmJiAhY2FsbGJhY2spIHRocm93IG5ldyBFcnJvcigiTWlzc2luZyByZXF1aXJlZCBhcmd1bWVudHMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpcy5zdHJpbmcodHlwZSkpIHRocm93IG5ldyBUeXBlRXJyb3IoIlNlY29uZCBhcmd1bWVudCBtdXN0IGJlIGEgU3RyaW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXMuZm4oY2FsbGJhY2spKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJUaGlyZCBhcmd1bWVudCBtdXN0IGJlIGEgRnVuY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzLm5vZGUodGFyZ2V0KSkgcmV0dXJuIGZ1bmN0aW9uIGxpc3Rlbk5vZGUobm9kZSwgdHlwZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBub2RlLmFkZEV2ZW50TGlzdGVuZXIodHlwZSwgY2FsbGJhY2spLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdHJveTogZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUucmVtb3ZlRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSh0YXJnZXQsIHR5cGUsIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzLm5vZGVMaXN0KHRhcmdldCkpIHJldHVybiBmdW5jdGlvbiBsaXN0ZW5Ob2RlTGlzdChub2RlTGlzdCwgdHlwZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBBcnJheS5wcm90b3R5cGUuZm9yRWFjaC5jYWxsKG5vZGVMaXN0LCAoZnVuY3Rpb24obm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYWRkRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0cm95OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLmZvckVhY2guY2FsbChub2RlTGlzdCwgKGZ1bmN0aW9uKG5vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUucmVtb3ZlRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9KHRhcmdldCwgdHlwZSwgY2FsbGJhY2spOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXMuc3RyaW5nKHRhcmdldCkpIHJldHVybiBmdW5jdGlvbiBsaXN0ZW5TZWxlY3RvcihzZWxlY3RvciwgdHlwZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWxlZ2F0ZShkb2N1bWVudC5ib2R5LCBzZWxlY3RvciwgdHlwZSwgY2FsbGJhY2spOwogICAgICAgICAgICAgICAgICAgICAgICB9KHRhcmdldCwgdHlwZSwgY2FsbGJhY2spOwogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJGaXJzdCBhcmd1bWVudCBtdXN0IGJlIGEgU3RyaW5nLCBIVE1MRWxlbWVudCwgSFRNTENvbGxlY3Rpb24sIG9yIE5vZGVMaXN0Iik7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICA4MTc6IGZ1bmN0aW9uKG1vZHVsZSkgewogICAgICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gc2VsZWN0KGVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdGVkVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCJTRUxFQ1QiID09PSBlbGVtZW50Lm5vZGVOYW1lKSBlbGVtZW50LmZvY3VzKCksIHNlbGVjdGVkVGV4dCA9IGVsZW1lbnQudmFsdWU7IGVsc2UgaWYgKCJJTlBVVCIgPT09IGVsZW1lbnQubm9kZU5hbWUgfHwgIlRFWFRBUkVBIiA9PT0gZWxlbWVudC5ub2RlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGlzUmVhZE9ubHkgPSBlbGVtZW50Lmhhc0F0dHJpYnV0ZSgicmVhZG9ubHkiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVhZE9ubHkgfHwgZWxlbWVudC5zZXRBdHRyaWJ1dGUoInJlYWRvbmx5IiwgIiIpLCBlbGVtZW50LnNlbGVjdCgpLCBlbGVtZW50LnNldFNlbGVjdGlvblJhbmdlKDAsIGVsZW1lbnQudmFsdWUubGVuZ3RoKSwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlYWRPbmx5IHx8IGVsZW1lbnQucmVtb3ZlQXR0cmlidXRlKCJyZWFkb25seSIpLCBzZWxlY3RlZFRleHQgPSBlbGVtZW50LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5oYXNBdHRyaWJ1dGUoImNvbnRlbnRlZGl0YWJsZSIpICYmIGVsZW1lbnQuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzZWxlY3Rpb24gPSB3aW5kb3cuZ2V0U2VsZWN0aW9uKCksIHJhbmdlID0gZG9jdW1lbnQuY3JlYXRlUmFuZ2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlLnNlbGVjdE5vZGVDb250ZW50cyhlbGVtZW50KSwgc2VsZWN0aW9uLnJlbW92ZUFsbFJhbmdlcygpLCBzZWxlY3Rpb24uYWRkUmFuZ2UocmFuZ2UpLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVGV4dCA9IHNlbGVjdGlvbi50b1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZWxlY3RlZFRleHQ7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAyNzk6IGZ1bmN0aW9uKG1vZHVsZSkgewogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIEUoKSB7fQogICAgICAgICAgICAgICAgICAgIEUucHJvdG90eXBlID0gewogICAgICAgICAgICAgICAgICAgICAgICBvbjogZnVuY3Rpb24obmFtZSwgY2FsbGJhY2ssIGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLmUgfHwgKHRoaXMuZSA9IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoZVtuYW1lXSB8fCAoZVtuYW1lXSA9IFtdKSkucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm46IGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eDogY3R4CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSwgdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgb25jZTogZnVuY3Rpb24obmFtZSwgY2FsbGJhY2ssIGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gbGlzdGVuZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5vZmYobmFtZSwgbGlzdGVuZXIpLCBjYWxsYmFjay5hcHBseShjdHgsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbGlzdGVuZXIuXyA9IGNhbGxiYWNrLCB0aGlzLm9uKG5hbWUsIGxpc3RlbmVyLCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBlbWl0OiBmdW5jdGlvbihuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBkYXRhID0gW10uc2xpY2UuY2FsbChhcmd1bWVudHMsIDEpLCBldnRBcnIgPSAoKHRoaXMuZSB8fCAodGhpcy5lID0ge30pKVtuYW1lXSB8fCBbXSkuc2xpY2UoKSwgaSA9IDAsIGxlbiA9IGV2dEFyci5sZW5ndGg7IGkgPCBsZW47IGkrKykgZXZ0QXJyW2ldLmZuLmFwcGx5KGV2dEFycltpXS5jdHgsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG9mZjogZnVuY3Rpb24obmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5lIHx8ICh0aGlzLmUgPSB7fSksIGV2dHMgPSBlW25hbWVdLCBsaXZlRXZlbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZ0cyAmJiBjYWxsYmFjaykgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGV2dHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIGV2dHNbaV0uZm4gIT09IGNhbGxiYWNrICYmIGV2dHNbaV0uZm4uXyAhPT0gY2FsbGJhY2sgJiYgbGl2ZUV2ZW50cy5wdXNoKGV2dHNbaV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpdmVFdmVudHMubGVuZ3RoID8gZVtuYW1lXSA9IGxpdmVFdmVudHMgOiBkZWxldGUgZVtuYW1lXSwgdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0sIG1vZHVsZS5leHBvcnRzID0gRSwgbW9kdWxlLmV4cG9ydHMuVGlueUVtaXR0ZXIgPSBFOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LCBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX18gPSB7fTsKICAgICAgICAgICAgZnVuY3Rpb24gX193ZWJwYWNrX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAgICAgaWYgKF9fd2VicGFja19tb2R1bGVfY2FjaGVfX1ttb2R1bGVJZF0pIHJldHVybiBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdLmV4cG9ydHM7CiAgICAgICAgICAgICAgICB2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgICAgICBleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHJldHVybiBfX3dlYnBhY2tfbW9kdWxlc19fW21vZHVsZUlkXShtb2R1bGUsIG1vZHVsZS5leHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSwgCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0czsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gX193ZWJwYWNrX3JlcXVpcmVfXy5uID0gZnVuY3Rpb24obW9kdWxlKSB7CiAgICAgICAgICAgICAgICB2YXIgZ2V0dGVyID0gbW9kdWxlICYmIG1vZHVsZS5fX2VzTW9kdWxlID8gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1vZHVsZS5kZWZhdWx0OwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBtb2R1bGU7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgcmV0dXJuIF9fd2VicGFja19yZXF1aXJlX18uZChnZXR0ZXIsIHsKICAgICAgICAgICAgICAgICAgICBhOiBnZXR0ZXIKICAgICAgICAgICAgICAgIH0pLCBnZXR0ZXI7CiAgICAgICAgICAgIH0sIF9fd2VicGFja19yZXF1aXJlX18uZCA9IGZ1bmN0aW9uKGV4cG9ydHMsIGRlZmluaXRpb24pIHsKICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBkZWZpbml0aW9uKSBfX3dlYnBhY2tfcmVxdWlyZV9fLm8oZGVmaW5pdGlvbiwga2V5KSAmJiAhX193ZWJwYWNrX3JlcXVpcmVfXy5vKGV4cG9ydHMsIGtleSkgJiYgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsIGtleSwgewogICAgICAgICAgICAgICAgICAgIGVudW1lcmFibGU6ICEwLAogICAgICAgICAgICAgICAgICAgIGdldDogZGVmaW5pdGlvbltrZXldCiAgICAgICAgICAgIC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CAwOwogICAgdmFyIEFyaWFDb25maWcgPSBmdW5jdGlvbiBBcmlhQ29uZmlnKCkge307CiAgICBleHBvcnRzLkFyaWFDb25maWcgPSBBcmlhQ29uZmlnOwp9LCBmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMpIHsKICAgIG1vZHVsZS5leHBvcnRzID0gbWR1aTsKfSwgZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCB7CiAgICAgICAgdmFsdWU6ICEwCiAgICB9KSwgZXhwb3J0cy5VcmwgPSB2b2lkIDA7CiAgICB2YXIgVXJsID0gZnVuY3Rpb24oKSB7CiAgICAgICAgZnVuY3Rpb24gVXJsKCkge30KICAgICAgICByZXR1cm4gVXJsLmdldCA9IGZ1bmN0aW9uKG5hbWUsIHVybCkgewogICAgICAgICAgICB2b2lkIDAgPT09IHVybCAmJiAodXJsID0gIiIpOwogICAgICAgICAgICB2YXIgcmVnID0gbmV3IFJlZ0V4cCgiKF58JikiICsgbmFtZSArICI9KFteJl0qKSgmfCQpIiwgImkiKSwgciA9ICh1cmwgfHwgd2luZG93LmxvY2F0aW9uLnNlYXJjaCkuc3Vic3RyKDEpLm1hdGNoKHJlZyk7CiAgICAgICAgICAgIHJldHVybiBudWxsICE9IHIgJiYgclsyXTsKICAgICAgICB9LCBVcmw7CiAgICB9KCk7CiAgICBleHBvcnRzLlVybCA9IFVybDsKfSBdKTs=
Add Comment
Please, Sign In to add comment