xiaomianao666

插件名:global_秒传链接提取

Dec 16th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_秒传链接提取@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUg56eS5Lyg6ZO+5o6l5o+Q5Y+WCi8vIEB2ZXJzaW9uIDIuNS4yCi8vIEBhdXRob3IgbWVuZ3pvbmVmaXJlCi8vIEBkZXNjcmlwdGlvbiDnlKjkuo7mj5Dlj5blkoznlJ/miJDnmb7luqbnvZHnm5jnp5LkvKDpk77mjqUKLy8gQGhvbWVwYWdlIGh0dHBzOi8vZ3JlYXN5Zm9yay5vcmcvemgtQ04vc2NyaXB0cy80MjQ1NzQKLy8gQHN1cHBvcnRVUkwgaHR0cHM6Ly9naXRodWIuY29tL21lbmd6b25lZmlyZS9yYXBpZC11cGxvYWQtdXNlcnNjcmlwdC9pc3N1ZXMKLy8gQG1hdGNoICo6Ly9wYW4uYmFpZHUuY29tL2Rpc2svaG9tZSoKLy8gQG1hdGNoICo6Ly9wYW4uYmFpZHUuY29tL2Rpc2svbWFpbioKLy8gQG1hdGNoICo6Ly95dW4uYmFpZHUuY29tL2Rpc2svaG9tZSoKLy8gQG1hdGNoICo6Ly95dW4uYmFpZHUuY29tL2Rpc2svbWFpbioKLy8gQG1hdGNoICo6Ly93YW5ncGFuLmJhaWR1LmNvbS9kaXNrL2hvbWUqCi8vIEBtYXRjaCAqOi8vd2FuZ3Bhbi5iYWlkdS5jb20vZGlzay9tYWluKgovLyBAbmFtZTplbiByYXBpZHVwbG9hZC11c2Vyc2NyaXB0Ci8vIEBsaWNlbnNlIEdQTHYzCi8vIEBpY29uIGRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQkFBQUFBUUNBWUFBQUFmOC85aEFBQUJCVWxFUVZSNEFaVFRKUkJVVVJUSDRUdER3WHVQZFByZ2Jo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RoLAogICAgICAgICAgICBzdGF0ZSA9IFsxNzMyNTg0MTkzLCAtMjcxNzMzODc5LCAtMTczMjU4NDE5NCwgMjcxNzMzODc4XSwKICAgICAgICAgICAgaSwKICAgICAgICAgICAgbGVuZ3RoLAogICAgICAgICAgICB0YWlsLAogICAgICAgICAgICB0bXAsCiAgICAgICAgICAgIGxvLAogICAgICAgICAgICBoaTsKCiAgICAgICAgZm9yIChpID0gNjQ7IGkgPD0gbjsgaSArPSA2NCkgewogICAgICAgICAgICBtZDVjeWNsZShzdGF0ZSwgbWQ1YmxrKHMuc3Vic3RyaW5nKGkgLSA2NCwgaSkpKTsKICAgICAgICB9CiAgICAgICAgcyA9IHMuc3Vic3RyaW5nKGkgLSA2NCk7CiAgICAgICAgbGVuZ3RoID0gcy5sZW5ndGg7CiAgICAgICAgdGFpbCA9IFswLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICAgICAgdGFpbFtpID4+IDJdIHw9IHMuY2hhckNvZGVBdChpKSA8PCAoKGkgJSA0KSA8PCAzKTsKICAgICAgICB9CiAgICAgICAgdGFpbFtpID4+IDJdIHw9IDB4ODAgPDwgKChpICUgNCkgPDwgMyk7CiAgICAgICAgaWYgKGkgPiA1NSkgewogICAgICAgICAgICBtZDVjeWNsZShzdGF0ZSwgdGFpbCk7CiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCAxNjsgaSArPSAxKSB7CiAgICAgICAgICAgICAgICB0YWlsW2ldID0gMDsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgLy8gQmV3YXJlIHRoYXQgdGhlIGZpbmFsIGxlbmd0aCBtaWdodCBub3QgZml0IGluIDMyIGJpdHMgc28gd2UgdGFrZSBjYXJlIG9mIHRoYXQKICAgICAgICB0bXAgPSBuICogODsKICAgICAgICB0bXAgPSB0bXAudG9TdHJpbmcoMTYpLm1hdGNoKC8oLio/KSguezAsOH0pJC8pOwogICAgICAgIGxvID0gcGFyc2VJbnQodG1wWzJdLCAxNik7CiAgICAgICAgaGkgPSBwYXJzZUludCh0bXBbMV0sIDE2KSB8fCAwOwoKICAgICAgICB0YWlsWzE0XSA9IGxvOwogICAgICAgIHRhaWxbMTVdID0gaGk7CgogICAgICAgIG1kNWN5Y2xlKHN0YXRlLCB0YWlsKTsKICAgICAgICByZXR1cm4gc3RhdGU7CiAgICB9CgogICAgZnVuY3Rpb24gbWQ1MV9hcnJheShhKSB7CiAgICAgICAgdmFyIG4gPSBhLmxlbmd0aCwKICAgICAgICAgICAgc3RhdGUgPSBbMTczMjU4NDE5MywgLTI3MTczMzg3OSwgLTE3MzI1ODQxOTQsIDI3MTczMzg3OF0sCiAgICAgICAgICAgIGksCiAgICAgICAgICAgIGxlbmd0aCwKICAgICAgICAgICAgdGFpbCwKICAgICAgICAgICAgdG1wLAogICAgICAgICAgICBsbywKICAgICAgICAgICAgaGk7CgogICAgICAgIGZvciAoaSA9IDY0OyBpIDw9IG47IGkgKz0gNjQpIHsKICAgICAgICAgICAgbWQ1Y3ljbGUoc3RhdGUsIG1kNWJsa19hcnJheShhLnN1YmFycmF5KGkgLSA2NCwgaSkpKTsKICAgICAgICB9CgogICAgICAgIC8vIE5vdCBzdXJlIGlmIGl0IGlzIGEgYnVnLCBob3dldmVyIElFMTAgd2lsbCBhbHdheXMgcHJvZHVjZSBhIHN1YiBhcnJheSBvZiBsZW5ndGggMQogICAgICAgIC8vIGNvbnRhaW5pbmcgdGhlIGxhc3QgZWxlbWVudCBvZiB0aGUgcGFyZW50IGFycmF5IGlmIHRoZSBzdWIgYXJyYXkgc3BlY2lmaWVkIHN0YXJ0cwogICAgICAgIC8vIGJleW9uZCB0aGUgbGVuZ3RoIG9mIHRoZSBwYXJlbnQgYXJyYXkgLSB3ZWlyZC4KICAgICAgICAvLyBodHRwczovL2Nvbm5lY3QubWlj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1Y3ljbGUoc3RhdGUsIHRhaWwpOwoKICAgICAgICByZXR1cm4gc3RhdGU7CiAgICB9CgogICAgZnVuY3Rpb24gcmhleChuKSB7CiAgICAgICAgdmFyIHMgPSAnJywKICAgICAgICAgICAgajsKICAgICAgICBmb3IgKGogPSAwOyBqIDwgNDsgaiArPSAxKSB7CiAgICAgICAgICAgIHMgKz0gaGV4X2NoclsobiA+PiAoaiAqIDggKyA0KSkgJiAweDBGXSArIGhleF9jaHJbKG4gPj4gKGogKiA4KSkgJiAweDBGXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHM7CiAgICB9CgogICAgZnVuY3Rpb24gaGV4KHgpIHsKICAgICAgICB2YXIgaTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgeC5sZW5ndGg7IGkgKz0gMSkgewogICAgICAgICAgICB4W2ldID0gcmhleCh4W2ldKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHguam9pbignJyk7CiAgICB9CgogICAgLy8gSW4gc29tZSBjYXNlcyB0aGUgZmFzdCBhZGQzMiBmdW5jdGlvbiBjYW5ub3QgYmUgdXNlZC4uCiAgICBpZiAoaGV4KG1kNTEoJ2hlbGxvJykpICE9PSAnNWQ0MTQwMmFiYzRiMmE3NmI5NzE5ZDkxMTAxN2M1OTInKSB7CiAgICAgICAgYWRkMzIgPSBmdW5jdGlvbiAoeCwgeSkgewogICAgICAgICAgICB2YXIgbHN3ID0gKHggJiAweEZGRkYpICsgKHkgJiAweEZGRkYpLAogICAgICAgICAgICAgICAgbXN3ID0gKHggPj4gMTYpICsgKHkgPj4gMTYpICsgKGxzdyA+PiAxNik7CiAgICAgICAgICAgIHJldHVybiAobXN3IDw8IDE2KSB8IChsc3cgJiAweEZGRkYpOwogICAgICAgIH07CiAgICB9CgogICAgLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgogICAgLyoqCiAgICAgKiBBcnJheUJ1ZmZlciBzbGljZSBwb2x5ZmlsbC4KICAgICAqCiAgICAgKiBAc2VlIGh0dHBzOi8vZ2l0aHViLmNvbS90dGF1YmVydC9ub2RlLWFycmF5YnVmZmVyLXNsaWNlCiAgICAgKi8KCiAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyICE9PSAndW5kZWZpbmVkJyAmJiAhQXJyYXlCdWZmZXIucHJvdG90eXBlLnNsaWNlKSB7CiAgICAgICAgKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgZnVuY3Rpb24gY2xhbXAodmFsLCBsZW5ndGgpIHsKICAgICAgICAgICAgICAgIHZhbCA9ICh2YWwgfCAwKSB8fCAwOwoKICAgICAgICAgICAgICAgIGlmICh2YWwgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE1hdGgubWF4KHZhbCArIGxlbmd0aCwgMCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgcmV0dXJuIE1hdGgubWluKHZhbCwgbGVuZ3RoKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgQXJyYXlCdWZmZXIucHJvdG90eXBlLnNsaWNlID0gZnVuY3Rpb24gKGZyb20sIHRvKSB7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoID0gdGhpcy5ieXRlTGVuZ3RoLAogICAgICAgICAgICAgICAgICAgIGJlZ2luID0gY2xhbXAoZnJvbSwgbGVuZ3RoKSwKICAgICAgICAgICAgICAgICAgICBlbmQgPSBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgbnVtLAogICAgICAgICAgICAgICAgICAgIHRhcmdldCwKICAgICAgICAgICAgICAgICAgICB0YXJnZXRBcnJheSwKICAgICAgICAgICAgICAgICAgICBzb3VyY2VBcnJheTsKCiAgICAgICAgICAgICAgICBpZiAodG8gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgIGVuZCA9IGNsYW1wKHRvLCBsZW5ndGgpOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIGlmIChiZWdpbiA+IGVuZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQXJyYXlCdWZmZXIoMCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgbnVtID0gZW5kIC0gYmVnaW47CiAgICAgICAgICAgICAgICB0YXJnZXQgPSBuZXcgQXJyYXlCdWZmZXIobnVtKTsKICAgICAgICAgICAgICAgIHRhcmdldEFycmF5ID0gbmV3IFVpbnQ4QXJyYXkodGFyZ2V0KTsKCiAgICAgICAgICAgICAgICBzb3VyY2VBcnJheSA9IG5ldyBVaW50OEFycmF5KHRoaXMsIGJlZ2luLCBudW0pOwogICAgICAgICAgICAgICAgdGFyZ2V0QXJyYXkuc2V0KHNvdXJjZUFycmF5KTsKCiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICB9OwogICAgICAgIH0pKCk7CiAgICB9CgogICAgLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgogICAgLyoqCiAgICAgKiBIZWxwZXJzLgogICAgICovCgogICAgZnVuY3Rpb24gdG9VdGY4KHN0cikgewogICAgICAgIGlmICgvW1x1MDA4MC1cdUZGRkZdLy50ZXN0KHN0cikpIHsKICAgICAgICAgICAgc3RyID0gdW5lc2NhcGUoZW5jb2RlVVJJQ29tcG9uZW50KHN0cikpOwogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIHN0cjsKICAgIH0KCiAgICBmdW5jdGlvbiB1dGY4U3RyMkFycmF5QnVmZmVyKHN0ciwgcmV0dXJuVUludDhBcnJheSkgewogICAgICAgIHZhciBsZW5ndGggPSBzdHIubGVuZ3RoLAogICAgICAgICAgIGJ1ZmYgPSBuZXcgQXJyYXlCdWZmZXIobGVuZ3RoKSwKICAgICAgICAgICBhcnIgPSBuZXcgVWludDhBcnJheShidWZmKSwKICAgICAgICAgICBpOwoKICAgICAgICBmb3IgK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ICAgICAqCiAgICAgKiBAcGFyYW0ge1N0cmluZ30gY29udGVudHMgVGhlIGJpbmFyeSBzdHJpbmcgdG8gYmUgYXBwZW5kZWQKICAgICAqCiAgICAgKiBAcmV0dXJuIHtTcGFya01ENX0gVGhlIGluc3RhbmNlIGl0c2VsZgogICAgICovCiAgICBTcGFya01ENS5wcm90b3R5cGUuYXBwZW5kQmluYXJ5ID0gZnVuY3Rpb24gKGNvbnRlbnRzKSB7CiAgICAgICAgdGhpcy5fYnVmZiArPSBjb250ZW50czsKICAgICAgICB0aGlzLl9sZW5ndGggKz0gY29udGVudHMubGVuZ3RoOwoKICAgICAgICB2YXIgbGVuZ3RoID0gdGhpcy5fYnVmZi5sZW5ndGgsCiAgICAgICAgICAgIGk7CgogICAgICAgIGZvciAoaSA9IDY0OyBpIDw9IGxlbmd0aDsgaSArPSA2NCkgewogICAgICAgICAgICBtZDVjeWNsZSh0aGlzLl9oYXNoLCBtZDVibGsodGhpcy5fYnVmZi5zdWJzdHJpbmcoaSAtIDY0LCBpKSkpOwogICAgICAgIH0KCiAgICAgICAgdGhpcy5fYnVmZiA9IHRoaXMuX2J1ZmYuc3Vic3RyaW5nKGkgLSA2NCk7CgogICAgICAgIHJldHVybiB0aGlzOwogICAgfTsKCiAgICAvKioKICAgICAqIEZpbmlzaGVzIHRoZSBpbmNyZW1lbnRhbCBjb21wdXRhdGlvbiwgcmVzZXRpbmcgdGhlIGludGVybmFsIHN0YXRlIGFuZAogICAgICogcmV0dXJuaW5nIHRoZSByZXN1bHQuCiAgICAgKgogICAgICogQHBhcmFtIHtCb29sZWFufSByYXcgVHJ1ZSB0byBnZXQgdGhlIHJhdyBzdHJpbmcsIGZhbHNlIHRvIGdldCB0aGUgaGV4IHN0cmluZwogICAgICoKICAgICAqIEByZXR1cm4ge1N0cmluZ30gVGhlIHJlc3VsdAogICAgICovCiAgICBTcGFya01ENS5wcm90b3R5cGUuZW5kID0gZnVuY3Rpb24gKHJhdykgewogICAgICAgIHZhciBidWZmID0gdGhpcy5fYnVmZiwKICAgICAgICAgICAgbGVuZ3RoID0gYnVmZi5sZW5ndGgsCiAgICAgICAgICAgIGksCiAgICAgICAgICAgIHRhaWwgPSBbMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMF0sCiAgICAgICAgICAgIHJldDsKCiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSArPSAxKSB7CiAgICAgICAgICAgIHRhaWxbaSA+PiAyXSB8PSBidWZmLmNoYXJDb2RlQXQoaSkgPDwgKChpICUgNCkgPDwgMyk7CiAgICAgICAgfQoKICAgICAgICB0aGlzLl9maW5pc2godGFpbCwgbGVuZ3RoKTsKICAgICAgICByZXQgPSBoZXgodGhpcy5faGFzaCk7CgogICAgICAgIGlmIChyYXcpIHsKICAgICAgICAgICAgcmV0ID0gaGV4VG9CaW5hcnlTdHJpbmcocmV0KTsKICAgICAgICB9CgogICAgICAgIHRoaXMucmVzZXQoKTsKCiAgICAgICAgcmV0dXJuIHJldDsKICAgIH07CgogICAgLyoqCiAgICAgKiBSZXNldHMgdGhlIGludGVybmFsIHN0YXRlIG9mIHRoZSBjb21wdXRhdGlvbi4KICAgICAqCiAgICAgKiBAcmV0dXJuIHtTcGFya01ENX0gVGhlIGluc3RhbmNlIGl0c2VsZgogICAgICovCiAgICBTcGFya01ENS5wcm90b3R5cGUucmVzZXQgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgdGhpcy5fYnVmZiA9ICcnOwogICAgICAgIHRoaXMuX2xlbmd0aCA9IDA7CiAgICAgICAgdGhpcy5faGFzaCA9IFsxNzMyNTg0MTkzLCAtMjcxNzMzODc5LCAtMTczMjU4NDE5NCwgMjcxNzMzODc4XTsKCiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICB9OwoKICAgIC8qKgogICAgICogR2V0cyB0aGUgaW50ZXJuYWwgc3RhdGUgb2YgdGhlIGNvbXB1dGF0aW9uLgogICAgICo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HRoaXMucmVtYWluaW5nOwogICAgfQoKICAgIHN0b3AoKSB7CiAgICAgIGlmICh0aGlzLnJ1bm5pbmcpIHsKICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5pZCk7CiAgICAgICAgdGhpcy5yZW1haW5pbmcgLT0gbmV3IERhdGUoKS5nZXRUaW1lKCkgLSB0aGlzLnN0YXJ0ZWQuZ2V0VGltZSgpOwogICAgICB9CgogICAgICByZXR1cm4gdGhpcy5yZW1haW5pbmc7CiAgICB9CgogICAgaW5jcmVhc2UobikgewogICAgICBjb25zdCBydW5uaW5nID0gdGhpcy5ydW5uaW5nOwoKICAgICAgaWYgKHJ1bm5pbmcpIHsKICAgICAgICB0aGlzLnN0b3AoKTsKICAgICAgfQoKICAgICAgdGhpcy5yZW1haW5pbmcgKz0gbjsKCiAgICAgIGlmIChydW5uaW5nKSB7CiAgICAgICAgdGhpcy5zdGFydCgpOwogICAgICB9CgogICAgICByZXR1cm4gdGhpcy5yZW1haW5pbmc7CiAgICB9CgogICAgZ2V0VGltZXJMZWZ0KCkgewogICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgdGhpcy5zdG9wKCk7CiAgICAgICAgdGhpcy5zdGFydCgpOwogICAgICB9CgogICAgICByZXR1cm4gdGhpcy5yZW1haW5pbmc7CiAgICB9CgogICAgaXNSdW5uaW5nKCkgewogICAgICByZXR1cm4gdGhpcy5ydW5uaW5nOwogICAgfQoKICB9CgogIGNvbnN0IGZpeFNjcm9sbGJhciA9ICgpID0+IHsKICAgIC8vIGZvciBxdWV1ZXMsIGRvIG5vdCBkbyB0aGlzIG1vcmUgdGhhbiBvbmNlCiAgICBpZiAoc3RhdGVzLnByZXZpb3VzQm9keVBhZGRpbmcgIT09IG51bGwpIHsKICAgICAgcmV0dXJuOwogICAgfSAvLyBpZiB0aGUgYm9keSBoYXMgb3ZlcmZsb3cKCgogICAgaWYgKGRvY3VtZ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AgICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXModGhpcywgewogICAgICAgIHBhcmFtczogewogICAgICAgICAgdmFsdWU6IG91dGVyUGFyYW1zLAogICAgICAgICAgd3JpdGFibGU6IGZhbHNlLAogICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgIH0KICAgICAgfSk7IC8vIEB0cy1pZ25vcmUKCiAgICAgIGNvbnN0IHByb21pc2UgPSBjdXJyZW50SW5zdGFuY2UuX21haW4oY3VycmVudEluc3RhbmNlLnBhcmFtcyk7CgogICAgICBwcml2YXRlUHJvcHMucHJvbWlzZS5zZXQodGhpcywgcHJvbWlzZSk7CiAgICB9CgogICAgX21haW4odXNlclBhcmFtcykgewogICAgICBsZXQgbWl4aW5QYXJhbXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHt9OwogICAgICBzaG93V2FybmluZ3NGb3JQYXJhbXMoT2JqZWN0LmFzc2lnbih7fSwgbWl4aW5QYXJhbXMsIHVzZXJQYXJhbXMpKTsKCiAgICAgIGlmIChnbG9iYWxTdGF0ZS5jdXJyZW50SW5zdGFuY2UpIHsKICAgICAgICAvLyBAdHMtaWdub3JlCiAgICAgICAgZ2xvYmFsU3RhdGUuY3VycmVudEluc3RhbmNlLl9kZXN0cm95KCk7CgogICAgICAgIGlmIChpc01vZGFsKCkpIHsKICAgICAgICAgIHVuc2V0QXJpYUhpZGRlbigpOwogICAgICAgIH0KICAgICAgfQoKICAgICAgZ2xvYmFsU3RhdGUuY3VycmVudEluc3RhbmNlID0gY3VycmVudEluc3RhbmNlOwogICAgICBjb25zdCBpbm5lclBhcmFtcyA9IHByZXBhcmVQYXJhbXModXNlclBhcmFtcywgbWl4aW5QYXJhbXMpOwogICAgICBzZXRQYXJhbWV0ZXJzKGlubmVyUGFyYW1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KICAgIGVsc2UgewogICAgICAgIHIgPSBEdVBhcnNlci5wYXJzZUR1X3Y0KHN6VXJsKTsKICAgICAgICByLnZlciA9ICLmoqblp6zmoIflh4YiOwogICAgfQogICAgcmV0dXJuIHI7Cn07CkR1UGFyc2VyLnBhcnNlRHVfdjEgPSBmdW5jdGlvbiBwYXJzZUR1X3YxKHN6VXJsKSB7CiAgICByZXR1cm4gc3pVcmwKICAgICAgICAucmVwbGFjZSgvXHMqYmRwYW46XC9cLy9nLCAiICIpCiAgICAgICAgLnRyaW0oKQogICAgICAgIC5zcGxpdCgiICIpCiAgICAgICAgLm1hcChmdW5jdGlvbiAoeikgewogICAgICAgIHJldHVybiB6CiAgICAgICAgICAgIC50cmltKCkKICAgICAgICAgICAgLmZyb21CYXNlNjQoKQogICAgICAgICAgICAubWF0Y2goLyhbXHNcU10rKVx8KFtcZF17MSwyMH0pXHwoW1xkYS1mXXszMn0pXHwoW1xkYS1mXXszMn0pL2kpOwogICAgfSkKICAgICAgICAuZmlsdGVyKGZ1bmN0aW9uICh6KSB7CiAgICAgICAgcmV0dXJuIHo7CiAgICB9KQogICAgICAgIC5tYXAoZnVuY3Rpb24gKGluZm8pIHsKICAgICAgICByZXR1cm4gewogICAgICAgICAgICBtZDU6IGluZm9bM10sCiAgICAgICAgICAgIG1kNXM6IGluZm9bNF0sCiAgICAgICAgICAgIHNpemU6IGluZm9bMl0sCiAgICAgICAgICAgIHBhdGg6IGluZm9bMV0sCiAgICAgICAgfTsKICAgIH0pOwp9OwpEdVBhcnNlci5wYXJzZUR1X3YyID0gZnVuY3Rpb24gcGFyc2VEdV92MihzelVybCkgewogICAgcmV0dXJuIHN6VXJsCiAgICAgICAgLnNwbGl0KCJcbiIpCiAgICAgICAgLm1hcChmdW5jdGlvbiAoeikgewogICAgICAgIC8vIHVuc2lnbmVkIGxvbmcgbG9uZzogMH4xODQ0Njc0NDA3MzcwOTU1MTYxNQogICAgICAgIHJldHVybiB6CiAgICAgICAgICAgIC50cmltKCkKICAgICAgICAgICAgLm1hdGNoKC8tbGVuZ3RoPShbXGRdezEsMjB9KSAtbWQ1PShbXGRhLWZdezMyfSkgLXNsaWNlbWQ1PShbXGRhLWZdezMyfSlbXHNcU10rIihbXHNcU10rKSIvaSk7CiAgICB9KQogICAgICAgIC5maWx0ZXIoZnVuY3Rpb24gKHopIHsKICAgICAgICByZXR1cm4gejsKICAgIH0pCiAgICAgICAgLm1hcChmdW5jdGlvbiAoaW5mbykgewogICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIG1kNTogaW5mb1syXSwKICAgICAgICAgICAgbWQ1czogaW5mb1szXSwKICAgICAgICAgICAgc2l6ZTogaW5mb1sxXSwKICAgICAgICAgICAgcGF0aDogaW5mb1s0XSwKICAgICAgICB9OwogICAgfSk7Cn07CkR1UGFyc2VyLnBhcnNlRHVfdjMgPSBmdW5jdGlvbiBwYXJzZUR1X3YzKHN6VXJsKSB7CiAgICB2YXIgcmF3ID0gYXRvYihzelVybC5zbGljZSg2KS5yZXBsYWNlKC9ccy9nLCAiIikpOwogICAgaWYgKHJhdy5zbGljZSgwLCA1KSAhPT0gIkJERlNceDAwIikgewogICAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgdmFyIGJ1ZiA9IG5ldyBTaW1wbGVCdWZmZXIocmF3KTsKICAgIHZhciBwdHIgPSA5OwogICAgdmFyIGFyckZpbGVzID0gW107CiAgICB2YXIgZmlsZUluZm8sIG5hbWVTaXplOwogICAgdmFyIHRvdGFsID0gYnVmLnJlYWRVSW50KDUpOwogICAgdmFyIGk7CiAgICBmb3IgKGkgPSAwOyBpIDwgdG90YWw7IGkrKykgewogICAgICAgIC8vIOWkp+WwjyAoOCBieXRlcykKICAgICAgICAvLyBNRDUgKyBNRDVTICgweDIwKQogICAgICAgIC8vIG5hbWVTaXplICg0IGJ5dGVzKQogICAgICAgIC8vIE5hbWUgKHVuaWNvZGUpCiAgICAgICAgZmlsZUluZm8gPSB7fTsKICAgICAgICBmaWxlSW5mby5zaXplID0gYnVmLnJlYWRVTG9uZyhwdHIgKyAwKTsKICAgICAgICBmaWxlSW5mby5tZDUgPSBidWYucmVhZEhleChwdHIgKyA4LCAweDEwKTsKICAgICAgICBmaWxlSW5mby5tZDVzID0gYnVmLnJlYWRIZXgocHRyICsgMHgxOCwgMHgxMCk7CiAgICAgICAgbmFtZVNpemUgPSBidWYucmVhZFVJbnQocHRyICsgMHgyOCkgPDwgMTsKICAgICAgICBmaWxlSW5mby5uYW1lU2l6ZSA9IG5hbWVTaXplOwogICAgICAgIHB0ciArPSAweDJjOwogICAgICAgIGZpbGVJbmZvLnBhdGggPSBidWYucmVhZFVuaWNvZGUocHRyLCBuYW1lU2l6ZSk7CiAgICAgICAgYXJyRmlsZXMucHVzaChmaWxlSW5mbyk7CiAgICAgICAgcHRyICs9IG5hbWVTaXplOwogICAgfQogICAgcmV0dXJuIGFyckZpbGVzOwp9OwpEdVBhcnNlci5wYXJzZUR1X3Y0ID0gZnVuY3Rpb24gcGFyc2VEdV92MyhzelVybCkgewogICAgcmV0dXJuIHN6VXJsCiAgICAgICAgLnNwbGl0KCJcbiIpCiAgICAgICAgLm1hcChmdW5jdGlvbiAoeikgewogICAgICAgIHJldHVybiB6CiAgICAgICAgICAgIC50cmltKCkKICAgICAgICAgICAgLm1hdGNoKC9eKFtcZGEtZl17OX1bXGRhLXpdW1xkYS1mXXsyMn0pIyg/OihbXGRhLWZdezMyfSkjKT8oW1xkXXsxLDIwfSkjKFtcc1xTXSspL2kpOyAvLyAyMi44LjI55paw5aKe5pSv5oyB56ysMTDkvY3kuLpnLXrnmoTliqDlr4ZtZDUsIOi+k+WFpeWQjuiHquWKqOino+Wvhui9rOWtmAogICAgfSkKICAgICAgICAuZmlsdGVyKGZ1bmN0aW9uICh6KSB7CiAgICAgICAgcmV0dXJuIHo7CiAgICB9KQogICAgICAgIC5tYXAoZnVuY3Rpb24gKGluZm8pIHsKICAgICAgICByZXR1cm4gewogICAgICAgICAgICAvLyDmoIflh4bnoI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0b25UZXh0OiAi5Y+W5raIIiwKICAgICAgICBpbnB1dFZhbGlkYXRvcjogZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgIGlmICghdmFsdWUpIHsKICAgICAgICAgICAgICAgIHJldHVybiAi5paH5Lu26Lev5b6E5LiN6IO95Li656m6IjsKICAgICAgICAgICAgfQogICAgICAgIH0sCiAgICB9LAogICAgdXBkYXRlSW5mbzogewogICAgICAgIHRpdGxlOiAiXHU3OUQyXHU0RjIwXHU5NEZFXHU2M0E1XHU2M0QwXHU1M0Q2IHYiICsgdmVyc2lvbiArICIgKCIgKyB1cGRhdGVEYXRlICsgIikiLAogICAgICAgIHNob3dDbG9zZUJ1dHRvbjogdHJ1ZSwKICAgICAgICBhbGxvd091dHNpZGVDbGljazogZmFsc2UsCiAgICAgICAgY29uZmlybUJ1dHRvblRleHQ6ICLnn6XpgZPkuoYiLAogICAgICAgIGh0bWw6ICh1cGRhdGVJbmZvX2RlZmF1bHQoKSksCiAgICB9LAogICAgY2hlY2tSZWN1cnNpdmU6IHsKICAgICAgICBpY29uOiAiaW5mbyIsCiAgICAgICAgdGl0bGU6ICLljIXlkKvmlofku7blpLksIOaYr+WQpumAkuW9kueUn+aIkD8iLAogICAgICAgIHRleHQ6ICLoi6XpgInmmK8sIOWwhuWQjOaXtueUn+aIkOWQhOe6p+WtkOaWh+S7tuWkueS4i+eahOaWh+S7tiIsCiAgICAgICAgYWxsb3dPdXRzaWRlQ2xpY2s6IGZhbHNlLAogICAgICAgIGZvY3VzQ2FuY2VsOiB0cnVlLAogICAgICAgIHNob3dDYW5jZWxCdXR0b246IHRydWUsCiAgICAgICAgcmV2ZXJzZUJ1dHRvbnM6IHRydWUsCiAgICAgICAgc2hvd0Nsb3NlQnV0dG9uOiB0cnVlLAogICAgICAgIGNvbmZpcm1CdXR0b25UZXh0OiAi5pivIiwKICAgICAgICBjYW5jZWxCdXR0b25UZXh0OiAi5ZCmIiwKICAgIH0sCiAgICBjaGVja01kNVdh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Lyg6L+b5YWl5pe2KSDku47liarotLTmnb/or7vlj5bmnInmlYjnmoTnp5LkvKDpk77mjqUKICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRWYWx1ZSA9IF9hLnNlbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2EubGFiZWwgPSAyOwogICAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICAgICAgcGF0aFZhbHVlID0gR01fZ2V0VmFsdWUoImxhc3RfZGlyIikgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZUNvbmZpcm0gPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDmiYvliqjor7vlj5ZNdWx0aXBsZSBpbnB1dHPlhoXnmoTmlbDmja4sIOeUseS6juacquiuvue9rmlucHV05Y+C5pWwLCDljp/nlJ9WYWxpZGF0b3LkuI3nlJ/mlYgsIOiHquihjOa3u+WKoFZhbGlkYXRvcumAu+i+kQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRWYWx1ZSA9ICQoIiNtemYtcmFwaWQtaW5wdXQiKVswXS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGhWYWx1ZSA9ICQoIiNtemYtcGF0aC1pbnB1dCIpWzBdLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dFZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dlZXRhbGVydDJfYWxsX2RlZmF1bHQoKS5zaG93VmFsaWRhdGlvbk1lc3NhZ2UoIuenkuS8oOS4jeiDveS4uuepuiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb21tYW5kTGlzdC5pbmNsdWRlcyhpbnB1dFZhbHVlLnRyaW0oKSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDovpPlhaXmlK/mjIHnmoTlkb3ku6QsIOi3s+WHuuajgOafpQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0VmFsdWUgPSBpbnB1dFZhbHVlLnRyaW0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUR1UGFyc2VyLnBhcnNlKGlucHV0VmFsdWUpLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3ZWV0YWxlcnQyX2FsbF9kZWZhdWx0KCkuc2hvd1ZhbGlkYXRpb25NZXNzYWdlKCI8cD5cdTY3MkFcdThCQzZcdTUyMkJcdTUyMzBcdTZCNjNcdTc4NkVcdTc2ODRcdTk0RkVcdTYzQTUgPGEgaHJlZj1cIiIgKyBkb2MubGlua1R5cGVEb2MgKyAiXCIgIiArIGxpbmtTdHlsZSArICI+XHU2N0U1XHU3NzBCXHU2NTJGXHU2MzAxXHU2ODNDXHU1RjBGPC9hPjwvcD4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFZhbHVlLm1hdGNoKGlsbGVnYWxQYXRoUGF0dGVybikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLnNob3dWYWxpZGF0aW9uTWVzc2FnZSgn5L+d5a2Y6Lev5b6E5LiN6IO95ZCr5pyJ5a2X56ymXFwiOio/PD58LCDnpLrkvovvvJovR1RBNS8nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbGxPcGVuID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgiI3N3YWwyLWh0bWwtY29udGFpbmVyIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY3NzKCJmb250LXNpemUiLCAiMXJlbSIpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNzcygiZGlzcGxheSIsICJncmlkIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuY3NzKCJtYXJnaW4iLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgiI216Zi1yYXBpZC1pbnB1dCIpWzBdLnZhbHVlID0gaW5wdXRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoIiNtemYtcGF0aC1pbnB1dCIpWzBdLnZhbHVlID0gcGF0aFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgiI216Zi1yYXBpZC1pbnB1dCIpLm9uKCJpbnB1dCIsIGZ1bmN0aW9uIChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBwYXJzZVF1ZXJ5TGluayhldmVudC50YXJnZXQudmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChEdVBhcnNlci5wYXJzZShyZXN1bHQpLmxlbmd0aCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gcmVzdWx0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7IC8vIOe7keWumui+k+WFpeahhuS6i+S7tiwg6L6T5YWl5LiA6ZSu56eS5Lyg5ZCO5bCd6K+V6L2s5o2i5Li65pmu6YCa56eS5LygCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3ZWV0YWxlcnQyX2FsbF9kZWZhdWx0KCkuZmlyZSh0aGlzLm1lcmdlQXJnKFN3YWxDb25maWcuaW5wdXRWaWV3LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmVDb25maXJtOiBwcmVDb25maXJtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbE9wZW46IHdpbGxPcGVuLAogICAgICAgICAgICAgICAgICAgICAgICB9KSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmlzQ29uZmlybWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0VmFsdWUgPT09ICJzZXQiKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5zZXR0aW5nVmlldygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKGlucHV0VmFsdWUgPT09ICJnZW4iKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5nZW5WaWV3KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAoaW5wdXRWYWx1ZSA9PT0gImluZm8iKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy51cGRhdGVJbmZvKGZ1bmN0aW9uICgpIHsgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnJhcGlkdXBsb2FkVGFzay5yZXNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5yYXBpZHVwbG9hZFRhc2suZmlsZUluZm9MaXN0ID0gRHVQYXJzZXIucGFyc2UoaW5wdXRWYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdNX3NldFZhbHVlKCJsYXN0X2RpciIsIHBhdGhWYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGF0aFZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDot6/lvoTnlZnnqboKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnJhcGlkdXBsb2FkVGFzay5pc0RlZmF1bHRQYXRoID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBub3dQYXRoID0gbG9jYXRpb24uaHJlZi5tYXRjaCgvcGF0aD0oLis/KSg/OiZ8JCkvKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChub3dQYXRoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGhWYWx1ZSA9IGRlY29kZVVSSUNvbXBvbmVudChub3dQYXRoWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoVmFsdWUgPSAiLyI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhWYWx1ZS5jaGFyQXQocGF0aFZhbHVlLmxlbmd0aCAtIDEpICE9PSAiLyIpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoVmFsdWUgKz0gIi8iOyAvLyDooaXlhajot6/lvoTnu5PlsL7nmoQgIi8iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJcdTc5RDJcdTRGMjBcdTY1ODdcdTRFRjZcdTRGRERcdTVCNThcdTUyMzA6ICIgKyBwYXRoVmFsdWUpOyAvLyBkZWJ1ZwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5yYXBpZHVwbG9hZFRhc2suc2F2ZVBhdGggPSBwYXRoVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnByb2Nlc3NWaWV3KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzIgLypyZXR1cm4qL107CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgfTsKICAgIC8vIOi9rOWtmC/nlJ/miJDov4fnqIvkuK3nmoTlvLnnqpcKICAgIFN3YWxiYXNlLnByb3RvdHlwZS5wcm9jZXNzVmlldyA9IGZ1bmN0aW9uIChpc0dlbikgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgdmFyIHN3YWxBcmcgPSB7CiAgICAgICAgICAgIHRpdGxlOiBpc0dlbgogICAgICAgICAgICAgICAgPyAi56eS5Lyg55Sf5oiQ5LitIgogICAgICAgICAgICAgICAgOiAiXHU2NTg3XHU0RUY2IiArICh0aGlzLnJhcGlkdXBsb2FkVGFzay5jaGVja01vZGUgPyAi5rWL6K+VIiA6ICLmj5Dlj5YiKSArICJcdTRFMkQiLAogICAgICAgICAgICBodG1sOiBpc0dlbgogICAgICAgICAgICAgICAgPyAiPHA+5q2j5Zyo55Sf5oiQ56ysIDxmaWxlX251bT4wPC9maWxlX251bT4g5LiqPC9wPjxwPjxnZW5fcHJvZz7mraPlnKjojrflj5bmlofku7bliJfooaguLi48L2dlbl9wcm9nPjwvcD4iCiAgICAgICAgICAgICAgICA6ICJcdTZCNjNcdTU3MjgiICsgKHRoaXMucmFwaWR1cGxvYWRUYXNrLmNoZWNrTW9kZSA/ICLmtYvor5UiIDogIui9rOWtmCIpICsgIlx1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HQ7CiAgICAgICAgaWYgKGlzR2VuKSB7CiAgICAgICAgICAgIHRoaXMucmFwaWR1cGxvYWRUYXNrLnJlc2V0KCk7CiAgICAgICAgICAgIHRoaXMucmFwaWR1cGxvYWRUYXNrLmZpbGVJbmZvTGlzdCA9IHBhcnNlUmVzdWx0LnN1Y2Nlc3NMaXN0OwogICAgICAgIH0KICAgICAgICB2YXIgY2hlY2tib3hBcmcgPSB7CiAgICAgICAgICAgIGlucHV0OiAiY2hlY2tib3giLAogICAgICAgICAgICBpbnB1dFZhbHVlOiBHTV9nZXRWYWx1ZSgid2l0aF9wYXRoIiksCiAgICAgICAgICAgIGlucHV0UGxhY2Vob2xkZXI6ICLlr7zlh7rmlofku7blpLnnm67lvZXnu5PmnoQiLAogICAgICAgIH07IC8vIOWFqOmDqOWksei0peS4jeaYvuekuuatpGNoZWNrYm94LCAyMi41LjIyOiDlhajpg6jlpLHotKXkuZ/mmL7npLoKICAgICAgICB2YXIgaHRtbCA9IChpc0dlbgogICAgICAgICAgICA/IChwYXJzZVJlc3VsdC5mYWlsTGlzdC5sZW5ndGggIT0gZmlsZUluZm9MaXN0Lmxlbmd0aAogICAgICAgICAgICAgICAgPyBodG1sQ2hlY2tNZDUKICAgICAgICAgICAgICAgIDogIiIpICsgLy8g5re75Yqg5rWL6K+V56eS5Lyg5YWl5Y+jLCDoi6Xlhajpg6jlpLHotKXliJnkuI3mt7vliqAKICAgICAgICAgICAgICAgIGh0bWxEb2N1bWVudCAvLyDmt7vliqDmlofmoaPlhaXlj6MKICAgICAgICAgICAgOiAiIikgKwogICAgICAgICAgICAocGFyc2VSZXN1bHQuaHRtbEluZm8gJiYgaXNHZW4gPyAiPHA+PGJyPjwvcD4iIDogIiIpICsKICAgICAgICAgICAgcGFyc2VSZXN1bHQuaHRtbEluZm87IC8vIOa3u+WKoOWksei0peWIl+ihqCwg55Sf5oiQ5qih5byP5LiL5re75Yqg6aG26YOo56m66KGM5YiG6ZqUCiAgICAgICAgdmFyIGh0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mFwaWR1cGxvYWRUYXNrLmNoZWNrTW9kZSkgJiYgY2hlY2tib3hBcmcpKSwgeyB3aWxsT3BlbjogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgaWYgKCFpc0dlbiAmJiAhX3RoaXMucmFwaWR1cGxvYWRUYXNrLmNoZWNrTW9kZSkKICAgICAgICAgICAgICAgICAgICBfdGhpcy5hZGRPcGVuRGlyQnRuKCk7IC8vIOi9rOWtmOaooeW8j+aXtua3u+WKoCAi5omT5byA55uu5b2VIiDmjInpkq4KICAgICAgICAgICAgICAgIGlmIChpc0dlbiB8fCBfdGhpcy5yYXBpZHVwbG9hZFRhc2suY2hlY2tNb2RlKQogICAgICAgICAgICAgICAgICAgIEdNX3NldFZhbHVlKCJ1bkNsb3NlIiwgdHJ1ZSk7IC8vIOeUn+aIkOaooeW8j+iuvue9rue7k+aenOeql+WPo+acquWFs+mXreeahOagh+iusAogICAgICAgICAgICB9LCBwcmVEZW55OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgd2l0aF9wYXRoID0gJCgiI3N3YWwyLWNoZWNrYm94IilbMF0uY2hlY2tlZDsKICAgICAgICAgICAgICAgIEdNX3NldFZhbHVlKCJ3aXRoX3BhdGgiLCB3aXRoX3BhdGgpOwogICAgICAgICAgICAgICAgaWYgKCF3aXRoX3BhdGgpCiAgICAgICAgICAgICAgICAgICAgR01fc2V0Q2xpcGJvYXJkKGJkbGlua1ByZWZpeCArIHBhcnNlUmVzdWx0LmJkY29kZS5yZXBsYWNlKC9cLy4rXC8vZywgIiIpLnRvQmFzZTY0KCkpOwogICAgICAgICAgICAgICAgLy8g5Y676Zmk55uu5b2V57uT5p6ELCDlubbovazmjaLkuLrkuIDplK7np5LkvKAKICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICBHTV9zZXRDbGlwYm9hcmQoYmRsaW5rUHJlZml4ICsgcGFyc2VSZXN1bHQuYmRjb2RlLnRvQmFzZTY0KCkpOyAvLyDovazmjaLkuLrkuIDplK7np5LkvKAKICAgICAgICAgICAgICAgIHN3ZWV0YWxlcnQyX2FsbF9kZWZhdWx0KCkuZ2V0RGVueUJ1dHRvbigpLmlubmVyVGV4dCA9ICLlpI3liLbmiJDlip8s54K55Ye75Y+z5LiK5YWz6ZetIjsKICAgICAgICAgICAgICAgIHZhciBmb290ZXIgPSBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmdldEZvb3RlcigpOwogICAgICAgICAgICAgICAgZm9vdGVyLmlubmVySFRNTCA9IGh0bWxBYm91dEJkbGluazsKICAgICAgICAgICAgICAgIGZvb3Rlci5zdHlsZS5kaXNwbGF5ID0gImZsZXgiOwogICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICB9LCBwcmVDb25maXJtOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoaXNHZW4gfHwgX3RoaXMucmFwaWR1cGxvYWRUYXNrLmNoZWNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgIC8vIOeUn+aIkC/mtYvor5XmqKHlvI8sICLlpI3liLbnp5LkvKDku6PnoIEi5oyJ6ZKuCiAgICAgICAgICAgICAgICAgICAgdmFyIHdpdGhfcGF0aCA9ICQoIiNzd2FsMi1jaGVja2JveCIpWzBdLmNoZWNrZWQ7CiAgICAgICAgICAgICAgICAgICAgR01fc2V0VmFsdWUoIndpdGhfcGF0aCIsIHdpdGhfcGF0aCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCF3aXRoX3BhdGgpCiAgICAgICAgICAgICAgICAgICAgICAgIEdNX3NldENsaXBib2FyZChwYXJzZVJlc3VsdC5iZGNvZGUucmVwbGFjZSgvXC8uK1wvL2csICIiKSk7CiAgICAgICAgICAgICAgICAgICAgLy8g5Y676Zmk56eS5Lyg6ZO+5o6l5Lit55qE55uu5b2V57uT5p6EKOS7heS/neeVmeaWh+S7tuWQjSkKICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIEdNX3NldENsaXBib2FyZChwYXJzZVJlc3VsdC5iZGNvZGUpOyAvLyDkv53nlZnlrozmlbTnmoTmlofku7bot6/lvoQKICAgICAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmdldENvbmZpcm1CdXR0b24oKS5pbm5lclRleHQgPSAi5aSN5Yi25oiQ5YqfLOeCueWHu+WPs+S4iuWFs+mXrSI7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgLy8g6L2s5a2Y5qih5byPLCAi56Gu5a6aIiDmjInpkq4KICAgICAgICAgICAgICAgICAgICByZWZyZXNoTGlzdCgpOyAvLyDosIPnlKjliLfmlrDmlofku7bliJfooajnmoTmlrnms5UKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IH0pOwogICAgICAgIHN3ZWV0YWxlcnQyX2FsbF9kZWZhdWx0KCkuZmlyZSh0aGlzLm1lcmdlQXJnKFN3YWxDb25maWcuZmluaXNoVmlldywgc3dhbEFyZykpLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkgewogICAgICAgICAgICBpZiAocmVzdWx0LmlzRGlzbWlzc2VkIHx8IHJlc3VsdC5kaXNtaXNzID09PSAoc3dlZXRhbGVydDJfYWxsX2RlZmF1bHQoKSkuRGlzbWlzc1JlYXNvbi5jbG9zZSkgewogICAgICAgICAgICAgICAgR01fZGVsZXRlVmFsdWUoInVuZmluaXNoIik7IC8vIOeCueWHu+S6huWPs+S4iuinkueahOWFs+mXreaMiemSriwg5riF6Zmk5Lu75Yqh6L+b5bqm5pWw5o2uCiAgICAgICAgICAgICAgICBHTV9zZXRWYWx1ZSgidW5DbG9zZSIsIGZhbHNlKTsKICAgICAgICAgICAgfQogICAgIC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AgICAgICAgICAgIC5jc3MoImZvbnQtc2l6ZSIsICIxcmVtIikKICAgICAgICAgICAgICAgIC5jc3MoImRpc3BsYXkiLCAiZ3JpZCIpCiAgICAgICAgICAgICAgICAuY3NzKCJtYXJnaW4iLCAiMCIpOwogICAgICAgICAgICAkKCIjbXpmLXRoZW1lIilbMF0udmFsdWUgPSBHTV9nZXRWYWx1ZSgic3dhbFRoZW1lcyIpIHx8ICJEZWZhdWx0IjsKICAgICAgICAgICAgJCgiI216Zi1saXN0ZW4tY2xpcGJvYXJkIilbMF0uY2hlY2tlZCA9IEJvb2xlYW4oR01fZ2V0VmFsdWUoImxpc3Rlbi1jbGlwYm9hcmQiKSk7CiAgICAgICAgICAgICQoIiNtemYtZmFzdC1nZW5lcmF0ZSIpWzBdLmNoZWNrZWQgPSBCb29sZWFuKEdNX2dldFZhbHVlKCJmYXN0LWdlbmVyYXRlIikpOwogICAgICAgIH07CiAgICAgICAgdmFyIHByZUNvbmZpcm0gPSBmdW5jdGlvbiAoKSB7IHJldHVybiBfX2F3YWl0ZXIoX3RoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBlcnJvcl8xOwogICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9hKSB7CiAgICAgICAgICAgICAgICBzd2l0Y2ggKF9hLmxhYmVsKSB7CiAgICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgICAgICAvLyDorr7nva7kuLvpopgKICAgICAgICAgICAgICAgICAgICAgICAgR01fc2V0VmFsdWUoInN3YWxUaGVtZXMiLCAkKCIjbXpmLXRoZW1lIilbMF0udmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISQoIiNtemYtbGlzdGVuLWNsaXBib2FyZCIpWzBdLmNoZWNrZWQpIHJldHVybiBbMyAvKmJyZWFrKi8sIDRdOwogICAgICAgICAgICAgICAgICAgICAgICBfYS5sYWJlbCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICBfYS50cnlzLnB1c2goWzEsIDMsICwgNF0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQgLyp5aWVsZCovLCBuYXZpZ2F0b3IuY2xpcGJvYXJkLnJlYWRUZXh0KCldOwogICAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICAgICAgX2Euc2VudCgpOwogICAgICAgICAgICAgICAgICAgICAgICBHTV9zZXRWYWx1ZSgibGlzdGVuLWNsaXBib2FyZCIsICQoIiNtemYtbGlzdGVuLWNsaXBib2FyZCIpWzBdLmNoZWNrZWQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzMgLypicmVhayovLCA0XTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yXzEgPSBfYS5zZW50KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dBbGVydChhcHBFcnJvci5DbGlwYm9hcmRQcmVtaXNzaW9uRXJyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyIC8qcmV0dXJuKi9dOwogICAgICAgICAgICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgICAgICAgICAgICAgLy8g6K6+572u5p6B6YCf55Sf5oiQLCDoi6XlvIDlkK/liJnlvLnlh7rmlofmnKzmj5DphpIKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCQoIiNtemYtZmFzdC1nZW5lcmF0ZSIpWzBdLmNoZWNrZWQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93QWxlcnQoYXBwV2FybmluZy5mYXN0R2VuZXJhdGVXYXJuKTsKICAgICAgICAgICAgICAgICAgICAgICAgR01fc2V0VmFsdWUoImZhc3QtZ2VuZXJhdGUiLCAkKCIjbXpmLWZhc3QtZ2VuZXJhdGUiKVswXS5jaGVja2VkKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyIC8qcmV0dXJuKi9dOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICB9KTsgfTsKICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmZpcmUodGhpcy5tZXJnZUFyZyhTd2FsQ29uZmlnLnNldHRpbmdWaWV3LCB7CiAgICAgICAgICAgIHdpbGxPcGVuOiB3aWxsT3BlbiwKICAgICAgICAgICAgcHJlQ29uZmlybTogcHJlQ29uZmlybSwKICAgICAgICB9KSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICAgIGlmIChyZXN1bHQuaXNDb25maXJtZWQpCiAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmZpcmUoX3RoaXMubWVyZ2VBcmcoU3dhbENvbmZpZy5zZXR0aW5nV2FybmluZykpOwogICAgICAgIH0pOwogICAgfTsKICAgIC8vIOeUn+aIkOmhtSAo6L6T5YWl6Lev5b6E5YiX6KGo6L+b6KGM56eS5Lyg55Sf5oiQKQogICAgU3dhbGJhc2UucHJvdG90eXBlLmdlblZpZXcgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmZpcmUodGhpcy5tZXJnZUFyZyhTd2FsQ29uZmlnLmdlblZpZXcpKS50aGVuKGZ1bmN0aW9uIChyZXN1bHQpIHsKICAgICAgICAgICAgaWYgKHJlc3VsdC5pc0NvbmZpcm1lZCkgewogICAgICAgICAgICAgICAgX3RoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLnJlc2V0KCk7CiAgICAgICAgICAgICAgICByZXN1bHQudmFsdWUuc3BsaXQoIlxuIikuZm9yRWFjaChmdW5jdGlvbiAoaXRlbSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmNoYXJBdCgwKSAhPT0gIi8iKQogICAgICAgICAgICAgICAgICAgICAgICBpdGVtID0gIi8iICsgaXRlbTsKICAgICAgICAgICAgICAgICAgICBfdGhpcy5nZW5lcmF0ZWJkbGlua1Rhc2suZmlsZUluZm9MaXN0LnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBpdGVtLAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBfdGhpcy5wcm9jZXNzVmlldyh0cnVlKTsgLy8g5pi+56S66L+b5bqm5by556qXCiAgICAgICAgICAgICAgICBfdGhpcy5nZW5GaWxlV29yayhmYWxzZSwgdHJ1ZSk7IC8vIOi3s+i/h+iOt+WPlumAieaLqeaWh+S7tuWIl+ihqOWSjOaJq+aPj+aWh+S7tuWkueeahOatpemqpAogICAgICAgICAgICAgICAgX3RoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLmdlbmVyYXRlQmRsaW5rKDApOyAvLyDlvIDlp4vnlJ/miJDku7vliqEKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfTsKICAgIC8vIOeUn+aIkOenkuS8oOacquWujOaIkOS7u+WKoeaPkOekugogICAgU3dhbGJhc2UucHJvdG90eXBlLmdlblVuZmluaXNoID0gZnVuY3Rpb24gKG9uQ29uZmlybSwgb25DYW5jZWwpIHsKICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmZpcmUodGhpcy5tZXJnZUFyZyhHTV9nZXRWYWx1ZSgidW5DbG9zZSIpCiAgICAgICAgICAgID8gU3dhbENvbmZpZy5nZW5VbmZpbmlzaDIKICAgICAgICAgICAgOiBTd2FsQ29uZmlnLmdlblVuZmluaXNoKSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICAgIGlmIChyZXN1bHQuaXNDb25maXJtZWQpCiAgICAgICAgICAgICAgICBvbkNvbmZpcm0oKTsKICAgICAgICAgICAgZWxzZ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ICAgICAgICAgICBpZiAodGV4dCA9PT0gdm9pZCAwKSB7IHRleHQgPSAiIjsgfQogICAgICAgICAgICBpZiAodGV4dCkgewogICAgICAgICAgICAgICAgLy8g5pi+56S66Ieq5a6a5LmJ5paH5pysCiAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmdldEh0bWxDb250YWluZXIoKS5xdWVyeVNlbGVjdG9yKCJnZW5fcHJvZyIpLnRleHRDb250ZW50ID0gdGV4dDsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIWUgfHwgdHlwZW9mIGUudG90YWwgIT09ICJudW1iZXIiKQogICAgICAgICAgICAgICAgcmV0dXJuOyAvLyDlj4LmlbDmlbDmja7kuI3mraPnoa4g6Lez6L+HCiAgICAgICAgICAgIHN3ZWV0YWxlcnQyX2FsbF9kZWZhdWx0KCkuZ2V0SHRtbENvbnRhaW5lcigpLnF1ZXJ5U2VsZWN0b3IoImdlbl9wcm9nIikudGV4dENvbnRlbnQgPSAoKGUubG9hZGVkIC8gZS50b3RhbCkgKgogICAgICAgICAgICAgICAgMTAwKS50b0ZpeGVkKCkgKyAiJSI7CiAgICAgICAgfTsKICAgICAgICB0aGlzLmdlbmVyYXRlYmRsaW5rVGFzay5vbkhhc05vRGlyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICBfdGhpcy5wcm9jZXNzVmlldyh0cnVlKTsKICAgICAgICAgICAgX3RoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLmdlbmVyYXRlQmRsaW5rKDApOwogICAgICAgIH07CiAgICAgICAgdGhpcy5nZW5lcmF0ZWJkbGlua1Rhc2sub25IYXNEaXIgPSBmdW5jdGlvbiAoKSB7IHJldHVybiBfdGhpcy5jaGVja1JlY3Vyc2l2ZSgpOyB9OwogICAgICAgIHRoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLm9uRmluaXNoID0gZnVuY3Rpb24gKCkgeyByZXR1cm4gX3RoaXMuZmluaXNoVmlldyh0cnVlKTsgfTsKICAgICAgICBpZiAoIWlzVW5maW5pc2ggJiYgIWlzR2VuVmlldykKICAgICAgICAgICAgdGhpcy5nZW5lcmF0ZWJkbGlua1Rhc2suc3RhcnQoKTsgLy8g5omn6KGM5paw5Lu75Yqh5Yid5aeL5YyWCiAgICB9OwogICAgU3dhbGJhc2UucHJvdG90eXBlLmNoZWNrVW5maW5pc2ggPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICBpZiAoR01fZ2V0VmFsdWUoInVuZmluaXNoIikpIHsKICAgICAgICAgICAgdGhpcy5nZW5VbmZpbmlzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBfdGhpcy5wcm9jZXNzVmlldyh0cnVlKTsKICAgICAgICAgICAgICAgIF90aGlzLmdlbkZpbGVXb3JrKHRydWUsIGZhbHNlKTsKICAgICAgICAgICAgICAgIHZhciB1bmZpbmlzaEluZm8gPSBHTV9nZXRWYWx1ZSgidW5maW5pc2giKTsKICAgICAgICAgICAgICAgIF90aGlzLmdlbmVyYXRlYmRsaW5rVGFzay5maWxlSW5mb0xpc3QgPSB1bmZpbmlzaEluZm8uZmlsZV9pbmZvX2xpc3Q7CiAgICAgICAgICAgICAgICB1bmZpbmlzaEluZm8uaXNDaGVja01kNQogICAgICAgICAgICAgICAgICAgID8gX3RoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLmNoZWNrTWQ1KHVuZmluaXNoSW5mby5maWxlX2lkKQogICAgICAgICAgICAgICAgICAgIDogX3RoaXMuZ2VuZXJhdGViZGxpbmtUYXNrLmdlbmVyYXRlQmRsaW5rKHVuZmluaXNoSW5mby5maWxlX2lkKTsKICAgICAgICAgICAgfSwgLy8g56Gu6K6k57un57ut5pyq5a6M5oiQ5Lu75YqhCiAgICAgICAgICAgIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIEdNX2RlbGV0ZVZhbHVlKCJ1bmZpbmlzaCIpOwogICAgICAgICAgICAgICAgX3RoaXMuZ2VuRmlsZVdvcmsoZmFsc2UsIGZhbHNlKTsKICAgICAgICAgICAgfSAvLyDkuI3nu6fnu63mnKrlrozmiJDku7vliqEsIOa4hemZpOaVsOaNriwg5byA5ZCv5paw5Lu75YqhCiAgICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICB0aGlzLmdlbkZpbGVXb3JrKGZhbHNlLCBmYWxzZSk7CiAgICAgICAgfSAvLyDmsqHmnInmnKrlrozmiJDku7vliqEsIOebtOaOpeW8gOWQr+aWsOS7u+WKoQogICAgfTsKICAgIFN3YWxiYXNlLnByb3RvdHlwZS5jaGVja01kNSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIHRoaXMucmFwaWR1cGxvYWRUYXNrLmNoZWNrTW9kZSA9IHRydWU7CiAgICAgICAgaWYgKCFHTV9nZXRWYWx1ZSgiY2hlY2tfbWQ1X3dhcm5pbmciKSkgewogICAgICAgICAgICB0aGlzLmNoZWNrTWQ1V2FybmluZyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBfdGhpcy5wcm9jZXNzVmlldyhmYWxzZSk7CiAgICAgICAgICAgIH0sIC8vIOeCueWHu+ehruWumuaMiemSriwg5byA5aeL5rWL6K+V6L2s5a2YCiAgICAgICAgICAgIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIF90aGlzLmZpbmlzaFZpZXcodHJ1ZSk7CiAgICAgICAgICAgIH0gLy8g54K55Ye76L+U5Zue5oyJ6ZKuLCDlm57liLDnlJ/miJDlrozmiJDnmoTnlYzpnaIKICAgICAgICAgICAgKTsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgICAgICB0aGlzLnByb2Nlc3NWaWV3KGZhbHNlKTsgLy8g5bey5Yu+6YCJIuS4jeWGjeaPkOekuiIsIOebtOaOpeW8gOWni+a1i+ivlei9rOWtmAogICAgfTsKICAgIC8vIOa3u+WKoCAi5omT5byA55uu5b2VIiDmjInpkq4KICAgIFN3YWxiYXNlLnByb3RvdHlwZS5hZGRPcGVuRGlyQnRuID0gZnVuY3Rpb24gKCkgewogICAgICAgIGlmICghdGhpcy5yYXBpZHVwbG9hZFRhc2suaXNEZWZhdWx0UGF0aCkgewogICAgICAgICAgICB2YXIgX2Rpcl8xID0gKHRoaXMucmFwaWR1cGxvYWRUYXNrLnNhdmVQYXRoIHx8ICIiKS5yZXBsYWNlKC9cLyQvLCAiIik7IC8vIOWOu+mZpOi3r+W+hOe7k+WwvueahCIvIgogICAgICAgICAgICBpZiAoX2Rpcl8xLmNoYXJBdCgwKSAhPT0gIi8iKQogICAgICAgICAgICAgICAgX2Rpcl8xID0gIi8iICsgX2Rpcl8xOyAvLyDooaXpvZDot6/lvoTlvIDlpLTnmoQiLyIKICAgICAgICAgICAgdmFyIGNCdG4gPSBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmdldENvbmZpcm1CdXR0b24oKTsKICAgICAgICAgICAgdmFyIGJ0biA9IGNCdG4uY2xvbmVOb2RlKCk7CiAgICAgICAgICAgIGJ0bi50ZXh0Q29udGVudCA9ICLmiZPlvIDnm67lvZUiOwogICAgICAgICAgICBidG4uc3R5bGUuYmFja2dyb3VuZENvbG9yID0gIiNlY2FlM2MiOwogICAgICAgICAgICBidG4ub25jbGljayA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIHZhciBwYXRoID0gbG9jYXRpb24uaHJlZi5tYXRjaCgvKHBhdGg9KC4rPykpKD86JnwkKS8pOwogICAgICAgICAgICAgICAgaWYgKHBhdGgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFsyXSAhPT0gZW5jb2RlVVJJQ29tcG9uZW50KF9kaXJfMSkpCiAgICAgICAgICAgICAgICAgICAgICAgIGxvY2F0aW9uLmhyZWYgPSBsb2NhdGlvbi5ocmVmLnJlcGxhY2UoCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOS7heabv+aNonBhdGjlj4LmlbAsIOS4jeS/ruaUueWFtuS7luWPguaVsAogICAgICAgICAgICAgICAgICAgICAgICBwYXRoWzFdLCAicGF0aD0iICsgZW5jb2RlVVJJQ29tcG9uZW50KF9kaXJfMSkpOwogICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaExpc3QoKTsgLy8gcGF0aOWPguaVsOebuOWQjCwg5bey5Zyo55uu5qCH55uu5b2V5LiLLCDosIPnlKjliLfmlrDlh73mlbAKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgIHZhciBjb25uZWN0Q2hhciA9IGxvY2F0aW9uLmhyZWYuaW5jbHVkZXMoIj8iKSA/ICImIiA6ICI/IjsgLy8g56Gu5a6a5Y+C5pWw55qE6L+e5o6l56ymCiAgICAgICAgICAgICAgICAgICAgbG9jYXRpb24uaHJlZiArPSBjb25uZWN0Q2hhciArICJwYXRoPSIgKyBlbmNvZGVVUklDb21wb25lbnQoX2Rpcl8xKTsKICAgICAgICAgICAgICAgIH0gLy8g5rKh5pyJ5om+5YiwcGF0aOWPguaVsCwg55u05o6l5re75YqgCiAgICAgICAgICAgICAgICBzd2VldGFsZXJ0Ml9hbGxfZGVmYXVsdCgpLmNsb3NlKCk7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGNCdG4uYmVmb3JlKGJ0bik7CiAgICAgICAgfQogICAgfTsKICAgIHJldHVybiBTd2FsYmFzZTsKfSgpKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBjb25zdCBzd2FsQmFzZSA9IChTd2FsYmFzZSk7Cgo7Ly8gQ09OQ0FURU5BVEVEIE1PRFVMRTogLi9zcmMvY29tbW9uL2FqYXgudHN4Ci8qCiAqIEBBdXRob3I6IG1lbmd6b25lZmlyZQogKiBARGF0ZTogMjA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7IH07CiAgICB9OwogICAgUmFwaWR1cGxvYWRUYXNrLnByb3RvdHlwZS5zdGFydCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICBpZiAodGhpcy5jaGVja01vZGUpCiAgICAgICAgICAgIHRoaXMuc2F2ZVBhdGggPSAiIjsKICAgICAgICB0aGlzLnNhdmVGaWxlVjIoMCk7CiAgICB9OwogICAgLyoqCiAgICAgKiBAZGVzY3JpcHRpb246IOi9rOWtmOenkuS8oCDmjqXlj6MyCiAgICAgKiBAcGFyYW0ge251bWJlcn0gaQogICAgICovCiAgICBSYXBpZHVwbG9hZFRhc2sucHJvdG90eXBlLnNhdmVGaWxlVjIgPSBmdW5jdGlvbiAoaSkgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgaWYgKGkgPj0gdGhpcy5maWxlSW5mb0xpc3QubGVuZ3RoKSB7CiAgICAgICAgICAgIHRoaXMub25GaW5pc2godGhpcy5maWxlSW5mb0xpc3QpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMub25Qcm9jZXNzKGksIHRoaXMuZmlsZUluZm9MaXN0KTsKICAgICAgICB2YXIgZmlsZSA9IHRoaXMuZmlsZUluZm9MaXN0W2ldOwogICAgICAgIC8vIOaWh+S7tuWQjeWQq+aciemdnuazleWtl+espiAvIOaWh+S7tuWQjeS4uuepugogICAgICAgIGlmIChmaWxlLnBhdGgubWF0Y2goL1siXFxcOio/PD58XS8pIHx8IGZpbGUucGF0aCA9PT0gIi8iKSB7CiAgICAgICAgICAgIGZpbGUuZXJybm8gPSAtNzsKICAgICAgICAgICAgdGhpcy5zYXZlRmlsZVYyKGkgKyAxKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICB2YXIgb25GYWlsZWQgPSBmdW5jdGlvbiAoc3RhdHVzQ29kZSkgewogICAgICAgICAgICBmaWxlLmVycm5vID0gc3RhdHVzQ29kZTsKICAgICAgICAgICAgX3RoaXMuc2F2ZUZpbGVWMihpICsgMSk7CiAgICAgICAgfTsKICAgICAgICBwcmVjcmVhdGVGaWxlVjIuY2FsbCh0aGlzLCBmaWxlLCBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICBkYXRhID0gZGF0YS5yZXNwb25zZTsKICAgICAgICAgICAgaWYgKDAgPT09IGRhdGEuZXJybm8pIHsKICAgICAgICAgICAgICAgIGlmICgwID09PSBkYXRhLmJsb2NrX2xpc3QubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgX3RoaXMuY3JlYXRlRmlsZVYyKGZpbGUsIGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBkYXRhLnJlc3BvbnNlOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxlLmVycm5vID0gMiA9PT0gZGF0YS5lcnJubyA/IDExNCA6IGRhdGEuZXJybm87CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSAzMTE5MCA9PT0gZmlsZS5lcnJubyA/IDQwNCA6IGZpbGUuZXJybm87CiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnNhdmVGaWxlVjIoaSArIDEpOwogICAgICAgICAgICAgICAgICAgIH0sIG9uRmFpbGVkKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSA0MDQ7CiAgICAgICAgICAgICAgICAgICAgX3RoaXMuc2F2ZUZpbGVWMihpICsgMSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBmaWxlLmVycm5vID0gZGF0YS5lcnJubzsKICAgICAgICAgICAgICAgIF90aGlzLnNhdmVGaWxlVjIoaSArIDEpOwogICAgICAgICAgICB9CiAgICAgICAgfSwgb25GYWlsZWQpOwogICAgfTsKICAgIC8vIOatpOaOpeWPo+a1i+ivlee7k+aenOWmguS4izog6ZSZ6K+vbWQ1LT7ov5Tlm54iZXJybm8iOiAzMTE5MCwg5q2j56GubWQ1K+mUmeivr3NpemUtPui/lOWbniJlcnJubyI6IDIKICAgIC8vIOatpOWkliwg5Y2z5L2/bWQ15ZKMc2l6ZeWdh+ato+ehriwg6L+e57ut6K+35rGC5pe25L6d5pen5pyJ5bCP5qaC546H6L+U5ZueImVycm5vIjogMiwg5pWF5bu66K6u5Yqg5YWlcmV0cnnnrZbnlaUKICAgIFJhcGlkdXBsb2FkVGFzay5wcm90b3R5cGUuY3JlYXRlRmlsZVYyID0gZnVuY3Rpb24gKGZpbGUsIG9uUmVzcG9uc2VkLCBvbkZhaWxlZCwgcmV0cnkpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIGlmIChyZXRyeSA9PT0gdm9pZCAwKSB7IHJldHJ5ID0gMDsgfQogICAgICAgIGFqYXgoewogICAgICAgICAgICB1cmw6ICIiICsgY3JlYXRlX3VybCArICh0aGlzLmJkc3Rva2VuICYmICImYmRzdG9rZW49IiArIHRoaXMuYmRzdG9rZW4pLAogICAgICAgICAgICBtZXRob2Q6ICJQT1NUIiwKICAgICAgICAgICAgcmVzcG9uc2VUeXBlOiAianNvbiIsCiAgICAgICAgICAgIGRhdGE6IGNvbnZlcnREYXRhKHsKICAgICAgICAgICAgICAgIGJsb2NrX2xpc3Q6IEpTT04uc3RyaW5naWZ5KFtmaWxlLm1kNS50b0xvd2VyQ2FzZSgpXSksCiAgICAgICAgICAgICAgICBwYXRoOiB0aGlzLnNhdmVQYXRoICsgZmlsZS5wYXRoLAogICAgICAgICAgICAgICAgc2l6ZTogZmlsZS5zaXplLAogICAgICAgICAgICAgICAgaXNkaXI6IDAsCiAgICAgICAgICAgICAgICBydHlwZTogdGhpcy5jaGVja01vZGUgPyAzIDogMCwgLy8gcnR5cGU9M+imhuebluaWh+S7tiwgcnR5cGU9MOWImei/lOWbnuaKpemUmSwg5LiN6KaG55uW5paH5Lu2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oTliJ3lp4vljJbmraXpqqQg5omr5o+P6YCJ5oup55qE5paH5Lu25YiX6KGoCiAgICAgKi8KICAgIEdlbmVyYXRlYmRsaW5rVGFzay5wcm90b3R5cGUuc3RhcnQgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICB0aGlzLnNlbGVjdExpc3QuZm9yRWFjaChmdW5jdGlvbiAoaXRlbSkgewogICAgICAgICAgICBpZiAoaXRlbS5pc2RpcikKICAgICAgICAgICAgICAgIF90aGlzLmRpckxpc3QucHVzaChpdGVtLnBhdGgpOwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIF90aGlzLmZpbGVJbmZvTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICBwYXRoOiBpdGVtLnBhdGgsCiAgICAgICAgICAgICAgICAgICAgc2l6ZTogaXRlbS5zaXplLAogICAgICAgICAgICAgICAgICAgIGZzX2lkOiBpdGVtLmZzX2lkLAogICAgICAgICAgICAgICAgICAgIC8vIOW3suW8gOWQr+aegemAn+eUn+aIkCwg55u05o6l5Y+WbWV0YeWGheeahG1kNQogICAgICAgICAgICAgICAgICAgIG1kNTogX3RoaXMuaXNGYXN0ID8gZGVjcnlwdE1kNShpdGVtLm1kNS50b0xvd2VyQ2FzZSgpKSA6ICIiLAogICAgICAgICAgICAgICAgICAgIG1kNXM6ICIiLAogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBpZiAodGhpcy5kaXJMaXN0Lmxlbmd0aCkKICAgICAgICAgICAgdGhpcy5vbkhhc0RpcigpOwogICAgICAgIGVsc2UKICAgICAgICAgICAgdGhpcy5vbkhhc05vRGlyKCk7CiAgICB9OwogICAgLyoqCiAgICAgKiBAZGVzY3JpcHRpb246IOmAieaLqeeahOWIl+ihqOWMheWQq+aWh+S7tuWkuSwg6I635Y+W5paH5Lu25aS55LiL55qE5a2Q5paH5Lu2CiAgICAgKiBAcGFyYW0ge251bWJlcn0gaSDmnaHnm65pbmRleAogICAgICogQHBhcmFtIHtudW1iZXJ9IHN0YXJ0IOWIl+ihqOaOpeWPo+ajgOe0oui1t+eCuQogICAgICovCiAgICBHZW5lcmF0ZWJkbGlua1Rhc2sucHJvdG90eXBlLnNjYW5GaWxlID0gZnVuY3Rpb24gKGksIHN0YXJ0KSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICBpZiAoc3RhcnQgPT09IHZvaWQgMCkgeyBzdGFydCA9IDA7IH0KICAgICAgICBpZiAoaSA+PSB0aGlzLmRpckxpc3QubGVuZ3RoKSB7CiAgICAgICAgICAgIHRoaXMuZ2VuZXJhdGVCZGxpbmsoMCk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgYWpheCh7CiAgICAgICAgICAgIHVybDogbGlzdF91cmwgKyAiJnBhdGg9IiArIGVuY29kZVVSSUNvbXBvbmVudCh0aGlzLmRpckxpc3RbaV0pICsgIiZyZWN1cnNpb249IiArICh0aGlzLnJlY3Vyc2l2ZSA/IDEgOiAwKSArICImc3RhcnQ9IiArIHN0YXJ0LAogICAgICAgICAgICBtZXRob2Q6ICJHRVQiLAogICAgICAgICAgICByZXNwb25zZVR5cGU6ICJqc29uIiwKICAgICAgICB9LCAvLyBsaXN05o6l5Y+j6Ieq5bim6YCS5b2S5Y+C5pWwcmVjdXJzaW9uCiAgICAgICAgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgICAgICAgZGF0YSA9IGRhdGEucmVzcG9uc2U7CiAgICAgICAgICAgIGlmICghZGF0YS5lcnJubykgewogICAgICAgICAgICAgICAgaWYgKCFkYXRhLmxpc3QubGVuZ3RoKQogICAgICAgICAgICAgICAgICAgIF90aGlzLnNjYW5GaWxlKGkgKyAxKTsgLy8g6L+U5Zue5YiX6KGo5Li656m6LCDljbPmraTmlofku7blpLnmlofku7blhajpg6jmiavmj4/lrozmiJAKICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgIGRhdGEubGlzdC5mb3JFYWNoKGZ1bmN0aW9uIChpdGVtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW0uaXNkaXIgfHwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLmZpbGVJbmZvTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBpdGVtLnBhdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogaXRlbS5zaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZzX2lkOiBpdGVtLmZzX2lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1kNTogX3RoaXMuaXNGYXN0ID8gZGVjcnlwdE1kNShpdGVtLm1kNS50b0xvd2VyQ2FzZSgpKSA6ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1kNXM6ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7IC8vIOetm+mAieaWh+S7tihpc2Rpcj0wKQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIF90aGlzLnNjYW5GaWxlKGksIHN0YXJ0ICsgbGlzdExpbWl0KTsgLy8g5LuO5LiL5LiA5Liq6LW354K557un57ut5qOA57Si5YiX6KGoCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBfdGhpcy5maWxlSW5mb0xpc3QucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgcGF0aDogX3RoaXMuZGlyTGlzdFtpXSwKICAgICAgICAgICAgICAgICAgICBlcnJubzogZGF0YS5lcnJubywKICAgICAgICAgICAgICAgIH0pOyAvLyBsaXN05o6l5Y+j6K6/6Zeu5aSx6LSlLCDmt7vliqDlpLHotKXkv6Hmga8KICAgICAgICAgICAgICAgIF90aGlzLnNjYW5GaWxlKGkgKyAxKTsKICAgICAgICAgICAgfQogICAgICAgIH0sIGZ1bmN0aW9uIChzdGF0dXNDb2RlKSB7CiAgICAgICAgICAgIF90aGlzLmZpbGVJbmZvTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgIHBhdGg6IF90aGlzLmRpckxpc3RbaV0sCiAgICAgICAgICAgICAgICBlcnJubzogc3RhdHVzQ29kZSA9PT0gNTAwID8gOTAxIDogc3RhdHVzQ29kZSwKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIF90aGlzLnNjYW5GaWxlKGkgKyAxKTsKICAgICAgICB9KTsKICAgIH07CiAgICAvKioKICAgICAqIEBkZXNjcmlwdGlvbjog6aG65bqP5omn6KGM55Sf5oiQ5Lu75YqhCiAgICAgKiBAcGFyYW0ge251bWJlcn0gaQogICAgICovCiAgICBHZW5lcmF0ZWJkbGlua1Rhc2sucHJvdG90eXBlLmdlbmVyYXRlQmRsaW5rID0gZnVuY3Rpb24gKGkpIHsKICAgICAgICAvLyDkv53lrZjku7vliqHov5vluqbmlbDmja4KICAgICAgICBHTV9zZXRWYWx1ZSgidW5maW5pc2giLCB7CiAgICAgICAgICAgIGZpbGVfaW5mb19saXN0OiB0aGlzLmZpbGVJbmZvTGlzdCwKICAgICAgICAgICAgZmlsZV9pZDogaSwKICAgICAgICB9KTsKICAgICAgICAvLyDnlJ/miJDlrozmiJAKICAgICAgICBpZiAoaSA+PSB0aGlzLmZpbGVJbmZvTGlzdC5sZW5ndGgpIHsKICAgICAgICAgICAgaWYgKHRoaXMuaXNGYXN0KQogICAgICAgICAgICAgICAgdGhpcy5jaGVja01kNSgwKTsgLy8g5bey5byA5ZCvICLmnoHpgJ/nlJ/miJAiLCDmiafooYxtZDXmo4Dmn6UKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgdGhpcy5vbkZpbmlzaCh0aGlzLmZpbGVJbmZvTGlzdCk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgLy8g55Sf5oiQ6YC76L6RCiAgICAgICAgaWYgKCF0aGlzLmlzRmFzdCkKICAgICAgICAgICAgdGhpcy5vblByb2Nlc3MoaSwgdGhpcy5maWxlSW5mb0xpc3QpOyAvLyDmnKrlvIDlkK8gIuaegemAn+eUn+aIkCIsIOWIt+aWsOW8ueeql+WGheeahOS7u+WKoei/m+W6pgogICAgICAgIHZhciBmaWxlID0gdGhpcy5maWxlSW5mb0xpc3RbaV07CiAgICAgICAgLy8g6Lez6L+H5omr5o+P5aSx6LSl55qE55uu5b2V6Lev5b6ECiAgICAgICAgaWYgKGZpbGUuZXJybm8pIHsKICAgICAgICAgICAgdGhpcy5nZW5lcmF0ZUJkbGluayhpICsgMSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgLy8g5bey5byA5ZCvICLmnoHpgJ/nlJ/miJAiIOS4lOW3suiOt+WPluWIsG1kNSwg6Lez6L+H5pmu6YCa55Sf5oiQ5q2l6aqkCiAgICAgICAgaWYgKHRoaXMuaXNGYXN0ICYmIGZpbGUubWQ1KQogICAgICAgICAgICB0aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICAvLyDmma7pgJrnlJ/miJDmraXpqqQKICAgICAgICBlbHNlCiAgICAgICAgICAgIHRoaXMuZ2V0RGxpbmsoaSk7CiAgICB9OwogICAgLyoqCiAgICAgKiBAZGVzY3JpcHRpb246IOiOt+WPluaWh+S7tuS/oeaBrzogc2l6ZSwgbWQ1KOWPr+iDvemUmeivryksIGZzX2lkCiAgICAgKiBAcGFyYW0ge251bWJlcn0gaQogICAgICovCiAgICBHZW5lcmF0ZWJkbGlua1Rhc2sucHJvdG90eXBlLmdldEZpbGVJbmZvID0gZnVuY3Rpb24gKGkpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIHZhciBmaWxlID0gdGhpcy5maWxlSW5mb0xpc3RbaV07CiAgICAgICAgYWpheCh7CiAgICAgICAgICAgIHVybDogbWV0YV91cmwgKyBlbmNvZGVVUklDb21wb25lbnQoZmlsZS5wYXRoKSwKICAgICAgICAgICAgcmVzcG9uc2VUeXBlOiAianNvbiIsCiAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgfSwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgICAgICAgZGF0YSA9IGRhdGEucmVzcG9uc2U7CiAgICAgICAgICAgIGlmICghZGF0YS5lcnJubykgewogICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coZGF0YS5saXN0WzBdKTsgLy8gZGVidWcKICAgICAgICAgICAgICAgIGlmIChkYXRhLmxpc3RbMF0uaXNkaXIpIHsKICAgICAgICAgICAgICAgICAgICBmaWxlLmVycm5vID0gOTAwOwogICAgICAgICAgICAgICAgICAgIF90aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmaWxlLnNpemUgPSBkYXRhLmxpc3RbMF0uc2l6ZTsKICAgICAgICAgICAgICAgIGZpbGUuZnNfaWQgPSBkYXRhLmxpc3RbMF0uZnNfaWQ7CiAgICAgICAgICAgICAgICAvLyDlt7LlvIDlkK/mnoHpgJ/nlJ/miJAsIOebtOaOpeWPlm1ldGHlhoXnmoRtZDUKICAgICAgICAgICAgICAgIGZpbGUubWQ1ID0gX3RoaXMuaXNGYXN0CiAgICAgICAgICAgICAgICAgICAgPyBkZWNyeXB0TWQ1KGRhdGEubGlzdFswXS5tZDUudG9Mb3dlckNhc2UoKSkKICAgICAgICAgICAgICAgICAgICA6ICIiOwogICAgICAgICAgICAgICAgZmlsZS5tZDVzID0gIiI7CiAgICAgICAgICAgICAgICBfdGhpcy5nZXREbGluayhpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSBkYXRhLmVycm5vOwogICAgICAgICAgICAgICAgX3RoaXMuZ2VuZXJhdGVCZGxpbmsoaSArIDEpOwogICAgICAgICAgICB9CiAgICAgICAgfSwgZnVuY3Rpb24gKHN0YXR1c0NvZGUpIHsKICAgICAgICAgICAgZmlsZS5lcnJubyA9IHN0YXR1c0NvZGUgPT09IDQwNCA/IDkwOSA6IHN0YXR1c0NvZGU7CiAgICAgICAgICAgIF90aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICB9KTsKICAgIH07CiAgICAvKioKICAgICAqIEBkZXNjcmlwdGlvbjog6I635Y+W5paH5Lu2ZGxpbmso5LiL6L2955u06ZO+KQogICAgICogQHBhcmFtIHtudW1iZXJ9IGkKICAgICAqLwogICAgR2VuZXJhdGViZGxpbmtUYXNrLnByb3RvdHlwZS5nZXREbGluayA9IGZ1bmN0aW9uIChpKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICB2YXIgZmlsZSA9IHRoaXMuZmlsZUluZm9MaXN0W2ldOwogICAgICAgIC8vIOS9v+eUqOeUn+aIkOmhteaXtuS7heaciXBhdGjmsqHmnIlmc19pZCwg6Lez6L2s5Yiw6I635Y+WZnNfaWQKICAgICAgICBpZiAoIWZpbGUuZnNfaWQpIHsKICAgICAgICAgICAgdGhpcy5nZXRGaWxlSW5mbyhpKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBhamF4KHsKICAgICAgICAgICAgdXJsOiBtZXRhX3VybDIgKyBKU09OLnN0cmluZ2lmeShbZmlsZS5mc19pZF0pLAogICAgICAgICAgICByZXNwb25zZVR5cGU6ICJqc29uIiwKICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICB9LCBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICBkYXRhID0gZGF0YS5yZXNwb25zZTsKICAgICAgICAgICAgLy8g6K+35rGC5q2j5bi4CiAgICAgICAgICAgIGlmICghZGF0YS5lcnJubykgewogICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coZGF0YS5saXN0WzBdKTsgLy8gZGVidWcKICAgICAgICAgICAgICAgIF90aGlzLmRvd25sb2FkRmlsZURhdGEoaSwgZGF0YS5saXN0WzBdLmRsaW5rKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyDor7fmsYLmiqXplJkKICAgICAgICAgICAgZmlsZS5lcnJubyA9IGRhdGEuZXJybm87CiAgICAgICAgICAgIF90aGlzLmlzRmFzdCA/IF90aGlzLmNoZWNrTWQ1KGkgKyAxKSA6IF90aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICB9LCBmdW5jdGlvbiAoc3RhdHVzQ29kZSkgewogICAgICAgICAgICBmaWxlLmVycm5vID0gc3RhdHVzQ29kZTsKICAgICAgICAgICAgX3RoaXMuaXNGYXN0ID8gX3RoaXMuY2hlY2tNZDUoaSArIDEpIDogX3RoaXMuZ2VuZXJhdGVCZGxpbmsoaSArIDEpOwogICAgICAgIH0pOwogICAgfTsKICAgIC8qKgogICAgICogQGRlc2NyaXB0aW9uOiDosIPnlKjkuIvovb3nm7Tpk74KICAgICAqIEBwYXJhbSB7bnVtYmVyfSBpCiAgICAgKiBAcGFyYW0ge3N0cmluZ30gZGxpbmsKICAgICAqLwogICAgR2VuZXJhdGViZGxpbmtUYXNrLnByb3RvdHlwZS5kb3dubG9hZEZpbGVEYXRhID0gZnVuY3Rpb24gKGksIGRsaW5rKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICB2YXIgZGxTaXplLCBmaWxlID0gdGhpcy5maWxlSW5mb0xpc3RbaV07CiAgICAgICAgaWYgKHRoaXMuaXNGYXN0KQogICAgICAgICAgICBkbFNpemUgPSAxOyAvLyAi5p6B6YCf5LiL6L29IiDkuI3pnIDopoHnlJ/miJBzbGljZS1tZDUsIOaVheaXoOmcgOS4i+i9veaWh+S7tuaVsOaNrgogICAgICAgIGVsc2UKICAgICAgICAgICAgZGxTaXplID0gZmlsZS5zaXplIDwgMjYyMTQ0ID8gMSA6IDI2MjE0MzsgLy9zbGljZS1tZDU6IOaWh+S7tuWJjTI1NktpQueahG1kNSwgc2l6ZTwyNTZLaULliJnnm7TmjqXlj5ZtZDXljbPlj68sIOaXoOmcgOS4i+i9veaWh+S7tuaVsOaNrgogICAgICAgIGFqYXgoewogICAgICAgICAgICB1cmw6IGRsaW5rLAogICAgICAgICAgICBtZXRob2Q6ICJHRVQiLAogICAgICAgICAgICByZXNwb25zZVR5cGU6ICJhcnJheWJ1ZmZlciIsCiAgICAgICAgICAgIGhlYWRlcnM6IHsKICAgICAgICAgICAgICAgIFJhbmdlOiAiYnl0ZXM9MC0iICsgZGxTaXplLAogICAgICAgICAgICAgICAgIlVzZXItQWdlbnQiOiBVQSwKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25wcm9ncmVzczogdGhpcy5pc0Zhc3QgPyBmdW5jdGlvbiAoKSB7IH0gOiB0aGlzLm9uUHJvZ3Jlc3MsCiAgICAgICAgfSwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgICAgICAgaWYgKCFfdGhpcy5pc0Zhc3QpCiAgICAgICAgICAgICAgICBfdGhpcy5vblByb2dyZXNzKHsgbG9hZGVkOiAxMDAsIHRvdGFsOiAxMDAgfSk7IC8vIDEwMCUKICAgICAgICAgICAgX3RoaXMucGFyc2VEb3dubG9hZERhdGEoaSwgZGF0YSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHN0YXR1c0NvZGUpIHsKICAgICAgICAgICAgaWYgKHN0YXR1c0NvZGUgPT09IDQwNCkKICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSA5MDk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSBzdGF0dXNDb2RlOwogICAgICAgICAgICBfdGhpcy5pc0Zhc3QgPyBfdGhpcy5jaGVja01kNShpICsgMSkgOiBfdGhpcy5nZW5lcmF0ZUJkbGluayhpICsgMSk7CiAgICAgICAgfSk7CiAgICB9OwogICAgLyoqCiAgICAgKiBAZGVzY3JpcHRpb246IOino+aekOebtOmTvuivt+axgui/lOWbnueahOaVsOaNrgogICAgICogQHBhcmFtIHtudW1iZXJ9IGkKICAgICAqIEBwYXJhbSB7YW55fSBkYXRhCiAgICAgKi8KICAgIEdlbmVyYXRlYmRsaW5rVGFzay5wcm90b3R5cGUucGFyc2VEb3dubG9hZERhdGEgPSBmdW5jdGlvbiAoaSwgZGF0YSkgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgdmFyIGZpbGUgPSB0aGlzLmZpbGVJbmZvTGlzdFtpXTsKICAgICAgICBjb25zb2xlLmxvZygiZGxfdXJsOiAiICsgZGF0YS5maW5hbFVybCk7IC8vIGRlYnVnCiAgICAgICAgLy8g5LiL6L2955u06ZO+6YeN5a6a5ZCR5Yiw5q2k5Z+f5ZCNLCDliKTlrprkuLrmlofku7blkozosJAKICAgICAgICBpZiAoZGF0YS5maW5hbFVybC5pbmNsdWRlcygiaXNzdWVjZG4uYmFpZHVwY3MuY29tIikpIHsKICAgICAgICAgICAgZmlsZS5lcnJubyA9IDE5MTk7CiAgICAgICAgICAgIHRoaXMuaXNGYXN0ID8gdGhpcy5jaGVja01kNShpICsgMSkgOiB0aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyDku47kuIvovb3mjqXlj6Pojrflj5ZtZDUsIOatpOatpemqpOWPr+ehruS/neiOt+WPluWIsOato+ehrm1kNQogICAgICAgIC8vIGNvbnNvbGUubG9nKGRhdGEucmVzcG9uc2VIZWFkZXJzKTsgLy8gZGVidWcKICAgICAgICB2YXIgZmlsZU1kNSA9IGRhdGEucmVzcG9uc2VIZWFkZXJzLm1hdGNoKC9jb250ZW50LW1kNTogKFtcZGEtZl17MzJ9KS9pKTsKICAgICAgICBpZiAoZmlsZU1kNSkKICAgICAgICAgICAgZmlsZS5tZDUgPS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bWQ1X2RlZmF1bHQoKSkuQXJyYXlCdWZmZXIoKTsKICAgICAgICAgICAgICAgIHNwYXJrLmFwcGVuZChkYXRhLnJlc3BvbnNlKTsKICAgICAgICAgICAgICAgIHZhciBzbGljZU1kNSA9IHNwYXJrLmVuZCgpOwogICAgICAgICAgICAgICAgZmlsZS5tZDVzID0gc2xpY2VNZDU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGludGVydmFsID0gdGhpcy5maWxlSW5mb0xpc3QubGVuZ3RoID4gMSA/IDIwMDAgOiAxMDAwOwogICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIF90aGlzLmdlbmVyYXRlQmRsaW5rKGkgKyAxKTsKICAgICAgICAgICAgfSwgaW50ZXJ2YWwpOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgICAgIHRoaXMuY2hlY2tNZDUoaSArIDEpOwogICAgfTsKICAgIC8qKgogICAgICogQGRlc2NyaXB0aW9uOiAi5p6B6YCf55Sf5oiQIiDlj6/og73lvpfliLDplJnor69tZDUsIOaVheaJp+ihjOmqjOivgeatpemqpCwg6Iul6aqM6K+B5LiN6YCa6L+H5YiZ5omn6KGM5pmu6YCa55Sf5oiQCiAgICAgKiBAcGFyYW0ge251bWJlcn0gaQogICAgICovCiAgICBHZW5lcmF0ZWJkbGlua1Rhc2sucHJvdG90eXBlLmNoZWNrTWQ1ID0gZnVuY3Rpb24gKGkpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIGlmIChpID49IHRoaXMuZmlsZUluZm9MaXN0Lmxlbmd0aCkgewogICAgICAgICAgICB0aGlzLm9uRmluaXNoKHRoaXMuZmlsZUluZm9MaXN0KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICB0aGlzLm9uUHJvY2VzcyhpLCB0aGlzLmZpbGVJbmZvTGlzdCk7CiAgICAgICAgdGhpcy5vblByb2dyZXNzKGZhbHNlLCAi5p6B6YCf55Sf5oiQ5LitLi4uIik7CiAgICAgICAgdmFyIGZpbGUgPSB0aGlzLmZpbGVJbmZvTGlzdFtpXTsKICAgICAgICBwcmVjcmVhdGVGaWxlVjIuY2FsbCh0aGlzLCBmaWxlLCBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICBkYXRhID0gZGF0YS5yZXNwb25zZTsKICAgICAgICAgICAgaWYgKDAgPT09IGRhdGEuZXJybm8pIHsKICAgICAgICAgICAgICAgIGlmICgwID09PSBkYXRhLmJsb2NrX2xpc3QubGVuZ3RoKQogICAgICAgICAgICAgICAgICAgIF90aGlzLmNoZWNrTWQ1KGkgKyAxKTsgLy8gbWQ16aqM6K+B5oiQ5YqfCiAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAvLyBtZDXpqozor4HlpLHotKUsIOaJp+ihjOaZrumAmueUn+aIkCwg5LuF5Zyo5q2k5aSE5L+d5a2Y5Lu75Yqh6L+b5bqmCiAgICAgICAgICAgICAgICAgICAgR01fc2V0VmFsdWUoInVuZmluaXNoIiwgewogICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2luZm9fbGlzdDogX3RoaXMuZmlsZUluZm9MaXN0LAogICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBpLAogICAgICAgICAgICAgICAgICAgICAgICBpc0NoZWNrTWQ1OiB0cnVlLAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIF90aGlzLmdldERsaW5rKGkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgLy8g5o6l5Y+j6K6/6Zeu5aSx6LSlCiAgICAgICAgICAgICAgICBmaWxlLmVycm5vID0gZGF0YS5lcnJubzsKICAgICAgICAgICAgICAgIF90aGlzLmNoZWNrTWQ1KGkgKyAxKTsKICAgICAgICAgICAgfQogICAgICAgIH0sIGZ1bmN0aW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bXTsKICAgICAgICB0aGlzLnNhdmVQYXRoID0gIiI7CiAgICAgICAgdGhpcy5jaGVja01vZGUgPSBmYWxzZTsKICAgICAgICB0aGlzLmlzRGVmYXVsdFBhdGggPSBmYWxzZTsKICAgICAgICB0aGlzLm9uRmluaXNoID0gZnVuY3Rpb24gKCkgeyB9OwogICAgICAgIHRoaXMub25Qcm9jZXNzID0gZnVuY3Rpb24gKCkgeyB9OwogICAgfTsKICAgIFJhcGlkdXBsb2FkVGFzay5wcm90b3R5cGUuc3RhcnQgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgaWYgKHRoaXMuY2hlY2tNb2RlKQogICAgICAgICAgICB0aGlzLnNhdmVQYXRoID0gIiI7CiAgICAgICAgdGhpcy5zYXZlRmlsZVYyKDApOwogICAgfTsKICAgIC8qKgogICAgICogQGRlc2NyaXB0aW9uOiDovazlrZjnp5LkvKAg5o6l5Y+jMgogICAgICogQHBhcmFtIHtudW1iZXJ9IGkKICAgICAqLwogICAgUmFwaWR1cGxvYWRUYXNrLnByb3RvdHlwZS5zYXZlRmlsZVYyID0gZnVuY3Rpb24gKGkpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIGlmIChpID49IHRoaXMuZmlsZUluZm9MaXN0Lmxlbmd0aCkgewogICAgICAgICAgICB0aGlzLm9uRmluaXNoKHRoaXMuZmlsZUluZm9MaXN0KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICB0aGlzLm9uUHJvY2VzcyhpLCB0aGlzLmZpbGVJbmZvTGlzdCk7CiAgICAgICAgdmFyIGZpbGUgPSB0aGlzLmZpbGVJbmZvTGlzdFtpXTsKICAgICAgICAvLyDmlofku7blkI3lkKvmnInpnZ7ms5XlrZfnrKYgLyDmlofku7blkI3kuLrnqboKICAgICAgICBpZiAoZmlsZS5wYXRoLm1hdGNoKC9bIlxcXDoqPzw+fF0vKSB8fCBmaWxlLnBhdGggPT09ICIvIikgewogICAgICAgICAgICBmaWxlLmVycm5vID0gLTc7CiAgICAgICAgICAgIHRoaXMuc2F2ZUZpbGVWMihpICsgMSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgdmFyIG9uRmFpbGVkID0gZnVuY3Rpb24gKHN0YXR1c0NvZGUpIHsKICAgICAgICAgICAgZmlsZS5lcnJubyA9IHN0YXR1c0NvZGU7CiAgICAgICAgICAgIF90aGlzLnNhdmVGaWxlVjIoaSArIDEpOwogICAgICAgIH07CiAgICAgICAgUmFwaWR1cGxvYWRUYXNrX3ByZWNyZWF0ZUZpbGVWMi5jYWxsKHRoaXMsIGZpbGUsIGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgIGRhdGEgPSBkYXRhLnJlc3BvbnNlOwogICAgICAgICAgICBpZiAoMCA9PT0gZGF0YS5lcnJubykgewogICAgICAgICAgICAgICAgaWYgKDAgPT09IGRhdGEuYmxvY2tfbGlzdC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICBfdGhpcy5jcmVhdGVGaWxlVjIoZmlsZSwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IGRhdGEucmVzcG9uc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSAyID09PSBkYXRhLmVycm5vID8gMTE0IDogZGF0YS5lcnJubzsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsZS5lcnJubyA9IDMxMTkwID09PSBmaWxlLmVycm5vID8gNDA0IDogZmlsZS5lcnJubzsKICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuc2F2ZUZpbGVWMihpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgfSwgb25GYWlsZWQpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgZmlsZS5lcnJubyA9IDQwNDsKICAgICAgICAgICAgICAgICAgICBfdGhpcy5zYXZlRmlsZVYyKGkgKyAxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSBkYXRhLmVycm5vOwogICAgICAgICAgICAgICAgX3RoaXMuc2F2ZUZpbGVWMihpICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9LCBvbkZhaWxlZCk7CiAgICB9OwogICAgLy8g5q2k5o6l5Y+j5rWL6K+V57uT5p6c5aaC5LiLOiDplJnor69tZDUtPui/lOWbniJlcnJubyI6IDMxMTkwLCDmraPnoa5tZDUr6ZSZ6K+vc2l6ZS0+6L+U5ZueImVycm5vIjogMgogICAgLy8g5q2k5aSWLCDljbPkvb9tZDXlkoxzaXpl5Z2H5q2j56GuLCDov57nu63or7fmsYLml7bkvp3ml6fmnInlsI/mpoLnjofov5Tlm54iZXJybm8iOiAyLCDmlYXlu7rorq7liqDlhaVyZXRyeeetlueVpQogICAgUmFwaWR1cGxvYWRUYXNrLnByb3RvdHlwZS5jcmVhdGVGaWxlVjIgPSBmdW5jdGlvbiAoZmlsZSwgb25SZXNwb25zZWQsIG9uRmFpbGVkLCByZXRyeSkgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgaWYgKHJldHJ5ID09PSB2b2lkIDApIHsgcmV0cnkgPSAwOyB9CiAgICAgICAgYWpheCh7CiAgICAgICAgICAgIHVybDogIiIgKyBjcmVhdGVfdXJsICsgKHRoaXMuYmRzdG9rZW4gJiYgIiZiZHN0b2tlbj0iICsgdGhpcy5iZHN0b2tlbiksCiAgICAgICAgICAgIG1ldGhvZDogIlBPU1QiLAogICAgICAgICAgICByZXNwb25zZVR5cGU6ICJqc29uIiwKICAgICAgICAgICAgZGF0YTogY29udmVydERhdGEoewogICAgICAgICAgICAgICAgYmxvY2tfbGlzdDogSlNPTi5zdHJpbmdpZnkoW2ZpbGUubWQ1LnRvTG93ZXJDYXNlKCldKSwKICAgICAgICAgICAgICAgIHBhdGg6IHRoaXMuc2F2ZVBhdGggKyBmaWxlLnBhdGgsCiAgICAgICAgICAgICAgICBzaXplOiBmaWxlLnNpemUsCiAgICAgICAgICAgICAgICBpc2RpcjogMCwKICAgICAgICAgICAgICAgIHJ0eXBlOiB0aGlzLmNoZWNrTW9kZSA/IDMgOiAwLCAvLyBydHlwZT0z6KaG55uW5paH5Lu2LCBydHlwZT0w5YiZ6L+U5Zue5oql6ZSZLCDkuI3opobnm5bmlofku7YsIOm7mOiupOS4unJ0eXBlPTEo6Ieq5Yqo6YeN5ZG95ZCNKQogICAgICAgICAgICB9KSwKICAgICAgICB9LCBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhkYXRhLnJlc3BvbnNlKTsgLy8gZGVidWcKICAgICAgICAgICAgaWYgKDMxMDM5ID09PSBkYXRhLnJlc3BvbnNlLmVycm5vICYmIDMxMDM5ICE9IGZpbGUuZXJybm8pIHsKICAgICAgICAgICAgICAgIGZpbGUuZXJybm8gPSAzMTAzOTsKICAgICAgICAgICAgICAgIGZpbGUucGF0aCA9IHN1ZmZpeENoYW5nZShmaWxlLnBhdGgpOwogICAgICAgICAgICAgICAgX3RoaXMuY3JlYXRlRmlsZVYyKGZpbGUsIG9uUmVzcG9uc2VkLCBvbkZhaWxlZCwgcmV0cnkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgaWYgKDIgPT09IGRhdGEucmVzcG9uc2UuZXJybm8gJiYgcmV0cnkgPCByZXRyeU1heF9hcGlWMikKICAgICAgICAgICAgICAgIF90aGlzLmNyZWF0ZUZpbGVWMihmaWxlLCBvblJlc3BvbnNlZCwgb25GYWlsZWQsICsrcmV0cnkpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICBvblJlc3BvbnNlZChkYXRhKTsKICAgICAgICB9LCBvbkZhaWxlZCk7CiAgICB9OwogICAgcmV0dXJuIFJhcGlkdXBsb2FkVGFzazsKfSgpKTsKLyogaG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OwogICAgZnVuY3Rpb24gdmVyYihuKSB7IHJldHVybiBmdW5jdGlvbiAodikgeyByZXR1cm4gc3RlcChbbiwgdl0pOyB9OyB9CiAgICBmdW5jdGlvbiBzdGVwKG9wKSB7CiAgICAgICAgaWYgKGYpIHRocm93IG5ldyBUeXBlRXJyb3IoIkdlbmVyYXRvciBpcyBhbHJlYWR5IGV4ZWN1dGluZy4iKTsKICAgICAgICB3aGlsZSAoXykgdHJ5IHsKICAgICAgICAgICAgaWYgKGYgPSAxLCB5ICYmICh0ID0gb3BbMF0gJiAyID8geVsicmV0dXJuIl0gOiBvcFswXSA/IHlbInRocm93Il0gfHwgKCh0ID0geVsicmV0dXJuIl0pICYmIHQuY2FsbCh5KSwgMCkgOiB5Lm5leHQpICYmICEodCA9IHQuY2FsbCh5LCBvcFsxXSkpLmRvbmUpIHJldHVybiB0OwogICAgICAgICAgICBpZiAoeSA9IDAsIHQpIG9wID0gW29wWzBdICYgMiwgdC52YWx1ZV07CiAgICAgICAgICAgIHN3aXRjaCAob3BbMF0pIHsKICAgICAgICAgICAgICAgIGNhc2UgMDogY2FzZSAxOiB0ID0gb3A7IGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSA0OiBfLmxhYmVsKys7IHJldHVybiB7IHZhbHVlOiBvcFsxXSwgZG9uZTogZmFsc2UgfTsKICAgICAgICAgICAgICAgIGNhc2UgNTogXy5sYWJlbCsrOyB5ID0gb3BbMV07IG9wID0gWzBdOyBjb250aW51ZTsKICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTsKICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgaWYgKCEodCA9IF8udHJ5cywgdCA9IHQubGVuZ3RoID4gMCAmJiB0W3QubGVuZ3RoIC0gMV0pICYmIChvcFswXSA9PT0gNiB8fCBvcFswXSA9PT0gMikpIHsgXyA9IDA7IGNvbnRpbnVl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pZiAoIUR1UGFyc2VyLnBhcnNlKGJkbGluaykubGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzIgLypyZXR1cm4qLywgIiJdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiAvKnJldHVybiovLCBiZGxpbmtdOwogICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgIGVycm9yXzEgPSBfYS5zZW50KCk7CiAgICAgICAgICAgICAgICAgICAgc2hvd0FsZXJ0KGFwcEVycm9yLkNsaXBib2FyZFByZW1pc3Npb25FcnIpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiAvKnJldHVybiovLCAiIl07CiAgICAgICAgICAgICAgICBjYXNlIDM6IHJldHVybiBbMiAvKnJldHVybiovXTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfSk7Cn0KLyoqCiAqIEBkZXNjcmlwdGlvbjog6Kej5a+G5bey5Yqg5a+G55qEbWQ1CiAqIEBwYXJhbSB7c3RyaW5nfSBtZDUgKOWKoOWvhikKICogQHJldHVybiB7c3RyaW5nfSBtZDUgKOino+WvhikKICovCmZ1bmN0aW9uIGRlY3J5cHRNZDUobWQ1KSB7CiAgICBpZiAoISgocGFyc2VJbnQobWQ1WzldKSA+PSAwICYmIHBhcnNlSW50KG1kNVs5XSkgPD0gOSkgfHwKICAgICAgICAobWQ1WzldID49ICJhIiAmJiBtZDVbOV0gPD0gImYiKSkpCiAgICAgICAgcmV0dXJuIGRlY3J5cHQobWQ1KTsKICAgIGVsc2UKICAgICAgICByZXR1cm4gbWQ1OwogICAgZnVuY3Rpb24gZGVjcnlwdChlbmNyeXB0TWQ1KSB7CiAgICAgICAgdmFyIGtleSA9IChlbmNyeXB0TWQ1WzldLmNoYXJDb2RlQXQoMCkgLSAiZyIuY2hhckNvZGVBdCgwKSkudG9TdHJpbmcoMTYpOwogICAgICAgIHZhciBrZXkyID0gZW5jcnlwdE1kNS5zdWJzdHIoMCwgOSkgKy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Dku6XpmLLmraLmlrDniYjnlYzpnaLkuIvnmoRib2R55qC35byP56qB5Y+YCiAgICAgICAgICAgIHN3YWxJbnN0YW5jZS5zd2FsR2xvYmFsQXJncyA9IHsKICAgICAgICAgICAgICAgIGhlaWdodEF1dG86IGZhbHNlLAogICAgICAgICAgICAgICAgc2Nyb2xsYmFyUGFkZGluZzogZmFsc2UsCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIHNldFJlZnJlc2hMaXN0KGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50CiAgICAgICAgICAgICAgICAgICAgLnF1ZXJ5U2VsZWN0b3IoIi5uZC1tYWluLWxpc3QsIC5uZC1uZXctbWFpbi1saXN0IikKICAgICAgICAgICAgICAgICAgICAuX192dWVfXy5yZWxvYWRMaXN0KCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBzZXRHZXRTZWxlY3RlZEZpbGVMaXN0KGdldFNlbGVjdGVkRmlsZUxpc3ROZXcpOwogICAgICAgICAgICBzZXRHZXRCZHN0b2tlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiLm5kLW1haW4tbGlzdCwgLm5kLW5ldy1tYWluLWxpc3QiKS5fX3Z1ZV9fCiAgICAgICAgICAgICAgICAgICAgLnl1bkRhdGEuYmRzdG9rZW47CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBpbnN0YWxsTmV3KCk7CiAgICAgICAgfSAvLyDmlrDniYjnlYzpnaJsb2FkZXLlhaXlj6MKICAgICAgICBlbHNlIHsKICAgICAgICAgICAgc2V0UmVmcmVzaExpc3QoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgLy8g5pen54mI55WM6Z2iLCDosIPnlKjljp/nlJ/mlrnms5XliLfmlrDmlofku7bliJfooagsIOaXoOmcgOmHjeaWsOWKoOi9vemhtemdogogICAgICAgICAgICAgICAgdW5zYWZlV2luZG93CiAgICAgICAgICAgICAgICAgICAgLnJlcXVpcmUoInN5c3RlbS1jb3JlOnN5c3RlbS9iYXNlU2VydmljZS9tZXNzYWdlL21lc3NhZ2UuanMiKQogICAgICAgICAgICAgICAgICAgIC50cmlnZ2VyKCJzeXN0ZW0tcmVmcmVzaCIpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgc2V0R2V0U2VsZWN0ZWRGaWxlTGlzdChnZXRTZWxlY3RlZEZpbGVMaXN0TGVnYWN5KTsKICAgICAgICAgICAgc2V0R2V0QmRzdG9rZW4oZnVuY3Rpb24gKCkgeyByZXR1cm4gdW5zYWZlV2luZG93LmxvY2Fscy5nZXQoImJkc3Rva2VuIik7IH0pOwogICAgICAgICAgICBpbnN0YWxsbGVnYWN5KCk7CiAgICAgICAgfSAvLyDml6fniYjnlYzpnaJsb2FkZXLlhaXlj6MKICAgICAgICB2YXIgYmRsaW5rID0gcGFyc2VRdWVyeUxpbmsobG9jVXJsKTsgLy8g6Kej5p6QdXJs5Lit55qE56eS5Lyg6ZO+5o6lCiAgICAgICAgaWYgKGJkbGluaykgewogICAgICAgICAgICAvLyDop6PmnpDliLDnp5LkvKDpk77mjqUsIOW8ueWHuui9rOWtmOeql+WPowogICAgICAgICAgICBzd2FsSW5zdGFuY2UuaW5wdXRWaWV3KGJkbGluayk7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKCFHTV9nZXRWYWx1ZSh1cGRhdGVJbmZvVmVyICsgIl9ub19maXJzdCIpKQogICAgICAgICAgICAvLyDmo4Dmn6XmmK/lkKbpppbmrKHov5DooYwsIOiLpeaYr+WImeW8ueWHuuabtOaWsOS/oeaBr+eql+WPowogICAgICAgICAgICBzd2FsSW5zdGFuY2UudXBkYXRlSW5mbyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBHTV9zZXRWYWx1ZSh1cGRhdGVJbmZvVmVyICsgIl9ub19maXJzdCIsIHRydWUpOwogICAgICAgICAgICB9KTsKICAgICAgICAvLyDpooTlhYjnu5Hlrprlpb3mjInpkq7kuovku7YKICAgICAgICAkKGRvY3VtZW50KS5vbigiY2xpY2siLCAiI2tpbGxfZG9uYXRlIiwgZnVuY3Rpb24gKCkgewogICAgICAgICAgICBHTV9zZXRWYWx1ZShmZWVkYmFja1ZlciArICJfa2lsbF9kb25hdGUiLCB0cnVlKTsKICAgICAgICAgICAgJCgiI216Zl9kb25hdGUiKS5yZW1vdmUoKTsKICAgICAgICB9KTsgLy8g6LWe5Yqp5o+Q56S6ICLkuI3lho3mmL7npLoiIOaMiemSrgogICAgICAgICQoZG9jdW1lbnQpLm9uKCJjbGljayIsICIja2lsbF9mZWVkYmFjayIsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgR01fc2V0VmFsdWUoZG9uYXRlVmVyICsgIl9raWxsX2ZlZWRiYWNrIiwgdHJ1ZSk7CiAgICAgICAgICAgICQoIiNtemZfZmVlZGJhY2siKS5yZW1vdmUoKTsKICAgICAgICB9KTsgLy8g5Y+N6aaI5o+Q56S6ICLkuI3lho3mmL7npLoiIOaMiemSrgogICAgICAgICQoZG9jdW1lbnQpLm9uKCJjbGljayIsICIjY2hlY2tfbWQ1X2J0biIsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgc3dhbEluc3RhbmNlLmNoZWNrTWQ1KCk7CiAgICAgICAgfSk7IC8vIOa1i+ivleenkuS8oOaMiemSrgogICAgICAgICQoZG9jdW1lbnQpLm9uKCJjbGljayIsICIjY29weV9mYWlsX2xpc3QiLCBmdW5jdGlvbiAoYnRuKSB7CiAgICAgICAgICAgIHZhciBsaXN0VGV4dCA9ICIiOwogICAgICAgICAgICBmb3IgKHZhciBfaSA9IDAsIF9hID0gc3dhbEluc3RhbmNlLnBhcnNlUmVzdWx0LmZhaWxMaXN0OyBfaSA8IF9hLmxlbmd0aDsgX2krKykgewogICAgICAgICAgICAgICAgdmFyIGl0ZW0gPSBfYVtfaV07CiAgICAgICAgICAgICAgICBsaXN0VGV4dCArPSBpdGVtLnBhdGggKyAiXG4iOwogICAgICAgICAgICB9CiAgICAgICAgICAgIEdNX3NldENsaXBib2FyZChsaXN0VGV4dCk7CiAgICAgICAgICAgIGJ0bi50YXJnZXQuaW5uZXJUZXh0ID0gIuWkjeWItuaIkOWKnyI7CiAgICAgICAgfSk7IC8vIOWksei0peaWh+S7tuWIl+ihqOWkjeWItgogICAgICAgICQoZG9jdW1lbnQpLm9uKCJjbGljayIsICIjY29weV9zdWNjZXNzX2xpc3QiLCBmdW5jdGlvbiAoYnRuKSB7CiAgICAgICAgICAgIHZhciBsaXN0VGV4dCA9ICIiOwogICAgICAgICAgICBmb3IgKHZhciBfaSA9IDAsIF9hID0gc3dhbEluc3RhbmNlLnBhcnNlUmVzdWx0LnN1Y2Nlc3NMaXN0OyBfaSA8IF9hLmxlbmd0aDsgX2krKykgewogICAgICAgICAgICAgICAgdmFyIGl0ZW0gPSBfYVtfaV07CiAgICAgICAgICAgICAgICBsaXN0VGV4dCArPSBpdGVtLnBhdGggKyAiXG4iOwogICAgICAgICAgICB9CiAgICAgICAgICAgIEdNX3NldENsaXBib2FyZChsaXN0VGV4dCk7CiAgICAgICAgICAgIGJ0bi50YXJnZXQuaW5uZXJUZXh0ID0gIuWkjeWItuaIkOWKnyI7CiAgICAgICAgfSk7IC8vIOaIkOWKn+aWh+S7tuWIl+ihqOWkjeWItgogICAgICAgICQoZG9jdW1lbnQpLm9uKCJjbGljayIsICIjY29weV9mYWlsX2JyYW5jaF9saXN0IiwgZnVuY3Rpb24gKGJ0bikgewogICAgICAgICAgICB2YXIgZWxlID0gJChidG4udGFyZ2V0KTsKICAgICAgICAgICAgR01fc2V0Q2xpcGJvYXJkKGVsZQogICAgICAgICAgICAgICAgLnBhcmVudHMoImRldGFpbHMubXpmX2RldGFpbHNfYnJhbmNoIikKICAgICAgICAgICAgICAgIC5uZXh0KClbMF0KICAgICAgICAgICAgICAgIC5pbm5lclRleHQucmVwbGFjZSgvXG5cbi9nLCAiXG4iKSk7CiAgICAg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