Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_HTML5视频播放器增强脚本@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICBIVE1MNeinhumikeaSreaUvuWZqOWinuW8uuiEmuacrAovLyBAbmFtZTplbiAgICAgIEhUTUw1IHZpZGVvIHBsYXllciBlbmhhbmNlZCBzY3JpcHQKLy8gQG5hbWU6emggICAgICBIVE1MNeinhumikeaSreaUvuWZqOWinuW8uuiEmuacrAovLyBAbmFtZTp6aC1UVyAgIEhUTUw16KaW6aC75pKt5pS+5Zmo5aKe5by36IWz5pysCi8vIEBuYW1lOmphICAgICAgSFRNTDXjg5Pjg4fjgqrjg5fjg6zjg7zjg6Tjg7zjga7mi6HlvLXjgrnjgq/jg6rjg5fjg4gKLy8gQG5hbWU6a28gICAgICBIVE1MNSDruYTrlJTsmKQg7ZSM66CI7J207Ja0IOqzoOq4iSDsiqTtgazrpr3tirgKLy8gQG5hbWU6cnUgICAgICBIVE1MNSDQstC40LTQtdC+INC/0LvQtdC10YAg0YPQu9GD0YfRiNC10L3QvdGL0Lkg0YHQutGA0LjQv9GCCi8vIEBuYW1lOmRlICAgICAgSFRNTDUgVmlkZW8gUGxheWVyIGVyd2VpdGVydGVzIFNrcmlwdAovLyBAbmFtZXNwYWNlICAgIGh0dHBzOi8vZ2l0aHViLmNvbS94eHhpbHkvaDVwbGF5ZXIKLy8gQGhvbWVwYWdlICAgICBodHRwczovL2dpdGh1Yi5jb20veHh4aWx5L2g1cGxheWVyCi8vIEB2ZXJzaW9uICAgICAgMy43LjUKLy8gQGRlc2NyaXB0aW9uICDop4bpopHlop7lvLrohJrmnKzvvIzmlK/mjIHmiYDmnIlINeinhumikee9keerme+8jOS+i+Wmgu+8mkLnq5njgIHmipbpn7PjgIHohb7orq/op4bpopHjgIHkvJjphbfjgIHniLHlpYfoibrjgIHopb/nk5zop4bpopHjgIHmsrnnrqHv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YmFjaywgdmlkZW8gc2NyZWVuc2hvdHMsIHBpY3R1cmUtaW4tcGljdHVyZSwgZnVsbC1zY3JlZW4gd2ViIHBhZ2VzLCBhZGp1c3RpbmcgYnJpZ2h0bmVzcywgc2F0dXJhdGlvbiwgY29udHJhc3QKLy8gQGRlc2NyaXB0aW9uOnpoICDop4bpopHlop7lvLrohJrmnKzvvIzmlK/mjIHmiYDmnIlINeinhumikee9keerme+8jOS+i+Wmgu+8mkLnq5njgIHmipbpn7PjgIHohb7orq/op4bpopHjgIHkvJjphbfjgIHniLHlpYfoibrjgIHopb/nk5zop4bpopHjgIHmsrnnrqHvvIhZb3VUdWJl77yJ44CB5b6u5Y2a6KeG6aKR44CB55+l5LmO6KeG6aKR44CB5pCc54uQ6KeG6aKR44CB572R5piT5YWs5byA6K++44CB55m+5bqm572R55uY44CB6Zi/6YeM5LqR55uY44CBdGVk44CBaW5zdGFncmFt44CBdHdpdHRlcuetieOAguWFqOeoi+W/q+aNt+mUruaOp+WItu+8jOaUr+aMge+8muWAjemAn+aSreaUvi/liqDpgJ/mkq3mlL7jgIHop4bpopHnlLvpnaLmiKrlm77jgIHnlLvkuK3nlLvjgIHnvZHpobXlhajlsY/jgIHosIPoioLkuq7luqbjgIHppbHlkozluqbjgIHlr7nmr5TluqbjgIHoh6rlrprkuYnphY3nva7lip/og73lop7lvLrnrYnlip/og73vvIzkuLrkvaDmj5DkvpvmhInmgqbnmoTlnKjnur/op4bpopHmkq3mlL7kvZPpqozjgILov5jmnInop4bpopHlub/lkYrlv6vov5vjgIHlnKjnur/mlZnnqIsv5pWZ6IKy6KeG6aKR5YCN6YCf5b+r5a2m44CB6KeG6aKR5paH5Lu25LiL6L29562J6IO95YqbCi8vIEBkZXNjcmlwdGlvbjp6aC1UVyAg6KaW6aC75aKe5by36IWz5pys77yM5pSv5oyB5omA5pyJSDXoppbpoLvntrLnq5nvvIzkvovlpoLvvJpC56uZ44CB5oqW6Z+z44CB6aiw6KiK6KaW6aC744CB5YS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gICAgICBjYW5jZWxhYmxlOiB0cnVlCiAgICAgIH0pOwogICAgICBkb2N1bWVudC5kaXNwYXRjaEV2ZW50KHNoYWRvd0V2ZW50KTsKCiAgICAgIHJldHVybiBzaGFkb3dSb290CiAgICB9OwogICAgd2luZG93Ll9oYXNIYWNrQXR0YWNoU2hhZG93XyA9IHRydWU7CiAgfSBjYXRjaCAoZSkgewogICAgY29uc29sZS5lcnJvcignaGFja0F0dGFjaFNoYWRvdyBlcnJvciBieSBoNXBsYXllciBwbHVnLWluJywgZSk7CiAgfQp9CgovKiEKICogQG5hbWUgICAgICAgICBvcmlnaW5hbC5qcwogKiBAZGVzY3JpcHRpb24gIOWtmOWCqOmDqOWIhumHjeimgeeahOWOn+eUn+WHveaVsO+8jOmYsuatouiiq+WklumDqOaxoeafk++8jOatpOmAu+i+keW6lOWwveWPr+iDveWJjee9ru+8jOWQpuWImeWtmOWCqOeahOWwhuaYr+axoeafk+WQjueahOWHveaVsAogKiBAdmVyc2lvbiAgICAgIDAuMC4xCiAqIEBhdXRob3IgICAgICAgeHh4aWx5CiAqIEBkYXRlICAgICAgICAgMjAyMi8xMC8xNiAxMDozMgogKiBAZ2l0aHViICAgICAgIGh0dHBzOi8vZ2l0aHViLmNvbS94eHhpbHkKICovCgpjb25zdCBvcmlnaW5hbCA9IHsKICAvLyDpmLLmraJkZWZpbmVQcm9wZXJ0eeWSjGRlZmluZVByb3BlcnRpZXPooqtBT1DohJrmnKzph43lhpkKICBPYmplY3Q6IHsKICAgIGRlZmluZVByb3BlcnR5OiBPYmplY3QuZGVmaW5lUHJvcGVydHksCiAgICBkZWZpbmVQcm9wZXJ0aWVzOiBPYmplY3QuZGVmaW5lUHJvcGVydGllcwogIH0sCgogIC8vIOmYsuatouatpOexu+eOqeazle+8mmh0dHBzOi8vanVlamluLmNuL3Bvc3QvNjg2NTkxMDU2NDgxNzAxMDcwMgogIFByb3h5LAoKICBNYXAsCiAgbWFwOiB7CiAgICBjbGVhcjogTWFwLnByb3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u7pNZWRpYVBsdXNBcGnlr7nosaEgKi8KICAgIG1lZGlhUGx1c0FwaSA9IHt9OwogICAgY29uc3QgbWVkaWFQbHVzQmFzZUFwaSA9IHsKICAgICAgLyoqCiAgICAgICAqIOWIm+W7uumUge+8jOmYu+atouWklumDqOmAu+i+keaTjeS9nG1lZGlhRWxlbWVudOebuOWFs+eahOWxnuaAp+aIluWHveaVsAogICAgICAgKiDov5nph4znmoTplIHpgLvovpHlj6rmmK/mlbDmja7nirbmgIHmoIfms6jlkozliIfmjaLvvIzlhbfkvZPnmoTplIHlip/og73pnIDlnKgKICAgICAgICogcHJveHlQcm90b3R5cGVNZXRob2TlkoxoaWphY2tQcm90b3R5cGVQcm9wZXJ0eemHjOWunueOsAogICAgICAgKi8KICAgICAgbG9jayAoa2V5TmFtZSwgZHVyYXRpb24pIHsKICAgICAgICBjb25zdCBpbmZvS2V5ID0gYF9fJHtrZXlOYW1lfV9pbmZvX19gOwogICAgICAgIG1lZGlhUGx1c0FwaVtpbmZvS2V5XSA9IG1lZGlhUGx1c0FwaVtpbmZvS2V5XSB8fCB7fTsKICAgICAgICBtZWRpYVBsdXNBcGlbaW5mb0tleV0ubG9jayA9IHRydWU7CgogICAgICAgIC8qIOino+mUgeaXtumXtOS/oeaBryAqLwogICAgICAgIGR1cmF0aW9uID0gTnVtYmVyKGR1cmF0aW9uKTsKICAgICAgICBpZiAoIU51bWJlci5pc05hTihkdXJhdGlvbikgJiYgZHVyYXRpb24gPiAwKSB7CiAgICAgICAgICBtZWRpYVBsdXNBcGlbaW5mb0tleV0udW5Mb2NrVGltZSA9IERhdGUubm93KCkgKyBkdXJhdGlvbjsKICAgICAgICB9CgogICAgICAgIC8vIG9yaWdpbmFsLmNvbnNvbGUubG9nKGBbbWVkaWFQbHVzQXBpXVtsb2NrXVske2tleU5hbWV9XSAke2R1cmF0aW9ufWApCiAgICAgIH0sCiAgICAgIHVuTG9jayAoa2V5TmFtZSkgewogICAgICAgIGNvbnN0IGluZm9LZX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Z1bmMsIHsKICAgICAgYXBwbHkgKHRhcmdldCwgY3R4LCBhcmdzKSB7CiAgICAgICAgbWVkaWFEZXRlY3RIYW5kbGVyKGN0eCk7CiAgICAgICAgLy8gb3JpZ2luYWwuY29uc29sZS5sb2coYFttZWRpYUVsZW1lbnRNZXRob2RQcm94eV0g5omn6KGM5Luj55CG5ZCO55qEJHttZXRob2ROYW1lfeWHveaVsGApCgogICAgICAgIC8qIOWvueaSreaUvuaaguWBnOmAu+i+kei/m+ihjOWinuW8uuWkhOeQhu+8jOS+i+WmguWFgeiuuOmAmui/h21lZGlhUGx1c0Fwaei/m+ihjOmUgeWumiAqLwogICAgICAgIGlmIChbJ3BsYXknLCAncGF1c2UnXS5pbmNsdWRlcyhtZXRob2ROYW1lKSkgewogICAgICAgICAgY29uc3QgbWVkaWFQbHVzQXBpID0gY3JlYXRlTWVkaWFQbHVzQXBpKGN0eCk7CiAgICAgICAgICBpZiAobWVkaWFQbHVzQXBpICYmIG1lZGlhUGx1c0FwaS5pc0xvY2sobWV0aG9kTmFtZSkpIHsKICAgICAgICAgICAgLy8gb3JpZ2luYWwuY29uc29sZS5sb2coYFttZWRpYUVsZW1lbnRNZXRob2RQcm94eV0gJHttZXRob2ROYW1lfeW3suiiq+mUgeWumu+8jOaXoOazleaJp+ihjOebuOWFs+aTjeS9nGApCiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgY29uc3QgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KGN0eCwgYXJncyk7CgogICAgICAgIC8vIFRPRE8g5a+55Ye95pWw5omn6KGM57uT5p6c6L+b6KGM6KeC5a+f5Yik5patCgogICAgICAgIHJldHVybiByZXN1bHQKICAgICAgfQogICAgfSk7CgogICAgLy8g5LiN5bu66K6u5a+5SFRNTE1lZGlhRWxlbWVudOeahOWOn+Wei+mTvui/m+ihjOaJqeWxle+8jOi/meagt+WuueaYk+iuqee9kemhteajgOa1i+WIsG1lZGlhQ29y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obWVkaWFQbHVzQXBpICYmIG1lZGlhUGx1c0FwaS5pc0xvY2socHJvcGVydHkpKSB7CiAgICAgICAgICBpZiAocHJvcGVydHkgPT09ICdwbGF5YmFja1JhdGUnKSB7CiAgICAgICAgICAgIHJldHVybiArIStbXQogICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIHZhbAogICAgICB9LAogICAgICBzZXQ6IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgIC8vIG9yaWdpbmFsLmNvbnNvbGUubG9nKGBbbWVkaWFFbGVtZW50UHJvcGVydHlIaWphY2tdWyR7cHJvcGVydHl9XVtzZXRdYCwgdmFsdWUpCgogICAgICAgIGlmIChwcm9wZXJ0eSA9PT0gJ3NyYycpIHsKICAgICAgICAgIG1lZGlhRGV0ZWN0SGFuZGxlcih0aGlzKTsKICAgICAgICB9CgogICAgICAgIC8qIOWvueiwg+mAn+OAgeiwg+mfs+WSjOi/m+W6puaOp+WItumAu+i+kei/m+ihjOWinuW8uuWkhOeQhu+8jOS+i+WmguWFgeiuuOmAmui/h21lZGlhUGx1c0Fwaei/meS6m+WKn+iDvei/m+ihjOmUgeWumiAqLwogICAgICAgIGlmIChbJ3BsYXliYWNrUmF0ZScsICd2b2x1bWUnLCAnY3VycmVudFRpbWUnXS5pbmNsdWRlcyhwcm9wZXJ0eSkpIHsKICAgICAgICAgIGNvbnN0IG1lZGlhUGx1c0FwaSA9IGNyZWF0ZU1lZGlhUGx1c0FwaSh0aGlzKTsKICAgICAgICAgIGlmIChtZWRpYVBsdXNBcGkgJiYgbWVkaWFQbHVzQXBpLmlzTG9jayhwcm9wZXJ0eSkpIHsKICAgICAgICAgICAgLy8gb3JpZ2luYWwuY29uc29sZS5sb2coYFttZWRpYUVsZW1lbnRQcm9wZXJ0eUhpamFja10gJHtwcm9wZXJ0eX3lt7LooqvplIHlrprvvIzml6Dms5XmiafooYznm7jlhbPmk43kvZxgKQogICAgICAgICAgICByZXR1cm4KICAgICAgICAgIH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VyY2VdW2Vycm9yXSc7CiAgICAgICAgICBvcmlnaW5hbC5jb25zb2xlLmVycm9yKG1zZywgZSk7CiAgICAgICAgICBvcmlnaW5hbC5hbGVydChtc2cpOwogICAgICAgIH0KICAgICAgfSk7CiAgICB9KTsKICB9CgogIGZ1bmN0aW9uIGhhc0luaXQgKCkgewogICAgcmV0dXJuIGhhc01lZGlhU291cmNlSW5pdAogIH0KCiAgZnVuY3Rpb24gaW5pdCAoKSB7CiAgICBpZiAoaGFzTWVkaWFTb3VyY2VJbml0KSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIGlmICghd2luZG93Lk1lZGlhU291cmNlKSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIE9iamVjdC5rZXlzKE1lZGlhU291cmNlLnByb3RvdHlwZSkuZm9yRWFjaChrZXkgPT4gewogICAgICB0cnkgewogICAgICAgIGlmIChNZWRpYVNvdXJjZS5wcm90b3R5cGVba2V5XSBpbnN0YW5jZW9mIEZ1bmN0aW9uKSB7CiAgICAgICAgICBvcmlnaW5NZXRob2RzW2tleV0gPSBNZWRpYVNvdXJjZS5wcm90b3R5cGVba2V5XTsKICAgICAgICB9CiAgICAgIH0gY2F0Y2ggKGUpIHt9CiAgICB9KTsKCiAgICBwcm94eU1lZGlhU291cmNlTWV0aG9kKCk7CgogICAgaGFzTWVkaWFTb3VyY2VJbml0ID0gdHJ1ZTsKICB9CgogIHJldHVybiB7CiAgICBpbml0LAogICAgaGFzSW5pdCwKICAgIG9yaWdpbk1ldGhvZHMsCiAgICBvcmlnaW5VUkxNZXRob2RzLAogICAgbWVkaWFTb3VyY2VNYXAsCiAgICBvYmplY3RVUkxNYXAsCiAgICBkb3dubG9hZE1lZGlhU291cmNlCiAgfQp9KSgpOwoKLyohCiAqIEBuYW1lICAgICAgICAgdXRpbHMuanMKICogQGRlc2NyaXB0aW9uICDmlbDmja7nsbvlnovnm7jlhbPnmoTmlrnms5UKICogQHZlcnNpb24gICAgICAwL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ltpXTsKICAgICAgICBpZiAoaXRlbSAhPT0gJycgJiYgaXRlbS5pbmRleE9mKCc9JykpIHsKICAgICAgICAgIHNlZy5wdXNoKGl0ZW0pOwogICAgICAgIH0KICAgICAgfQoKICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBzZWcubGVuZ3RoOyBqKyspIHsKICAgICAgICB2YXIgcGFyYW0gPSBzZWdbal07CiAgICAgICAgdmFyIGlkeCA9IHBhcmFtLmluZGV4T2YoJz0nKTsKICAgICAgICB2YXIga2V5ID0gcGFyYW0uc3Vic3RyaW5nKDAsIGlkeCk7CiAgICAgICAgdmFyIHZhbCA9IHBhcmFtLnN1YnN0cmluZyhpZHggKyAxKTsKICAgICAgICBpZiAoIWtleSkgewogICAgICAgICAgcmV0W3ZhbF0gPSBudWxsOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXRba2V5XSA9IHZhbDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIHJldAogICAgfSkoKQogIH0KfQoKLyoqCiAqIOWwhnBhcmFtc+Wvueixoei9rOaNouaIkOWtl+espuS4suaooeW8jwogKiBAcGFyYW0gcGFyYW1zIHtPYmplY3R9IC0g5b+F6YCJIHBhcmFtc+WvueixoQogKiBAcmV0dXJucyB7c3RyaW5nfQogKi8KZnVuY3Rpb24gc3RyaW5naWZ5UGFyYW1zIChwYXJhbXMpIHsKICB2YXIgc3RyQXJyID0gW107CgogIGlmICghT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKHBhcmFtcykgPT09ICdbb2JqZWN0IE9iamVjdF0nKSB7CiAgICByZXR1cm4gJycKICB9CgogIGZvciAodmFyIGtleSBpbiBwYXJhbXMpIHsKICAgIGlmIChPYmplY3QuaGFzT3duUHJvcGVydHkuY2FsbChwYXJhbXMsIGtleSkpIHsKICAgICAgdmFyIHZhbCA9IHBhcmFtc1trZXldOwogICAgICB2YXIgdmFsVHlwZSA9IE9iamVjdC5wcm90b3R5cGUudG9TdHJp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kZXNjOiAn5YiH5o2i55S75Lit55S75qih5byPJywKICAgICAga2V5OiAnc2hpZnQrcCcsCiAgICAgIGNvbW1hbmQ6ICd0b2dnbGVQaWN0dXJlSW5QaWN0dXJlJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+inhumikeaIquWbvicsCiAgICAgIGtleTogJ3NoaWZ0K3MnLAogICAgICBjb21tYW5kOiAnY2FwdHVyZScKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflkK/nlKjmiJbnpoHmraLoh6rliqjmgaLlpI3mkq3mlL7ov5vluqblip/og70nLAogICAgICBrZXk6ICdzaGlmdCtyJywKICAgICAgY29tbWFuZDogJ2NhcHR1cmUnCiAgICB9LAogICAgewogICAgICBkZXNjOiAn5Z6C55u06ZWc5YOP57+76L2sJywKICAgICAga2V5OiAnc2hpZnQrbScsCiAgICAgIGNvbW1hbmQ6ICdzZXRNaXJyb3InLAogICAgICBhcmdzOiBbdHJ1ZV0KICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfmsLTlubPplZzlg4/nv7vovawnLAogICAgICBrZXk6ICdtJywKICAgICAgY29tbWFuZDogJ3NldE1pcnJvcicKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfkuIvovb3pn7Pop4bpopHmlofku7bvvIjlrp7pqozmgKflip/og73vvIknLAogICAgICBrZXk6ICdzaGlmdCtkJywKICAgICAgY29tbWFuZDogJ21lZGlhRG93bmxvYWQnCiAgICB9LAogICAgewogICAgICBkZXNjOiAn57yp5bCP6KeG6aKR55S76Z2iIC0wLjA1JywKICAgICAga2V5OiAnc2hpZnQreCcsCiAgICAgIGNvbW1hbmQ6ICdzZXRTY2FsZURvd24nCiAgICB9LAogICAgewogICAgICBkZXNjOiAn5pS+5aSn6KeG6aKR55S76Z2iICswLjA1JywKICAgICAga2V5OiAnc2hpZnQrYycsCiAgICAgIGNvbW1hbmQ6ICdzZXRTY2FsZVVwJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+aBouWkjeinhumikeeUu+mdoicsCiAgICAgIGtleTogJ3NoaWZ0K3onLAogICAgICBjb21tYW5kOiAncmVzZXRUcmFuc2Zvcm0nCiAgICB9LAogICAgewogICAgICBkZXNjOiAn55S76Z2i5ZCR5Y+z56e75YqoMTBweCcsCiAgICAgIGtleTogJ3NoaWZ0K2Fycm93cmlnaHQnLAogICAgICBjb21tYW5kOiAnc2V0VHJhbnNsYXRlUmlnaHQnCiAgICB9LAogICAgewogICAgICBkZXNjOiAn55S76Z2i5ZCR5bem56e75YqoMTBweCcsCiAgICAgIGtleTogJ3NoaWZ0K2Fycm93bGVmdCcsCiAgICAgIGNvbW1hbmQ6ICdzZXRUcmFuc2xhdGVMZWZ0JwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+eUu+mdouWQkeS4iuenu+WKqDEwcHgnLAogICAgICBrZXk6ICdzaGlmdCthcnJvd3VwJywKICAgICAgY29tbWFuZDogJ3NldFRyYW5zbGF0ZVVwJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+eUu+mdouWQkeS4i+enu+WKqDEwcHgnLAogICAgICBrZXk6ICdzaGlmdCthcnJvd2Rvd24nLAogICAgICBjb21tYW5kOiAnc2V0VHJhbnNsYXRlRG93bicKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfliY3ov5s156eSJywKICAgICAga2V5OiAnYXJyb3dyaWdodCcsCiAgICAgIGNvbW1hbmQ6ICdzZXRDdXJyZW50VGltZVVwJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WQjumAgDXnp5InLAogICAgICBrZXk6ICdhcnJvd2xlZnQnLAogICAgICBjb21tYW5kOiAnc2V0Q3VycmVudFRpbWVEb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WJjei/mzMw56eSJywKICAgICAga2V5OiAnY3RybCthcnJvd3JpZ2h0JywKICAgICAgY29tbWFuZDogJ3NldEN1cnJlbnRUaW1lVXAnLAogICAgICBhcmdzOiBbMzBdCiAgICB9LAogICAgewogICAgICBkZXNjOiAn5ZCO6YCAMzDnp5InLAogICAgICBrZXk6ICdjdHJsK2Fycm93bGVmdCcsCiAgICAgIGNvbW1hbmQ6ICdzZXRDdXJyZW50VGltZURvd24nLAogICAgICBhcmdzOiBbLTMwXQogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+mfs+mHj+WNh+mrmCA1JScsCiAgICAgIGtleTogJ2Fycm93dXAnLAogICAgICBjb21tYW5kOiAnc2V0Vm9sdW1lVXAnLAogICAgICBhcmdzOiBbMC4wNV0KICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfpn7Pph4/pmY3kvY4gNSUnLAogICAgICBrZXk6ICdhcnJvd2Rvd24nLAogICAgICBjb21tYW5kOiAnc2V0Vm9sdW1lRG93bicsCiAgICAgIGFyZ3M6IFstMC4wNV0KICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfpn7Pph4/ljYfpq5ggMjAlJywKICAgICAga2V5OiAnY3RybCthcnJvd3VwJywKICAgICAgY29tbWFuZDogJ3NldFZvbHVtZVVwJywKICAgICAgYXJnczogWzAuMl0KICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfpn7Pph4/pmY3kvY4gMjAlJywKICAgICAga2V5OiAnY3RybCthcnJvd2Rvd24nLAogICAgICBjb21tYW5kOiAnc2V0Vm9sdW1lRG93bicsCiAgICAgIGFyZ3M6IFstMC4yXQogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WIh+aNouaaguWBnC/mkq3mlL4nLAogICAgICBrZXk6ICdzcGFjZScsCiAgICAgIGNvbW1hbmQ6ICdzd2l0Y2hQbGF5U3RhdHVzJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WHj+mAn+aSreaUviAtMC4xJywKICAgICAga2V5OiAneCcsCiAgICAgIGNvbW1hbmQ6ICdzZXRQbGF5YmFja1JhdGVEb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WKoOmAn+aSreaUviArMC4xJywKICAgICAga2V5OiAnYycsCiAgICAgIGNvbW1hbmQ6ICdzZXRQbGF5YmFja1JhdGVVcCcKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfmraPluLjpgJ/luqbmkq3mlL4nLAogICAgICBrZXk6ICd6JywKICAgICAgY29tbWFuZDogJ3Jlc2V0UGxheWJhY2tSYXRlJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+iuvue9rjF455qE5pKt5pS+6YCf5bqmJywKICAgICAga2V5OiAnRGlnaXQxJywKICAgICAgY29tbWFuZDogJ3NldFBsYXliYWNrUmF0ZVBsdXMnLAogICAgICBhcmdzOiAxCiAgICB9LAogICAgewogICAgICBkZXNjOiAn6K6+572uMXjnmoTmkq3mlL7pgJ/luqYnLAogICAgICBrZXk6ICdOdW1wYWQxJywKICAgICAgY29tbWFuZDogJ3NldFBsYXliYWNrUmF0ZVBsdXMnLAogICAgICBhcmdzOiAxCiAgICB9LAogICAgewogICAgICBkZXNjOiAn6K6+572uMnjnmoTmkq3mlL7pgJ/luqYnLAogICAgICBrZXk6ICdEaWdpdDInLAogICAgICBjb21tYW5kOiAnc2V0UGxheWJhY2tSYXRlUGx1cycsCiAgICAgIGFyZ3M6IDIKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICforr7nva4yeOeahOaSreaUvumAn+W6picsCiAgICAgIGtleTogJ051bXBhZDInLAogICAgICBjb21tYW5kOiAnc2V0UGxheWJhY2tSYXRlUGx1cycsCiAgICAgIGFyZ3M6IDIKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICforr7nva4zeOeahOaSreaUvumAn+W6picsCiAgICAgIGtleTogJ0RpZ2l0MycsCiAgICAgIGNvbW1hbmQ6ICdzZXRQbGF5YmFja1JhdGVQbHVzJywKICAgICAgYXJnczogMwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+iuvue9rjN455qE5pKt5pS+6YCf5bqmJywKICAgICAga2V5OiAnTnVtcGFkMycsCiAgICAgIGNvbW1hbmQ6ICdzZXRQbGF5YmFja1JhdGVQbHVzJywKICAgICAgYXJnczogMwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+iuvue9rjR455qE5pKt5pS+6YCf5bqmJywKICAgICAga2V5OiAnRGlnaXQ0JywKICAgICAgY29tbWFuZDogJ3NldFBsYXliYWNrUmF0ZVBsdXMnLAogICAgICBhcmdzOiA0CiAgICB9LAogICAgewogICAgICBkZXNjOiAn6K6+572uNHjnmoTmkq3mlL7pgJ/luqYnLAogICAgICBrZXk6ICdOdW1wYWQ0JywKICAgICAgY29tbWFuZDogJ3NldFBsYXliYWNrUmF0ZVBsdXMnLAogICAgICBhcmdzOiA0CiAgICB9LAogICAgewogICAgICBkZXNjOiAn5LiL5LiA5binJywKICAgICAga2V5OiAnRicsCiAgICAgIGNvbW1hbmQ6ICdmcmVlemVGcmFtZScsCiAgICAgIGFyZ3M6IDEKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICfkuIrkuIDluKcnLAogICAgICBrZXk6ICdEJywKICAgICAgY29tbWFuZDogJ2ZyZWV6ZUZyYW1lJywKICAgICAgYXJnczogLTEKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflop7liqDkuq7luqYnLAogICAgICBrZXk6ICdFJywKICAgICAgY29tbWFuZDogJ3NldEJyaWdodG5lc3NVcCcKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflh4/lsJHkuq7luqYnLAogICAgICBrZXk6ICdXJywKICAgICAgY29tbWFuZDogJ3NldEJyaWdodG5lc3NEb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WinuWKoOWvueavlOW6picsCiAgICAgIGtleTogJ1QnLAogICAgICBjb21tYW5kOiAnc2V0Q29udHJhc3RVcCcKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflh4/lsJHlr7nmr5TluqYnLAogICAgICBrZXk6ICdSJywKICAgICAgY29tbWFuZDogJ3NldENvbnRyYXN0RG93bicKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflop7liqDppbHlkozluqYnLAogICAgICBrZXk6ICdVJywKICAgICAgY29tbWFuZDogJ3NldFNhdHVyYXRpb25VcCcKICAgIH0sCiAgICB7CiAgICAgIGRlc2M6ICflh4/lsJHppbHlkozluqYnLAogICAgICBrZXk6ICdZJywKICAgICAgY29tbWFuZDogJ3NldFNhdHVyYXRpb25Eb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WinuWKoOiJsuebuCcsCiAgICAgIGtleTogJ08nLAogICAgICBjb21tYW5kOiAnc2V0SHVlVXAnCiAgICB9LAogICAgewogICAgICBkZXNjOiAn5YeP5bCR6Imy55u4JywKICAgICAga2V5OiAnSScsCiAgICAgIGNvbW1hbmQ6ICdzZXRIdWVEb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+aooeeziuWinuWKoCAxIHB4JywKICAgICAga2V5OiAnSycsCiAgICAgIGNvbW1hbmQ6ICdzZXRCbHVyVXAnCiAgICB9LAogICAgewogICAgICBkZXNjOiAn5qih57OK5YeP5bCRIDEgcHgnLAogICAgICBrZXk6ICdKJywKICAgICAgY29tbWFuZDogJ3NldEJsdXJEb3duJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+WbvuWDj+WkjeS9jScsCiAgICAgIGtleTogJ1EnLAogICAgICBjb21tYW5kOiAncmVzZXRGaWx0ZXJBbmRUcmFuc2Zvcm0nCiAgICB9LAogICAgewogICAgICBkZXNjOiAn55S76Z2i5peL6L2sIDkwIOW6picsCiAgICAgIGtleTogJ1MnLAogICAgICBjb21tYW5kOiAnc2V0Um90YXRlJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+aSreaUvuS4i+S4gOmbhicsCiAgICAgIGtleTogJ04nLAogICAgICBjb21tYW5kOiAnc2V0TmV4dFZpZGVvJwogICAgfSwKICAgIHsKICAgICAgZGVzYzogJ+aJp+ihjEpT6ISa5pysJywKICAgICAga2V5OiAnY3RybCtqIGN0cmwrcycsCiAgICAgIGNvbW1hbmQ6ICgpID0+IHsKIC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vbmYpIH0KfTsKCi8qIOS/neWtmOmHjeimgeeahOWOn+Wni+WHveaVsO+8jOmYsuatouiiq+WklumDqOiEmuacrOaxoeafkyAqLwpjb25zdCBvcmlnaW5hbE1ldGhvZHMgPSB7CiAgT2JqZWN0OiB7CiAgICBkZWZpbmVQcm9wZXJ0eTogT2JqZWN0LmRlZmluZVByb3BlcnR5LAogICAgZGVmaW5lUHJvcGVydGllczogT2JqZWN0LmRlZmluZVByb3BlcnRpZXMKICB9LAogIHNldEludGVydmFsOiB3aW5kb3cuc2V0SW50ZXJ2YWwsCiAgc2V0VGltZW91dDogd2luZG93LnNldFRpbWVvdXQKfTsKCi8qKgogKiDku7vliqHphY3nva7kuK3lv4MgVGFzayBDb250cm9sIENlbnRlcgogKiDnlKjkuo7phY3nva7miYDmnInml6Dms5Xov5vooYzpgJrnlKjlpITnkIbnmoTku7vliqHvvIzlpoLkuI3lkIznvZHnq5nnmoTlhajlsY/mlrnlvI/kuI3kuIDmoLfvvIzlv4XpobvosIPnlKjnvZHnq5nmnKzouqvnmoTlhajlsY/pgLvovpHvvIzmiY3og73noa7kv53lrZfluZXjgIHlvLnluZXnrYnmraPluLjlt6XkvZwKICoqLwoKY2xhc3MgVENDIHsKICBjb25zdHJ1Y3RvciAodGFza0NvbmYsIGRvVGFza0Z1bmMpIHsKICAgIHRoaXMuY29uZiA9IHRhc2tDb25mIHx8IHsKICAgICAgLyoqCiAgICAgICAqIOmFjee9ruekuuS+iwogICAgICAgKiDniLbnuqfplK7lkI3lr7nlupTnmoTmmK/kuIDnuqfln5/lkI3vvIwKICAgICAgICog5a2Q57qn6ZSu5ZCN5a+55bqU55qE55u45YWz5Yqf6IO95ZCN56ew77yM6ZSu5YC85a+55bqU55qE6K+l5Yqf6IO96KaB6Kem5Y+R55qE54K55Ye76YCJ5oup5Zmo5oiW6ICF6KaB6LCD55So55qE55u45YWz5Ye95pWwCiAgICAgICAqIOaJgOacieWtkOe6p+eahOmUruWAvOmDveaUr+aMgeS9v+eUqOmAieaLqeWZqOinpuWPkeaIluWHveaVsOiwg+eUqAogICAgICAgKiDphY3nva7kuoblrZDnuqfnmoTliJnkvb/nlKjlrZDnuqfphY3nva7pgLvovpHov5vooYzmk43kvZzvvIzlkKbliJnkvb/nlKjpu5jorqTpgLvovpEKICAgICAgICog5rOo5oSP77yaaW5jbHVkZe+8jGV4Y2x1ZGXov5nkuKTkuKrlrZDnuqfplK7lkI3pmaTlpJbvvIzov5nkuKTkuKrmmK/nlKjmnaXov5vooYx1cmzojIPlm7TljLnphY3nmoQKICAgICAgICogKi8KICAgICAgJ2RlbW8uZGVtbyc6IHsKICAgICAgICBmdWxsU2NyZWVuOiAnLmZ1bGxzY3JlZW4tYnRuJywKICAgICAgICBleGl0RnVsbFNjcmVlbjogJy5leGl0LWZ1bGxzY3JlZW4tYnRuJywKICAgICAgICB3ZWJGdWxsU2NyZWVuOiBmdW5jdGlvbiAoKSB7fSwKICAgICAgICBleGl0V2ViRnVsbFNjcmVlbjogJy5leGl0LWZ1bGxzY3JlZW4tYnRuJywKICAgICAgICBhdXRvUGxheTogJy5wbGF5ZXItc3RhcnQtYnRuJywKICAgICAgICBwYXVzZTogJy5wbGF5ZXItcGF1c2UnLAogICAgICAgIHBsYXk6ICcucGxheWVyLXBsYXknLAogICAgICAgIHN3aXRjaFBsYXlTdGF0dXM6ICcucGxheWVyLXBsYXknLAogICAgICAgIHBsYXliYWNrUmF0ZTogZnVuY3Rpb24gKCkge30sCiAgICAgICAgY3VycmVudFRpbWU6IGZ1bmN0aW9uICgpIHt9LAogICAgICAgIGFkZEN1cnJlbnRUaW1lOiAnLmFkZC1jdXJyZW50dGltZScsCiAgICAgICAgc3VidHJhY3RDdXJyZW50VGltZTogJy5zdWJ0cmFjdC1jdXJyZW50dGltZScsCiAgICAgICAgLy8g6Ieq5a6a5LmJ5b+r5o236ZSu55qE5omn6KGM5pa55byP77yM5aaC5p6c5piv57uE5ZCI6ZSu77yM5b+F6aG75pivIGN0cmwtLT5zaGlmdC0tPmFsdCDov5nmoLfnmoTpobrluo/vvIzmsqHmnInlj6/ku6Xlv73nlaXvvIzplK7lkI3lv4XpobvlhajlsI/lhpkKICAgICAgICBzaG9ydGN1dHM6IHsKICAgICAgICAgIC8qIOazqOWGjOimgeaJp+ihjOiHquWumuS5ieWbnuiwg+aTjeS9nOeahOW/q+aNt+mUriAqLwogICAgICAgICAgcmVnaXN0ZXI6IFsKICAgICAgICAgICAgJ2N0cmwrc2hpZnQrYWx0K2MnLAogICAgICAgICAgICAnY3RybCtzaGlmdCtjJywKICAgICAgICAgICAgJ2N0cmwrYWx0K2MnLAogICAgICAgICAgICAnY3RybCtjJywKICAgICAgICAgICAgJ2MnCiAgICAgICAgICBdLAogICAgICAgICAgLyog6Ieq5a6a5LmJ5b+r5o236ZSu55qE5Zue6LCD5pON5L2cICovCiAgICAgICAgICBjYWxsYmFjazogZnVuY3Rpb24gKGg1UGxheWVyLCB0YXNrQ29uZiwgZGF0YSkgewogICAgICAgICAgICBjb25zdCB7IGV2ZW50LCBwbGF5ZXIgfSA9IGRhdGE7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKGV2ZW50LCBwbGF5ZXIpOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgLyog5b2T5YmN5Z+f5ZCN5LiL6ZyA5YyF5ZCr55qE6Lev5b6E5L+h5oGv77yM6buY6K6k5pW05Liq5Z+f5ZCN5LiL5omA5pyJ6Lev5b6E5Y+v55SoIOW/hemhu+aYr+ato+WImSAqLwogICAgICAgIGluY2x1ZGU6IC9eLiovLAogICAgICAgIC8qIOW9k+WJjeWfn+WQjeS4i+mcgOaOkumZpOeahOi3r+W+hOS/oeaBr++8jOm7mOiupOS4jeaOkumZpOS7u+S9lei3r+W+hCDlv4XpobvmmK/mraPliJkgKi8KICAgICAgICBleGNsdWRlOiAvXHQvCiAgICAgIH0KICAgIH07CgogICAgLy8g6YCa6L+HZG9UYXNrRnVuY+Wbnuiwg+WumuS5iemFjee9ruivpeW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uaW5jbHVkZSAmJiAhdGFza0NvbmYuZXhjbHVkZSkgewogICAgICBpc01hdGNoID0gdHJ1ZTsKICAgIH0gZWxzZSB7CiAgICAgIGlmICh0YXNrQ29uZi5pbmNsdWRlICYmIHRhc2tDb25mLmluY2x1ZGUudGVzdCh1cmwpKSB7CiAgICAgICAgaXNNYXRjaCA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRhc2tDb25mLmV4Y2x1ZGUgJiYgdGFza0NvbmYuZXhjbHVkZS50ZXN0KHVybCkpIHsKICAgICAgICBpc01hdGNoID0gZmFsc2U7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBpc01hdGNoCiAgfQoKICAvKioKICAgKiDojrflj5bku7vliqHphY3nva7vvIzlj6rog73ojrflj5bliLDlvZPliY3ln5/lkI3kuIvnmoTku7vliqHphY3nva7kv6Hmga8KICAgKiBAcGFyYW0gdGFza05hbWUge3N0cmluZ30gLeWPr+mAiSDmjIflrprlhbfkvZPku7vliqHvvIzpu5jorqTov5Tlm57miYDmnInnsbvlnovnmoTku7vliqHphY3nva4KICAgKi8KICBnZXRUYXNrQ29uZmlnICgpIHsKICAgIGNvbnN0IHQgPSB0aGlzOwogICAgaWYgKCF0Ll9oYXNGb3JtYXRUQ0NfKSB7CiAgICAgIHQuZm9ybWF0VENDKCk7CiAgICAgIHQuX2hhc0Zvcm1hdFRDQ18gPSB0cnVlOwogICAgfQogICAgY29uc3QgZG9tYWluID0gdC5nZXREb21haW4oKTsKICAgIGNvbnN0IHRhc2tDb25mID0gdC5jb25mW3dpbmRvdy5sb2NhdGlvbi5ob3N0XSB8fCB0LmNvbmZbZG9tYWluXTsKCiAgICBpZiAodGFza0NvbmYgJiYgdC5pc01hdGNoKHRhc2tDb25mKSkgewogICAgICByZXR1cm4gdGFza0NvbmYKICAgIH0KCiAgICByZXR1cm4ge30KICB9CgogIC8qKgogICAqIOaJp+ihjOW9k+WJjemhtemdouS4i+eahOebuOW6lOS7u+WKoQogICAqIEBwYXJ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CiAgICAgICAgYXJnLnVuc2hpZnQoYCVjIFske0h9OiR7TX06JHtTfV0gJHttc2d9IGApOwogICAgICB9IGVsc2UgewogICAgICAgIGFyZy51bnNoaWZ0KGAlYyAke21zZ30gYCk7CiAgICAgIH0KCiAgICAgIHdpbmRvdy5jb25zb2xlW25hbWVdLmFwcGx5KHdpbmRvdy5jb25zb2xlLCBhcmcpOwogICAgfQogIH0KCiAgaXNEZWJ1Z01vZGUgKCkgewogICAgcmV0dXJuIEJvb2xlYW4od2luZG93Ll9kZWJ1Z01vZGVfKQogIH0KfQoKdmFyIERlYnVnJDEgPSBuZXcgRGVidWcoKTsKCnZhciBkZWJ1ZyA9IERlYnVnJDEuY3JlYXRlKCdoNXBsYXllciBtZXNzYWdlOicpOwoKY29uc3QgJHEgPSBmdW5jdGlvbiAoc3RyKSB7IHJldHVybiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKHN0cikgfTsKCi8qKgogKiDku7vliqHphY3nva7kuK3lv4MgVGFzayBDb250cm9sIENlbnRlcgogKiDnlKjkuo7phY3nva7miYDmnInml6Dms5Xov5vooYzpgJrnlKjlpITnkIbnmoTku7vliqHvvIzlpoLkuI3lkIznvZHnq5nnmoTlhajlsY/mlrnlvI/kuI3kuIDmoLfvvIzlv4XpobvosIPnlKjnvZHnq5nmnKzouqvnmoTlhajlsY/pgLvovpHvvIzmiY3og73noa7kv53lrZfluZXjgIHlvLnluZXnrYnmraPluLjlt6XkvZwKICogKi8KCmNvbnN0IHRhc2tDb25mID0gewogIC8qKgogICAqIOmFjee9ruekuuS+iwogICAqIOeItue6p+mUruWQjeWvueW6lOeahOaYr+S4gOe6p+Wfn+WQje+8jAogICAqIOWtkOe6p+mUruWQjeWvueW6lOeahOebuOWFs+WKn+iDveWQjeensO+8jOmUruWAvOWvueW6lOeahOivpeWKn+iDveimgeinpuWPkeeahOeCueWHu+mAieaLqeWZqOaIluiAheimgeiwg+eUqOeahOebuOWFs+WHveaVsAogICAqIOaJgOacieWtkO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dGlvbiAoKSB7fSwKICAgIC8vIHBsYXliYWNrUmF0ZTogdHJ1ZSwgLy8g5b2T57uZ5p+Q5Liq5Yqf6IO96K6+572udHJ1ZeaXtu+8jOihqOekuuS9v+eUqOe9keermeiHqui6q+eahOiDveWKm+aOp+WItuinhumike+8jOiAjOW/veeVpeaPkuS7tueahOiDveWKmwogICAgY3VycmVudFRpbWU6IGZ1bmN0aW9uICgpIHt9LAogICAgYWRkQ3VycmVudFRpbWU6ICcuYWRkLWN1cnJlbnR0aW1lJywKICAgIHN1YnRyYWN0Q3VycmVudFRpbWU6ICcuc3VidHJhY3QtY3VycmVudHRpbWUnLAogICAgLy8g6Ieq5a6a5LmJ5b+r5o236ZSu55qE5omn6KGM5pa55byP77yM5aaC5p6c5piv57uE5ZCI6ZSu77yM5b+F6aG75pivIGN0cmwtLT5zaGlmdC0tPmFsdCDov5nmoLfnmoTpobrluo/vvIzmsqHmnInlj6/ku6Xlv73nlaXvvIzplK7lkI3lv4XpobvlhajlsI/lhpkKICAgIHNob3J0Y3V0czogewogICAgICAvKiDms6jlhozopoHmiafooYzoh6rlrprkuYnlm57osIPmk43kvZznmoTlv6vmjbfplK4gKi8KICAgICAgcmVnaXN0ZXI6IFsKICAgICAgICAnY3RybCtzaGlmdCthbHQrYycsCiAgICAgICAgJ2N0cmwrc2hpZnQrYycsCiAgICAgICAgJ2N0cmwrYWx0K2MnLAogICAgICAgICdjdHJsK2MnLAogICAgICAgICdjJwogICAgICBdLAogICAgICAvKiDoh6rlrprkuYnlv6vmjbfplK7nmoTlm57osIPmk43kvZwgKi8KICAgICAgY2FsbGJhY2s6IGZ1bmN0aW9uIChoNVBsYXllciwgdGFza0NvbmYsIGRhdGEpIHsKICAgICAgICBjb25zdCB7IGV2ZW50LCBwbGF5ZXIgfSA9IGRhdGE7CiAgICAgICAgY29uc29sZS5sb2coZXZlbnQsIHBsYXllcik7CiAgICAgIH0KICAgIH0sCgogICAgLyog6Zi75q2i572R56uZ6Ieq6Lqr55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0IHsgZXZlbnQgfSA9IGRhdGE7CiAgICAgICAgaWYgKGV2ZW50LmtleUNvZGUgPT09IDI3KSB7CiAgICAgICAgICAvKiDlj5bmtojmkq3mlL7kuIvkuIDkuKrmjqjojZDnmoTop4bpopEgKi8KICAgICAgICAgIGlmIChkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcueXRwLXVwbmV4dCcpLnN0eWxlLmRpc3BsYXkgIT09ICdub25lJykgewogICAgICAgICAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcueXRwLXVwbmV4dC1jYW5jZWwtYnV0dG9uJykuY2xpY2soKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9LAogICduZXRmbGl4LmNvbSc6IHsKICAgIC8vIOWBnOatouWcqG5ldGZsaXjkuIvkvb/nlKjmj5Lku7bnmoTmiYDmnInlip/og70KICAgIC8vIGRpc2FibGU6IHRydWUsCiAgICBmdWxsU2NyZWVuOiAnYnV0dG9uLmJ1dHRvbi1uZnBsYXllckZ1bGxzY3JlZW4nLAogICAgYWRkQ3VycmVudFRpbWU6ICdidXR0b24uYnV0dG9uLW5mcGxheWVyRmFzdEZvcndhcmQnLAogICAgc3VidHJhY3RDdXJyZW50VGltZTogJ2J1dHRvbi5idXR0b24tbmZwbGF5ZXJCYWNrVGVuJywKICAgIC8qKgogICAgICog5L2/55SobmV0ZmxpeOiHqui6q+eahOiwg+mAn++8jOWboOS4uuebruWJjeaPkuS7tuayoeazleino+WGs+iwg+mAn+WvvOiHtOeahOacjeWKoeS4reaWremXrumimAogICAgICogaHR0cHM6Ly9naXRodWIuY29tL3h4eGlseS9oNXBsYXllci9pc3N1ZXMvMjM0CiAgICAgKiBodHRwczovL2dpdGh1Yi5jb20veHh4aWx5L2g1cGxheWVyL2lzc3Vlcy8zMTcKICAgICAqIGh0dHBzOi8vZ2l0aHViLmNvbS94eHhpbHkvaDVwbGF5ZXIvaXNzdWVzLzM4MQogICAgICogaHR0cHM6Ly9naX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V4dDogJy5jb250cm9sLW5leHQtdmlkZW8nLAogICAgaW5pdDogZnVuY3Rpb24gKGg1UGxheWVyLCB0YXNrQ29uZikgewogICAgICAvLyDpmpDol4/msLTljbAKICAgICAgaGlkZURvbSgnLnlvdWt1LWxheWVyLWxvZ28nKTsKICAgIH0KICB9LAogICd0ZWQuY29tJzogewogICAgZnVsbFNjcmVlbjogJ2J1dHRvbi5GdWxsc2NyZWVuJwogIH0sCiAgJ3FxLmNvbSc6IHsKICAgIHBhdXNlOiAnLmNvbnRhaW5lcl9pbm5lciAudHhwLXNoYWRvdy1tb2QnLAogICAgcGxheTogJy5jb250YWluZXJfaW5uZXIgLnR4cC1zaGFkb3ctbW9kJywKICAgIHNob3J0Y3V0czogewogICAgICByZWdpc3RlcjogWydjJywgJ3gnLCAneicsICcxJywgJzInLCAnMycsICc0J10sCiAgICAgIGNhbGxiYWNrOiBmdW5jdGlvbiAoaDVQbGF5ZXIsIHRhc2tDb25mLCBkYXRhKSB7CiAgICAgICAgY29uc3QgeyBldmVudCB9ID0gZGF0YTsKICAgICAgICBjb25zdCBrZXkgPSBldmVudC5rZXkudG9Mb3dlckNhc2UoKTsKICAgICAgICBjb25zdCBrZXlOYW1lID0gJ2N1c3RvbVNob3J0Y3V0c18nICsga2V5OwoKICAgICAgICBpZiAoIWg1UGxheWVyW2tleU5hbWVdKSB7CiAgICAgICAgICAvKiDnrKzkuIDmrKHmjInkuIvlv6vmjbfplK7kvb/nlKjpu5jorqTpgLvovpHov5vooYzosIPpgJ8gKi8KICAgICAgICAgIGg1UGxheWVyW2tleU5hbWVdID0gewogICAgICAgICAgICB0aW1lOiBEYXRlLm5vdygpLAogICAgICAgICAgICBwbGF5YmFja1JhdGU6IGg1UGxheWVyLnBsYXliYWNrUmF0ZQogICAgICAgICAgfTsKICAgICAgICAgIHJldHVybiBmYWxzZQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvKiDnrKzkuIDmrKHmk43kvZzlkI7nmoQyMDBtc+WGheeahOaTjeS9nOmDveaYr+eUsem7mOiupOmAu+i+kei/m+ihjOiwg+mAnyAqLwogICAgICAgICAgaWYgKERhdGUubm93KCkgLSBoNVBsYXllcltrZXlOYW1lXS50aW1lIDwgMjAwKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZQogICAgICAgICAgfQoKICAgICAgICAgIC8qIOWIpOaWreaYr+WQpumcgOi/m+ihjOmZjee6p+WkhOeQhu+8jOWIqeeUqHNlc3Npb25TdG9yYWdl6L+b6KGM6LCD6YCfICovCiAgICAgICAgICBpZiAoaDVQbGF5ZXJba2V5TmFtZV0gPT09IGg1UGxheWVyLnBsYXliYWNrUmF0ZSB8fCBoNVBsYXllcltrZXlOYW1lXSA9PT0gdHJ1ZSkgewogICAgICAgICAgICBpZiAod2luZG93LnNlc3Npb25TdG9yYWdlLnBsYXliYWNrUmF0ZSAmJiAvKGN8eHx6fDF8MnwzfDQpLy50ZXN0KGtleSkpIHsKICAgICAgICAgICAgICBjb25zdCBjdXJTcGVlZCA9IE51bWJlcih3aW5kb3cuc2Vzc2lvblN0b3JhZ2UucGxheWJhY2tSYXRlKTsKICAgICAgICAgICAgICBjb25zdCBwZXJTcGVlZCA9IGN1clNwZWVkIC0gMC4xID49IDAgPyBjdXJTcGVlZCAtIDAuMSA6IDAuMTsKICAgICAgICAgICAgICBjb25zdCBuZXh0U3BlZWQgPSBjdXJTcGVlZCArIDAuMSA8PSA0ID8gY3VyU3BlZWQgKyAwLjEgOiA0OwogICAgICAgICAgICAgIGxldCB0YXJnZXRTcGVlZCA9IGN1clNwZWVkOwogICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICBjYXNlICd6JyA6CiAgICAgICAgICAgICAgICAgIHRhcmdldFNwZWVkID0gMTsKICAgICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgICAgIGNhc2UgJ2MnIDoKICAgICAgICAgICAgICAgICAgdGFyZ2V0U3BlZWQgPSBuZXh0U3BlZWQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgICAgICBjYXNlICd4JyA6CiAgICAgICAgICAgICAgICAgIHRhcmdldFNwZWVkID0gcGVyU3BlZWQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgICAgICBkZWZhdWx0IDoKICAgICAgICAgICAgICAgICAgdGFyZ2V0U3BlZWQgPSBOdW1iZXIoa2V5KTsKICAgICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgIHdpbmRvdy5zZXNzaW9uU3RvcmFnZS5wbGF5YmFja1JhdGUgPSB0YXJnZXRTcGVlZDsKICAgICAgICAgICAgICBoNVBsYXllci5zZXRDdXJyZW50VGltZSgwLjAxLCB0cnVlKTsKICAgICAgICAgICAgICBoNVBsYXllci5zZXRQbGF5YmFja1JhdGUodGFyZ2V0U3BlZWQsIHRydWUpOwogICAgICAgICAgICAgIHJldHVybiB0cnVlCiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8qIOagh+ivhum7mOiupOiwg+mAn+aWueahiOWkseaViO+8jOmcgOWQr+eUqHNlc3Npb25TdG9yYWdl6LCD6YCf5pa55qGIICovCiAgICAgICAgICAgIGg1UGxheWVyW2tleU5hbWVdID0gdHJ1ZTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8qIOagh+ivhum7mOiupOiwg+mAn+aWueahiOeUn+aViCAqLwogICAgICAgICAgICBoNVBsYXllcltrZXlOYW1lXSA9IGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIGZ1bGxTY3JlZW46ICd0eHBkaXZbZGF0YS1yZXBvcnQ9IndpbmRvdy1mdWxsc2NyZWVuIl0nLAogICAgd2ViRnVsbFNjcmVlbjogJ3R4cGRpdltkYXRhLXJlcG9ydD0iYnJvd3Nlci1mdWxsc2NyZWVuIl0nLAogICAgbmV4dDogJ3R4cGRpdltkYXRhLXJlcG9ydD0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BhcmVudE5vZGUuY2xpY2soKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gdHJ1ZQogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgfSwKICAnZG91eXUuY29tJzogewogICAgZnVsbFNjcmVlbjogZnVuY3Rpb24gKGg1UGxheWVyLCB0YXNrQ29uZikgewogICAgICBjb25zdCBwbGF5ZXIgPSBoNVBsYXllci5wbGF5ZXIoKTsKICAgICAgY29uc3QgY29udGFpbmVyID0gcGxheWVyLl9mdWxsU2NyZWVuXy5nZXRDb250YWluZXIoKTsKICAgICAgaWYgKHBsYXllci5faXNGdWxsU2NyZWVuXykgewogICAgICAgIGNvbnRhaW5lci5xdWVyeVNlbGVjdG9yKCdkaXZbdGl0bGU9IumAgOWHuueql+WPo+WFqOWxjyJdJykuY2xpY2soKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb250YWluZXIucXVlcnlTZWxlY3RvcignZGl2W3RpdGxlPSLnqpflj6PlhajlsY8iXScpLmNsaWNrKCk7CiAgICAgIH0KICAgICAgcGxheWVyLl9pc0Z1bGxTY3JlZW5fID0gIXBsYXllci5faXNGdWxsU2NyZWVuXzsKICAgICAgcmV0dXJuIHRydWUKICAgIH0sCiAgICB3ZWJGdWxsU2NyZWVuOiBmdW5jdGlvbiAoaDVQbGF5ZXIsIHRhc2tDb25mKSB7CiAgICAgIGNvbnN0IHBsYXllciA9IGg1UGxheWVyLnBsYXllcigpOwogICAgICBjb25zdCBjb250YWluZXIgPSBwbGF5ZXIuX2Z1bGxTY3JlZW5fLmdldENvbnRhaW5lcigpOwogICAgICBpZiAocGxheWVyLl9pc1dlYkZ1bGxTY3JlZW5fKSB7CiAgICAgICAgY29udGFpbmVyLnF1ZXJ5U2VsZWN0b3IoJ2Rpdlt0aXRsZT0i6YCA5Ye6572R6aG15YWo5bGPIl0nKS5jbGljaygpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRhaW5lci5xdWVyeVNlbGV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Xllci5wYXJlbnROb2RlLnBhcmVudE5vZGUpIHsKICAgICAgICBjb25zdCBtYXNrV3JhcCA9IHBsYXllci5wYXJlbnROb2RlLnBhcmVudE5vZGUucXVlcnlTZWxlY3RvcignZGl2fmRpdjpudGgtY2hpbGQoMyknKTsKICAgICAgICBpZiAobWFza1dyYXApIHsKICAgICAgICAgIGNvbnN0IG1hc2sgPSBtYXNrV3JhcC5xdWVyeVNlbGVjdG9yKCdkaXYnKTsKICAgICAgICAgIGlmIChtYXNrICYmIG1hc2suaW5uZXJUZXh0ID09PSAnJykgewogICAgICAgICAgICBtYXNrLmNsaWNrKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgaW5pdDogZnVuY3Rpb24gKGg1UGxheWVyLCB0YXNrQ29uZikgewogICAgICBoNVBsYXllci5wbGF5ZXIoKS5zZXRBdHRyaWJ1dGUoJ2Nyb3NzT3JpZ2luJywgJ2Fub255bW91cycpOwogICAgfQogIH0sCiAgJ3dlaWJvLmNvbSc6IHsKICAgIGZ1bGxTY3JlZW46IFsnYnV0dG9uLndicHYtZnVsbHNjcmVlbi1jb250cm9sJ10sCiAgICAvLyB3ZWJGdWxsU2NyZWVuOiBbJ2Rpdlt0aXRsZT0i5YWz6Zet5by55bGCIl0nLCAnZGl2LndicHYtb3Blbi1sYXllci1idXR0b24nXQogICAgd2ViRnVsbFNjcmVlbjogWydkaXYud2Jwdi1vcGVuLWxheWVyLWJ1dHRvbiddCiAgfQp9OwoKZnVuY3Rpb24gaDVQbGF5ZXJUY2NJbml0IChoNVBsYXllcikgewogIHJldHVybiBuZXcgVENDKHRhc2tDb25mLCBmdW5jdGlvbiAodGFza05hbWUsIHRhc2tDb25mLCBkYXRhKSB7CiAgICB0cnkgewogICAgICBjb25zdCB0YXNrID0gdGFza0NvbmZbdGFza05hbWVdOwogICAgICBjb25zdCB3cmFwRG9tID0gaDVQbGF5ZXIuZ2V0UGxheWVyV3JhcERvbSgpOwoKICAgICAgaWYgKCF0YXNrKSB7IHJldHVybiB9CgogICAgICBpZiAodGFza05hbWUgPT09ICdzaG9ydGN1dHMnKSB7CiAgICAgICAgaWYgKGlzT2JqKHRhc2spICYmIHRhc2suY2FsbGJhY2sgaW5zdGFuY2VvZiBGdW5jdGlvbikgewogICAgICAgICAgcmV0dXJuIHRhc2suY2FsbGJhY2soaDVQbGF5ZXIsIHRhc2tDb25mLCBkYXRhKQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmICh0YXNrIGluc3RhbmNlb2YgRnVuY3Rpb24pIHsKICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuIHRhc2soaDVQbGF5ZXIsIHRhc2tDb25mLCBkYXRhKQogICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgIGRlYnVnLmVycm9yKCfku7vliqHphY3nva7kuK3lv4PnmoToh6rlrprkuYnlh73mlbDmiafooYzlpLHotKXvvJonLCB0YXNrTmFtZSwgdGFza0NvbmYsIGRhdGEsIGUpOwogICAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHR5cGVvZiB0YXNrID09PSAnYm9vbGVhbicpIHsKICAgICAgICByZXR1cm4gdGFzawogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IHNlbGVjdG9yTGlzdCA9IEFycmF5LmlzQXJyYXkodGFzaykgPyB0YXNrIDogW3Rhc2tdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2VsZWN0b3JMaXN0Lmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzZWxlY3RvciA9IHNlbGVjdG9yTGlzdFtpXTsKCiAgICAgICAgICAvKiDop6blj5HpgInmi6nlmajkuIrnmoTngrnlh7vkuovku7YgKi8KICAgICAgICAgIGlmICh3cmFwRG9tICYmIHdyYXBEb20ucXVlcnlTZWxlY3RvcihzZWxlY3RvcikpIHsKICAgICAgICAgIC8vIOWcqHZpZGVv55qE54i25YWD57Sg6YeM5p+l5om+77yM5piv5Li65LqG5bC95Y+v6IO95YW85a655aSa5a6e5L6L5LiL55qE6YC76L6RCiAgICAgICAgICAgIHdyYXBEb20ucXVlcnlTZWxlY3RvcihzZWxlY3RvcikuY2xpY2soKTsKICAgICAgICAgICAgcmV0dXJuIHRydWUKICAgICAgICAgIH0gZWxzZSBpZiAoZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3RvcikpIHsKICAgICAgICAgICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3RvcikuY2xpY2soKTsKICAgICAgICAgICAgcmV0dXJuIHRydWUKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgZGVidWcuZXJyb3IoJ+S7u+WKoemFjee9ruS4reW/g+eahOiHquWumuS5ieS7u+WKoeaJp+ihjOWksei0pe+8micsIHRhc2tOYW1lLCB0YXNrQ29uZiwgZGF0YSwgZSk7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQogIH0pCn0KCmZ1bmN0aW9uIG1lcmdlVGFza0NvbmYgKGNvbmZpZykgewogIHJldHVybiBtZXJnZU9iaih0YXNrQ29uZiwgY29uZmlnKQp9CgovKiB1YeS8quijhemFjee9riAqLwpjb25zdCBmYWtlQ29uZmlnID0gewogIC8vICd0di5jY3R2LmNvbSc6IHVzZXJBZ2VudE1hcC5pUGhvbmUuY2hyb21lLAogIC8vICd2LnFxLmNvbSc6IHVzZXJBZ2VudE1hcC5pUGFkLmNocm9tZSwKICAnb3Blbi4xNjMuY29tJzogdXNlckFnZW50TWFwLmlQaG9uZS5jaHJvbWUsCiAgJ20ub3Blbi4xNjMuY29tJzogdXNlckFnZW50TWFwLmlQaG9uZS5jaHJvbWUsCiAgLyog55m+5bqm55uY55qE6Z2e5Lya5ZGY5Lya5L2/55So6Ieq6Lqr55qE5LiT55So5pKt5pS+5Zmo77yM5a+86Ie05rKh5rOV5L2/55SoaDVwbGF5ZXLvvIzmiYDku6XpnIDopoHpgJrov4fkvKroo4V1Yeadpeino+WGs+ivpemXrumimCAqLwogICdwYW4uYmFpZHUuY29tJzogdXNlckFnZW50TWFwLmlQaG9uZS5zYWZhcmkKfTsKCmZ1bmN0aW9uIHNldEZha2VVQSAodWEpIHsKICBjb25zdCBob3N0ID0gd2luZG93LmxvY2F0aW9uLmhvc3Q7CiAgdWEgPSB1YSB8fCBmYWtlQ29uZmlnW2hvc3RdOwoKICAvKioKICAgKiDliqjmgIHliKTmlq3mmK/lkKbpnIDopoHov5vooYx1YeS8quijhQogICAqIOS4i+mdouaWueahiOaaguaXtuS4jeWPr+eUqAogICAqIOeUseS6jumDqOWIhue9keermei3s+i9rOiHs+enu+WKqOerr+WQjuWfn+WQjeS4jeS4gOiHtO+8jOW9ouaIkOi3qOWfn+mXrumimAogICAqIOWvvOiHtOaXoOazleWQjOatpeS8quijhemFjee9ruiAjOS4jeaWreatu+W+queOr+i3s+i9rAogICAqIGVnLiBvcGVuLjE2My5jb20KICAgKiAqLwogIC8vIGxldCBjdXN0b21VQSA9IHdpbmRvdy5sb2NhbFN0b3JhZ2UuZ2V0SXRlbSgnX2g1X3BsYXllcl91c2VyX2FnZW50XycpCiAgLy8gZGVidWcubG9nKGN1c3RvbVVBLCB3aW5kb3cubG9jYXRpb24uaHJlZiwgd2luZG93Lm5hdmlnYXRvci51c2VyQWdlbnQsIGRvY3VtZW50LnJlZmVycmVyKQogIC8vIGlmIChjdXN0b21VQSkgewogIC8vICAgZmFrZVVBKGN1c3RvbVVBKQogIC8vICAgYWxlcnQoY3VzdG9tVUEpCiAgLy8gfSBlbHNlIHsKICAvLyAgIGFsZXJ0KCd1YSBmYWxzZScpCiAgLy8gfQoKICB1YSAmJiBmYWtlVUEodWEpOwp9CgovKioKICog5YWD57Sg5YWo5bGPQVBJ77yM5ZCM5pe25YW85a65572R6aG15YWo5bGPCiAqLwoKaGFja0F0dGFjaFNoYWRvdygpOwpjbGFzcyBGdWxsU2NyZWVuIHsKICBjb25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Rvd25sb2FkIChjYW52YXMsIHRpdGxlLCB2aWRlbykgewogICAgdGl0bGUgPSB0aXRsZSB8fCAndmlkZW9DYXB0dXJlcl8nICsgRGF0ZS5ub3coKTsKCiAgICB0cnkgewogICAgICBjYW52YXMudG9CbG9iKGZ1bmN0aW9uIChibG9iKSB7CiAgICAgICAgY29uc3QgZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdhJyk7CiAgICAgICAgZWwuZG93bmxvYWQgPSBgJHt0aXRsZX0uanBnYDsKICAgICAgICBlbC5ocmVmID0gVVJMLmNyZWF0ZU9iamVjdFVSTChibG9iKTsKICAgICAgICBlbC5jbGljaygpOwoKICAgICAgICAvKiDlsJ3or5XlpI3liLbliLDliarotLTmnb8gKi8KICAgICAgICBzZXRDbGlwYm9hcmQoYmxvYik7CiAgICAgIH0sICdpbWFnZS9qcGcnLCAwLjk5KTsKICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgdmlkZW9DYXB0dXJlci5wcmV2aWUoY2FudmFzLCB0aXRsZSk7CiAgICAgIGNvbnNvbGUuZXJyb3IoJ+inhumikea6kOWPl0NPUlPmoIfor4bpmZDliLbvvIzml6Dms5Xnm7TmjqXkuIvovb3miKrlm77vvIzop4HvvJpcbiBodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZy9lbi1VUy9kb2NzL1dlYi9IVFRQL0NPUlMnKTsKICAgICAgY29uc29sZS5lcnJvcih2aWRlbywgZSk7CiAgICB9CiAgfQp9OwoKLyoqCiAqIOm8oOagh+S6i+S7tuingua1i+WvueixoQogKiDnlKjkuo7lrp7njrDpvKDmoIfkuovku7bnmoTnqb/pgI/lk43lupTvvIzmnInliKvkuo5wb2ludGVyLWV2ZW50czpub25lCiAqIHBvaW50ZXItZXZlbnRzOm5vbmXmmK/orr7nva7lvZPliY3lsYLlhYHorrjnqb/pgI8KICog6ICMTW91c2VPYnNlcnZlcuaYr++8muWNs+S9v+S4jeefpemBk3RhcmdldOS4iumdouWtmOWc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ppognLAogIHNldHRpbmc6ICforr7nva4nLAogIGhvdGtleXM6ICflv6vmjbfplK4nLAogIGRvbmF0ZTogJ+ivt+S9nOiAheWWneadr+WSluWVofCfkY0nLAogIHJlY29tbWVuZDogJ+KdpO+4jyDlhY3otLlDaGF0R1BUIOKdpO+4jycsCiAgZW5hYmxlU2NyaXB0OiAn5ZCv55So6ISa5pysJywKICBkaXNhYmxlU2NyaXB0OiAn56aB55So6ISa5pysJywKICBvcGVuQ3Jvc3NPcmlnaW5GcmFtZVBhZ2U6ICfljZXni6zmiZPlvIDot6jln5/nmoTpobXpnaInLAogIGRpc2FibGVJbml0QXV0b1BsYXk6ICfnpoHmraLlnKjmraTnvZHnq5noh6rliqjmkq3mlL7op4bpopEnLAogIGVuYWJsZUluaXRBdXRvUGxheTogJ+WFgeiuuOWcqOatpOe9keermeiHquWKqOaSreaUvuinhumikScsCiAgcmVzdG9yZUNvbmZpZ3VyYXRpb246ICfov5jljp/lhajlsYDnmoTpu5jorqTphY3nva4nLAogIGJsb2NrU2V0UGxheWJhY2tSYXRlOiAn56aB55So6buY6K6k6YCf5bqm6LCD6IqC6YC76L6RJywKICBibG9ja1NldEN1cnJlbnRUaW1lOiAn56aB55So6buY6K6k5pKt5pS+6L+b5bqm5o6n5Yi26YC76L6RJywKICBibG9ja1NldFZvbHVtZTogJ+emgeeUqOm7mOiupOmfs+mHj+aOp+WItumAu+i+kScsCiAgdW5ibG9ja1NldFBsYXliYWNrUmF0ZTogJ+WFgeiuuOm7mOiupOmAn+W6puiwg+iKgumAu+i+kScsCiAgdW5ibG9ja1NldEN1cnJlbnRUaW1lOiAn5YWB6K646buY6K6k5pKt5pS+6L+b5bqm5o6n5Yi26YC76L6RJywKICB1bmJsb2NrU2V0Vm9sdW1lOiAn5YWB6K646buY6K6k6Z+z6YeP5o6n5Yi26YC76L6RJywKICBhbGxvd0Fjb3VzdGljR2FpbjogJ+W8gOWQr+mfs+mHj+WinuebiuiDveWKmycsCiAgbm90QWxsb3d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hwZXJpbWVudEZlYXR1cmVzV2FybmluZzogJ+Wvpumpl+aAp+WKn+iDveWuueaYk+mAoOaIkOS4gOS6m+S4jeeiuuWumueahOWVj+mhjO+8jOiri+isueaFjumWi+WVnycsCiAgYWxsb3dFeHRlcm5hbEN1c3RvbUNvbmZpZ3VyYXRpb246ICfplovllZ/lpJbpg6joh6rlrprnvqnog73lipsnLAogIG5vdEFsbG93RXh0ZXJuYWxDdXN0b21Db25maWd1cmF0aW9uOiAn6Zec6ZaJ5aSW6YOo6Ieq5a6a576p6IO95YqbJywKICBjb25maWdGYWlsOiAn6YWN572u5aSx5pWXJywKICBnbG9iYWxTZXR0aW5nOiAn5YWo5bGA6Kit572uJywKICBsb2NhbFNldHRpbmc6ICflg4XnlKjmlrzmraTntrLnq5knLAogIG9wZW5EZWJ1Z01vZGU6ICfplovllZ/oqr/oqabmqKHlvI8nLAogIGNsb3NlRGVidWdNb2RlOiAn6Zec6ZaJ6Kq/6Kmm5qih5byPJywKICB1bmZvbGRNZW51OiAn5bGV6ZaL6I+c5ZauJywKICBmb2xkTWVudTogJ+aKmOeWiuiPnOWWricsCiAgdGlwc01zZzogewogICAgcGxheXNwZWVkOiAn5pKt5pS+6YCf5bqm77yaJywKICAgIGZvcndhcmQ6ICflkJHliY3vvJonLAogICAgYmFja3dhcmQ6ICflkJHlvozvvJonLAogICAgc2Vjb25kczogJ+enkicsCiAgICB2b2x1bWU6ICfpn7Pph4/vvJonLAogICAgbmV4dGZyYW1lOiAn5a6a5L2N77ya5LiL5LiA5bmAJywKICAgIHByZXZpb3VzZnJhbWU6ICflrprkvY3vvJrkuIrkuIDluYAnLAogICAgc3RvcGZyYW1lOiAn5a6a5qC85bmA55Wr6Z2i77yaJywKICAgIHBsYXk6ICfmkq3mlL4nLAogICAgcGF1c2U6ICfmmqvlgZwnLAogICAgYXJwbDogJ+WFgeioseiHquWLleaBouW+qeaSreaUvumAsuW6picsCiAgICBkcnBsOiAn56aB5q2i6Ieq5YuV5oGi5b6p5pKt5pS+6YCy5bqmJywKICAgIGJyaWdodG5lc3M6ICflnJblg4/kuq7luqbvvJonLAogICAgY29udHJhc3Q6ICflnJblg4/lsI3mr5TluqbvvJonLAogICAgc2F0dXJhdGlvbjogJ+WcluWDj+mjveWSjOW6pu+8micsCiAgICBodWU6ICflnJblg4/oibLnm7jvvJonLAogICAgYmx1cjogJ+WcluWDj+aooeeziuW6pu+8micsCiAgICBpbWdhdHRycmVzZXQ6ICflnJblg4/lsazmgKfvvJrlvqnkvY0nLAogICAgaW1ncm90YXRlOiAn55Wr6Z2i5peL6L2J77yaJywKICAgIG9ucGx1Z2luOiAn5ZWf55SoaDVQbGF5ZXLmj5Lku7YnLAogICAgb2ZmcGx1Z2luOiAn56aB55SoaDVQbGF5ZXLmj5Lku7YnLAogICAgZ2xvYmFsbW9kZTogJ+WFqOWxgOaooeW8j++8micsCiAgICBwbGF5YmFja3Jlc3RvcmVkOiAn54K65L2g5oGi5b6p5LiK5qyh5pKt5pS+6YCy5bqmJywKICAgIHBsYXliYWNrcmVzdG9yZW9mZjogJ+aBouW+qeaSreaUvumAsuW6puWKn+iDveW3suemgeeUqO+8jOaMiSBTSElGVCtSIOWPr+mWi+WVn+ipsuWKn+iDvScsCiAgICBob3Jpem9udGFsOiAn5rC05bmz5L2N56e777yaJywKICAgIHZlcnRpY2FsOiAn5Z6C55u05L2N56e777yaJywKICAgIGhvcml6b250YWxNaXJyb3I6ICfmsLTlubPpj6Hlg48nLAogICAgdmVydGljYWxNaXJyb3I6ICflnoLnm7Tpj6Hlg48nLAogICAgdmlkZW96b29tOiAn6KaW6aC757iu5pS+546H77yaJwogIH0KfTsKCmNvbnN0IG1lc3NhZ2VzID0gewogICd6aC1DTic6IHpoQ04sCiAgemg6IHpoQ04sCiAgJ3poLUhLJzogemhUVywKICAnemgtVFcnOiB6aFRXLAogICdlbi1VUyc6IGVuVVMsCiAgZW46IGVuVVMsCiAgcnU6IHJ1Cn07Cgpjb25zdCBpMThuID0gbmV3I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ZWplY3QpID0+IHsKICAgIGlmICh3aW5kb3cuR01fZ2V0VGFiIGluc3RhbmNlb2YgRnVuY3Rpb24pIHsKICAgICAgd2luZG93LkdNX2dldFRhYihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgaWYgKCFvYmoudGFiSWQpIHsKICAgICAgICAgIG9iai50YWJJZCA9IGdldElkKCk7CiAgICAgICAgICB3aW5kb3cuR01fc2F2ZVRhYihvYmopOwogICAgICAgIH0KICAgICAgICAvKiDmr4/mrKHojrflj5bpg73mm7TmlrDlvZPliY1UYWLnmoRpZOWPtyAqLwogICAgICAgIGN1clRhYklkID0gb2JqLnRhYklkOwogICAgICAgIHJlc29sdmUob2JqLnRhYklkKTsKICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICAvKiDpnZ7msrnnjLTmj5Lku7bkuIvvvIzml6Dms5Xnoa7lrpppZnJhbWXmmK/lkKblpITkuo7lkIzkuIDkuKp0YWLkuIsgKi8KICAgICAgcmVzb2x2ZShEYXRlLm5vdygpKTsKICAgIH0KICB9KQp9CgovKiDkuIDlvIDlp4vlsLHliJ3lp4vljJblpb1jdXJUYWJJZO+8jOi/meagt+WQjue7reWwseS4jemcgOimgeW8guatpeiOt+WPllRhYmlk77yM6YOo5YiG5Zy65pmv5LiL6ZyA6KaB55So5YiwICovCmdldFRhYklkKCk7CgovKiEKICogQG5hbWUgICAgICBtb25rZXlNc2cuanMKICogQHZlcnNpb24gICAwLjAuMQogKiBAYXV0aG9yICAgIEJsYXplCiAqIEBkYXRlICAgICAgMjAxOS85LzIxIDE0OjIyCiAqLwovLyBpbXBvcnQgZGVidWcgZnJvbSAnLi9kZWJ1ZycKCi8qKgogKiDlsIblr7nosaHmlbDmja7ph4zpnaLlj6/lrZjlgqjliLBHTV9zZXRWYWx1ZemHjOmdoueahOWAvOaPkOWPluWHuuadpQogKiBAcGFyYW0gb2JqIHtvYmpjZXR9IC3lv4XpgIkg5omT566X6KaB5a2Y5YKo55qE5a+56LGh5pWw5o2u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G5hbWUpOwogICAgaWYgKG9sZE1zZyAmJiBvbGRNc2cudXBkYXRlVGltZSkgewogICAgICBjb25zdCBpbnRlcnZhbCA9IE1hdGguYWJzKERhdGUubm93KCkgLSBvbGRNc2cudXBkYXRlVGltZSk7CiAgICAgIGlmIChpbnRlcnZhbCA8IHRocm90dGxlSW50ZXJ2YWwpIHsKICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgfQogICAgfQoKICAgIGNvbnN0IG1zZyA9IHsKICAgICAgLyog5Y+R6YCB6L+H5p2l55qE5pWw5o2uICovCiAgICAgIGRhdGEsCiAgICAgIC8qIOihpeWFheagh+etvklE77yM55So5LqO5Yik5pat5piv5ZCm5ZCM5aSE5LiA5LiqdGFi5qCH562+5LiLICovCiAgICAgIHRhYklkOiBjdXJUYWJJZCB8fCAndW5kZWZpbmVkJywKICAgICAgLyog6KGl5YWF5raI5oGv55qE6aG16Z2i5p2l5rqQ55qE5qCH6aKY5L+h5oGvICovCiAgICAgIHRpdGxlOiBkb2N1bWVudC50aXRsZSwKICAgICAgLyog6KGl5YWF5raI5oGv55qE6aG16Z2i5p2l5rqQ5L+h5oGvICovCiAgICAgIHJlZmVycmVyOiBleHRyYWN0RGF0YWZyb21PYih3aW5kb3cubG9jYXRpb24pLAogICAgICAvKiDmnIDov5HkuIDmrKHmm7TmlrDor6XmlbDmja7nmoTml7bpl7QgKi8KICAgICAgdXBkYXRlVGltZTogRGF0ZS5ub3coKQogICAgfTsKICAgIGlmICh0eXBlb2YgZGF0YSA9PT0gJ29iamVjdCcpIHsKICAgICAgbXNnLmRhdGEgPSBleHRyYWN0RGF0YWZyb21PYihkYXRhKTsKICAgIH0KICAgIHdpbmRvdy5HTV9zZXRWYWx1ZShuYW1lLCBtc2cpOwoKICAgIC8vIGRlYnVnLmluZm8oYFttb25rZXlNc2ctc2VuZF1bJHtuYW1lfV1gLCBtc2cpCiAgfSwKICBzZXQ6IChuYW1lLCBkYXRhKSA9PiBtb25rZXlNc2cuc2VuZChu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gJ3UnLCAndycsICd4JywgJ3knLCAneicsICdcXCcsICd8J10sCiAga2V5TWFwOiB7CiAgICBlbnRlcjogMTMsCiAgICBzaGlmdDogMTYsCiAgICBjdHJsOiAxNywKICAgIGFsdDogMTgsCiAgICBlc2M6IDI3LAogICAgc3BhY2U6IDMyLAogICAgJ+KGkCc6IDM3LAogICAgJ+KGkSc6IDM4LAogICAgJ+KGkic6IDM5LAogICAgJ+KGkyc6IDQwLAogICAgMTogNDksCiAgICAyOiA1MCwKICAgIDM6IDUxLAogICAgNDogNTIsCiAgICBjOiA2NywKICAgIGQ6IDY4LAogICAgZTogNjksCiAgICBmOiA3MCwKICAgIGk6IDczLAogICAgajogNzQsCiAgICBrOiA3NSwKICAgIG06IDc3LAogICAgbjogNzgsCiAgICBvOiA3OSwKICAgIHA6IDgwLAogICAgcTogODEsCiAgICByOiA4MiwKICAgIHM6IDgzLAogICAgdDogODQsCiAgICB1OiA4NSwKICAgIHc6IDg3LAogICAgeDogODgsCiAgICB5OiA4OSwKICAgIHo6IDkwLAogICAgcGFkMTogOTcsCiAgICBwYWQyOiA5OCwKICAgIHBhZDM6IDk5LAogICAgcGFkNDogMTAwLAogICAgJ1xcJzogMjIwCiAgfQp9OwoKLyoqCiAqIOWIpOaWreW9k+WJjeaMiemUruaYr+WQpuazqOWGjOS4uumcgOimgeeUqOeahOaMiemUrgogKiDnlKjkuo7lh4/lsJHlr7nlhbblroPplK7kvY3nmoTlubLmibAKICovCmZ1bmN0aW9uIGlzUmVnaXN0ZXJLZXkgKGV2ZW50KSB7CiAgY29uc3Qga2V5Q29kZSA9IGV2ZW50LmtleUNvZGU7CiAgY29uc3Qga2V5ID0gZXZlbnQua2V5LnRvTG93ZXJDYXNlKCk7CiAgcmV0dXJuIGhhc1VzZUtleS5rZXlDb2RlTGlzdC5pbmNsdWRlcyhrZXlDb2RlKSB8fAogICAgaGFzVXNlS2V5LmtleUxpc3QuaW5jbHVkZXMoa2V5KQp9CgovKioKICog55Sx5LqOdGFtcGVybW9ua2V55a+5d2luZG935a+56LGh6L+b6KGM5LqG5bCB6KOF77yM5oiR5Lus5a6e6ZmF6K6/6Zeu5Yiw55qEd2luZG935bm26Z2e6aG16Z2i55yf5a6e55qEd2luZG93CiAqIOi/meWwseWvvOiHtOS6huWmguaenOaIkeS7rOmcgOimgeWwhuafkOS6m+WvueixoeaMgui9veWIsOmhtemdoueahHdpbmRvd+i/m+ihjOiwg+ivleeahOaXtuWAmeWwseaXoOazleaMgui9veS6hgogKiDmiYDku6Xlv4Xpobvkvb/nlKjnibnmrormiYvmrrXmiY3og73orr/pl67liLDpobXpnaLnnJ/lrp7nmoR3aW5kb3flr7nosaHvvIzkuo7mmK/lsLHmnInkuobkuIvpnaLov5nkuKrlh73mlbAKICogQHJldHVybnMge1Byb21pc2U8dm9pZD59CiAqLwphc3luYyBmdW5jdGlvbiBnZXRQYWdlV2luZG93ICgpIHsKICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgaWYgKHdpbmRvdy5fcGFnZVdpbmRvdykgewogICAgICByZXR1cm4gcmVzb2x2ZSh3aW5kb3cuX3BhZ2VXaW5kb3cpCiAgICB9CgogICAgLyog5bCd6K+V6YCa6L+H5ZCM5q2l55qE5pa55byP6I635Y+WcGFnZVdpbmRvdyAqLwogICAgdHJ5IHsKICAgICAgY29uc3QgcGFnZVdpbiA9IGdldFBhZ2VXaW5kb3dTeW5jKCk7CiAgICAgIGlmIChwYWdlV2luICYmIHBhZ2VXaW4uZG9jdW1lbnQgJiYgcGFnZVdpbi5YTUxIdHRwUmVxdWVzdCkgewogICAgICAgIHdpbmRvdy5fcGFnZVdpbmRvdyA9IHBhZ2VXaW47CiAgICAgICAgcmVzb2x2ZShwYWdlV2luKTsKICAgICAgICByZXR1cm4gcGFnZVdpbgogICAgICB9CiAgICB9IGNhdGNoIChlKSB7fQoKICAgIC8qIOS4i+mdouW8guatpeiOt+WPlnBhZ2V3aW5kb3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mRDaGlsZChzY3JpcHQpOwoKICAgIHJldHVybiBkb2N1bWVudC5fd2luXwogIH0KfQoKZnVuY3Rpb24gb3BlbkluVGFiICh1cmwsIG9wdHMsIHJlZmVyZXIpIHsKICBpZiAocmVmZXJlcikgewogICAgY29uc3QgdXJsT2JqID0gcGFyc2VVUkwodXJsKTsKICAgIGlmICghdXJsT2JqLnBhcmFtcy5yZWZlcmVyKSB7CiAgICAgIHVybE9iai5wYXJhbXMucmVmZXJlciA9IGVuY29kZVVSSUNvbXBvbmVudCh3aW5kb3cubG9jYXRpb24uaHJlZik7CiAgICAgIHVybCA9IHN0cmluZ2lmeVRvVXJsKHVybE9iaik7CiAgICB9CiAgfQoKICBpZiAod2luZG93LkdNX29wZW5JblRhYikgewogICAgd2luZG93LkdNX29wZW5JblRhYih1cmwsIG9wdHMgfHwgewogICAgICBhY3RpdmU6IHRydWUsCiAgICAgIGluc2VydDogdHJ1ZSwKICAgICAgc2V0UGFyZW50OiB0cnVlCiAgICB9KTsKICB9Cn0KCi8qIOehruS/neaVsOWtl+S4uuato+aVsCAqLwpmdW5jdGlvbiBudW1VcCAobnVtKSB7CiAgaWYgKHR5cGVvZiBudW0gPT09ICdudW1iZXInICYmIG51bSA8IDApIHsKICAgIG51bSA9IE1hdGguYWJzKG51bSk7CiAgfQogIHJldHVybiBudW0KfQoKLyog56Gu5L+d5pWw5a2X5Li66LSf5pWwICovCmZ1bmN0aW9uIG51bURvd24gKG51bSkgewogIGlmICh0eXBlb2YgbnVtID09PSAnbnVtYmVyJyAmJiBudW0gPiAwKSB7CiAgICBudW0gPSAtbnVtOwogIH0KICByZXR1cm4gbnVtCn0KCmZ1bmN0aW9uIGlzTWVkaWFFbGVtZW50IChlbGVtZW50KSB7CiAgcmV0dXJuIGVsZW1lbnQgJiYgKGVsZW1lbnQgaW5zdGFuY2VvZiBIVE1MTWVkaWFFbGVtZW50IHx8IGVsZW1lbnQuSFRNTE1lZGlhRWxlbWVudCB8fCBlbGVtZW50LkhU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lSW5QaWN0dXJlSW5mb+eKtuaAgQogICAgICovCiAgICBtb25rZXlNc2cuYnJvYWRjYXN0KGZ1bmN0aW9uICgpIHsKICAgICAgLy8gY29uc29sZS5sb2coJ1ttb25rZXlNc2ddW2Jyb2FkY2FzdF0nLCAuLi5hcmd1bWVudHMpCiAgICAgIGlmIChkb2N1bWVudC5waWN0dXJlSW5QaWN0dXJlRWxlbWVudCkgewogICAgICAgIG1vbmtleU1zZy5zZW5kKCdnbG9iYWxQaWN0dXJlSW5QaWN0dXJlSW5mbycsIHsKICAgICAgICAgIHVzZVBpY3R1cmVJblBpY3R1cmU6IHRydWUKICAgICAgICB9KTsKICAgICAgfQogICAgfSk7CiAgfSwKICAvKiDliKTmlq3lvZPliY3mmK/lkKblvIDlkK/kuobnlLvkuK3nlLvlip/og70gKi8KICBoYXNPcGVuUGljdHVyZUluUGljdHVyZSAoKSB7CiAgICBjb25zdCBkYXRhID0gbW9ua2V5TXNnLmdldCgnZ2xvYmFsUGljdHVyZUluUGljdHVyZUluZm8nKTsKCiAgICAvKiDnlLvkuK3nlLvnmoTlhajlsYDkv6Hmga/mm7TmlrDml7bpl7Tlt67lnKgzc+WGhe+8jOaJjeiupOS4uuW9k+WJjeW8gOWQr+S6hueUu+S4reeUu+aooeW8j++8jOWQpuWImeacieWPr+iDveaEj+WklumAgOWHuu+8jOiAjOayoeS/ruaUuXVzZVBpY3R1cmVJblBpY3R1cmXnmoTlgLzvvIzpgKDmiJDor6/liKQgKi8KICAgIGlmIChkYXRhICYmIGRhdGEuZGF0YSkgewogICAgICBpZiAoZGF0YS5kYXRhLnVzZVBpY3R1cmVJblBpY3R1cmUpIHsKICAgICAgICByZXR1cm4gTWF0aC5hYnMoRGF0ZS5ub3coKSAtIGRhdGEudXBkYXRlVGltZSkgPCAxMDAwICogMwogICAgICB9IGVsc2UgewogICAgICAgIC8qKgogICAgICAgICAqIOajgOa1i+WIsOeUu+S4reeUu+W3sue7j+iiq+WFs+mXre+8jOS9hui/mOayoeWFs+mXreWkquS5heeahOivne+8jOWFgeiuuOacieS4quefreaagueahOaXtumXtOauteWGheiuqeeUqOaIt+i3qFRBQuaOp+WItuinhumikQogICAgICAgICAqIOS+i+Wmgu+8muaaguWBnOinhumikeaSreaUvgogICAgICAgICAqLwogICAgICAgIHJldHVybiBNYXRoLmFicyhEYXRlLm5vdygpIC0gZGF0YS51cGRhdGVUaW1lKSA8IDEwMDAgKiAxNQogICAgICB9CiAgICB9CgogICAgcmV0dXJuIGZhbHNlCiAgfSwKICAvKioKICAgKiDliKTmlq3mmK/lkKbpnIDopoHlj5HpgIHot6hUYWLmjqfliLbmjInplK7kv6Hmga8KICAgKi8KICBpc05lZWRTZW5kQ3Jvc3NUYWJDdGxFdmVudCAoKSB7CiAgICBjb25zdCB0ID0gY3Jvc3NUYWJDdGw7CgogICAgLyog55S75Lit55S75byA5ZCv5ZCO77yM5Yik5pat5LiN5Zyo5ZCM5LiA5LiqVGFi5omN5Y+R6YCB5LqL5Lu2ICovCiAgICBjb25zdCBkYXRhID0gbW9ua2V5TXNnLmdldCgnZ2xvYmFsUGljdHVyZUluUGljdHVyZUluZm8nKTsKICAgIGlmICh0Lmhhc09wZW5QaWN0dXJlSW5QaWN0dXJlKCkgJiYgZGF0YS50YWJJZCAhPT0gY3VyVGFiSWQpIHsKICAgICAgcmV0dXJuIHRydWUKICAgIH0gZWxzZSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQogIH0sCiAgY3Jvc3NUYWJLZXlkb3duRXZlbnQgKGV2ZW50KSB7CiAgICBjb25zdCB0ID0gY3Jvc3NUYWJDdGw7CiAgICAvKiDlpITkuo7lj6/nvJbovpHlhYPntKDkuK3kuI3miafooYzku7vkvZXlv6vmjbfplK4gKi8KICAgIGlmIChpc0VkaXRhYmxlVGFyZ2V0KGV2ZW50LnRhcmdldCkpIHJldHVybgogICAgaWYgKHQuaXNOZWVkU2VuZENyb3NzVGFiQ3RsRXZlbnQoKSAmJiBpc1JlZ2lzdGVyS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LywgcyA9PiBzLnRvVXBwZXJDYXNlKCkpLAogIHRvQXJyOiBhcmcgPT4gQXJyYXkuZnJvbShBcnJheS5pc0FycmF5KGFyZykgPyBhcmcgOiBbYXJnXSksCgogIGRlYnVnOiB7CiAgICBsb2cgKCkgewogICAgICBsZXQgbG9nID0gd2luLmNvbnNvbGUubG9nOwogICAgICAvKiDlpoLmnpxsb2fkuZ/ooqtob29r5LqG77yM5YiZ5L2/55So5pyq6KKraG9va+WJjeeahGxvZ+WHveaVsCAqLwogICAgICBpZiAobG9nLm9yaWdpbk1ldGhvZCkgeyBsb2cgPSBsb2cub3JpZ2luTWV0aG9kOyB9CiAgICAgIGlmICh3aW4uX2RlYnVnTW9kZV8pIHsKICAgICAgICBsb2cuYXBwbHkod2luLmNvbnNvbGUsIGFyZ3VtZW50cyk7CiAgICAgIH0KICAgIH0KICB9LAogIC8qIOiOt+WPluWMheWQq+iHqui6q+OAgee7p+aJv+OAgeWPr+aemuS4vuOAgeS4jeWPr+aemuS4vueahOmUruWQjSAqLwogIGdldEFsbEtleXMgKG9iaikgewogICAgY29uc3QgdG1wQXJyID0gW107CiAgICBmb3IgKGNvbnN0IGtleSBpbiBvYmopIHsgdG1wQXJyLnB1c2goa2V5KTsgfQogICAgY29uc3QgYWxsS2V5cyA9IEFycmF5LmZyb20obmV3IFNldCh0bXBBcnIuY29uY2F0KFJlZmxlY3Qub3duS2V5cyhvYmopKSkpOwogICAgcmV0dXJuIGFsbEtleXMKICB9Cn07CgpjbGFzcyBIb29rSnMgewogIGNvbnN0cnVjdG9yICh1c2VQcm94eSkgewogICAgdGhpcy51c2VQcm94eSA9IHVzZVByb3h5IHx8IGZhbHNlOwogICAgdGhpcy5ob29rUHJvcGVydGllc0tleU5hbWUgPSAnX2hvb2tQcm9wZXJ0aWVzJyArIERhdGUubm93KCk7CiAgfQoKICBob29rSnNQcm8gKCkgewogICAgcmV0dXJuIG5ldyBIb29rSnModHJ1ZSkKICB9CgogIF9hZGRIb29rIChob29rTWV0aG9kLCBmbiwgdHlwZSwgY2xhc3NIb29rKSB7CiAgICBjb25zdCBob29rS2V5TmFtZSA9IHR5cGUgKyAnSG9va3MnOwogICAgY29uc3QgaG9va01ldGhvZFByb3BlcnRpZXMgPSBob29rTWV0aG9kW3RoaXMuaG9va1Byb3BlcnRpZXNLZXlOYW1lXTsKICAgIGlmICghaG9va01ldGhvZFByb3BlcnRpZXNbaG9va0tleU5hbWVdKSB7CiAgICAgIGhvb2tNZXRob2RQcm9wZXJ0aWVzW2hvb2tLZXlOYW1lXSA9IFtdOwogICAgfQoKICAgIC8qIOazqOWGjO+8iOWCqOWtmO+8ieimgeiiq+iwg+eUqOeahGhvb2vlh73mlbDvvIzlkIzml7bpmLLmraLph43lpI3ms6jlhowgKi8KICAgIGxldCBoYXNTYW1lSG9vayA9IGZhbHNlOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBob29rTWV0aG9kUHJvcGVydGllc1tob29rS2V5TmFtZV0ubGVuZ3RoOyBpKyspIHsKICAgICAgaWYgKGZuID09PSBob29rTWV0aG9kUHJvcGVydGllc1tob29rS2V5TmFtZV1baV0pIHsKICAgICAgICBoYXNTYW1lSG9vayA9IHRydWU7CiAgICAgICAgYnJlYWsKICAgICAgfQogICAgfQoKICAgIGlmICghaGFzU2FtZUhvb2spIHsKICAgICAgZm4uY2xhc3NIb29rID0gY2xhc3NIb29rIHx8IGZhbHNlOwogICAgICBob29rTWV0aG9kUHJvcGVydGllc1tob29rS2V5TmFtZV0ucHVzaChmbik7CiAgICB9CiAgfQoKICBfcnVuSG9va3MgKHBhcmVudE9iaiwgbWV0aG9kTmFtZSwgb3JpZ2luTWV0aG9kLCBob29rTWV0aG9kLCB0YXJnZXQsIGN0eCwgYXJncywgY2xhc3NIb29rLCBob29rUHJvcGVydGllc0tleU5hbWUpIHsKICAgIGNvbnN0IGhvb2tNZXRob2RQcm9wZXJ0aWVzID0gaG9va01ldGhvZFtob29rUHJvcGVydGllc0tleU5hbWVdOwogICA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ZSB7CiAgICAgIGlmIChlcnJvckhvb2tzLmxlbmd0aCkgewogICAgICAgIHRyeSB7CiAgICAgICAgICBleGVjSW5mby5yZXN1bHQgPSBydW5UYXJnZXQoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIGV4ZWNJbmZvLmVycm9yID0gZXJyOwogICAgICAgICAgY29uc3QgZXJyb3JIb29rc1Jlc3VsdCA9IHJ1bkhvb2tzKGVycm9ySG9va3MsICdlcnJvcicpOwogICAgICAgICAgLyog5pSv5oyB5omn6KGM6ZSZ6K+v5ZCO5LiN5oqb5Ye65byC5bi455qE5oyH5LukICovCiAgICAgICAgICBpZiAoZXJyb3JIb29rc1Jlc3VsdCAmJiBlcnJvckhvb2tzUmVzdWx0ID09PSAnU0tJUC1FUlJPUicpIDsgZWxzZSB7CiAgICAgICAgICAgIHRocm93IGVycgogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBleGVjSW5mby5yZXN1bHQgPSBydW5UYXJnZXQoKTsKICAgICAgfQogICAgfQoKICAgIC8qKgogICAgICog5omn6KGMYWZ0ZXJIb29rc++8jOWmguaenOi/lOWbnueahOaYr1Byb21pc2XvvIznkIborrrkuIrlupTor6Xov5vooYzov5vkuIDmraXnmoTnu4bliIblpITnkIYKICAgICAqIOS9hua3u+WKoOe7huWIhuWkhOeQhumAu+i+keWQjuWPkeeOsOaAp+iDveS4i+mZjeW+l+avlOi+g+WOieWus++8jOS4lOWuueaYk+WHuueOsOWQhOenjeW8guW4uO+8jOaJgOS7peWGs+WumuS4jeWcqGhvb2vph4zlpITnkIZQcm9taXNl5oOF5Ya1CiAgICAgKiDkuIvpnaLmmK/ljp9Qcm9taXNl5aSE55CG6YC76L6R77yM5re75Yqg5ZCO5Lya5a+86Ie05Lul5LiL572R56uZ5Y2h5q275oiW5peg5rOV6K6/6Zeu77yaCiAgICAgKiB3ZW5rdS5iYWlkdS5jb20KICAgICAqIGh0dHBzOi8vcHVicy5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9IG51bGw7CgogICAgLyog5a2Y5Zyo57yT5a2Y5YiZ5L2/55So57yT5a2Y55qEaG9va01ldGhvZCAqLwogICAgaWYgKHQuaXNIb29rKG9yaWdpbk1ldGhvZCkpIHsKICAgICAgaG9va01ldGhvZCA9IG9yaWdpbk1ldGhvZDsKICAgIH0gZWxzZSBpZiAob3JpZ2luTWV0aG9kW3QuaG9va1Byb3BlcnRpZXNLZXlOYW1lXSAmJiB0LmlzSG9vayhvcmlnaW5NZXRob2RbdC5ob29rUHJvcGVydGllc0tleU5hbWVdLmhvb2tNZXRob2QpKSB7CiAgICAgIGhvb2tNZXRob2QgPSBvcmlnaW5NZXRob2RbdC5ob29rUHJvcGVydGllc0tleU5hbWVdLmhvb2tNZXRob2Q7CiAgICB9CgogICAgaWYgKGhvb2tNZXRob2QpIHsKICAgICAgaWYgKCFob29rTWV0aG9kW3QuaG9va1Byb3BlcnRpZXNLZXlOYW1lXS5pc0hvb2spIHsKICAgICAgICAvKiDph43mlrDmoIfms6jooqtob29r54q25oCBICovCiAgICAgICAgaG9va01ldGhvZFt0Lmhvb2tQcm9wZXJ0aWVzS2V5TmFtZV0uaXNIb29rID0gdHJ1ZTsKICAgICAgICB1dGlsLmRlYnVnLmxvZyhgW2hvb2sgbWV0aG9kXSAke3V0aWwudG9TdHIocGFyZW50T2JqKX0gJHttZXRob2ROYW1lfWApOwogICAgICB9CiAgICAgIHJldHVybiBob29rTWV0aG9kCiAgICB9CgogICAgLyog5L2/55SoUHJveHnmqKHlvI/ov5vooYxob29r5Y+v5Lul6I635b6X5pu05aSa54m55oCn77yM5L2G5oCn6IO95Lmf5Lya56iN5beu5LiA5LqbICovCiAgICBpZiAodXNlUHJveHkgJiYgUHJveHkpIHsKICAgICAgLyog5rOo5oSP77ya5L2/55SoUHJveHnku6PnkIbvvIxob29rTWV0aG9k5ZKMb3JpZ2luTWV0aG9k5bCG5YWx55So5ZCM5LiA5a+56LGhICovCiAgICAgIGNvbnN0IGhhbmRsZXIgPSB7IC4uLnByb3h5SGFuZGxlciB9OwoKICAgICAgLyog5LiL6Z2i55qE5YaZ5rOV56Gu5a6a5LqGcHJveHlIYW5kbGVy5piv5peg5rOV6KaG55uWY29uc3RydWN05ZKMYXBwbHnmk43kvZznmoQgKi8KICAgICAgaWYgKGNsYXNzSG9vaykgewogICAgICAgIGhhbmRsZXIuY29uc3RydWN0ID0gZnVuY3Rpb24gKHRhcmdldCwgYXJncywgbmV3VGFyZ2V0KSB7CiAgICAgICAgICBjb250ZXh0ID0gY29udGV4dCB8fCB0aGlzOwogICAgICAgICAgcmV0dXJuIHQuX3J1bkhvb2tzKHBhcmVudE9iaiwgbWV0aG9kTmFtZSwgb3JpZ2luTWV0aG9kLCBob29rTWV0aG9kLCB0YXJnZXQsIGNvbnRleHQsIGFyZ3MsIHRydWUsIHQuaG9va1Byb3BlcnRpZXNLZXlOYW1lKQogICAgICAgIH07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgaGFuZGxlci5hcHBseSA9IGZ1bmN0aW9uICh0YXJnZXQsIGN0eCwgYXJncykgewogICAgICAgICAgY3R4ID0gY29udGV4dCB8fCBjdHg7CiAgICAgICAgICByZXR1cm4gdC5fcnVuSG9va3MocGFyZW50T2JqLCBtZXRob2ROYW1lLCBvcmlnaW5NZXRob2QsIGhvb2tNZXRob2QsIHRhcmdldCwgY3R4LCBhcmdzLCBmYWxzZSwgdC5ob29rUHJvcGVydGllc0tleU5hbWUpCiAgICAgICAgfTsKICAgICAgfQoKICAgICAgaG9va01ldGhvZCA9IG5ldyBQcm94eShvcmlnaW5NZXRob2QsIGhhbmRsZXIpOwogICAgfSBlbHNlIHsKICAgICAgaG9va01ldGhvZCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAvKioKICAgICAgICAgKiDms6jmhI/mraTlpITkuI3og73pgJrov4cgY29udGV4dCA9IGNvbnRleHQgfHwgdGhpcwogICAgICAgICAqIOeEtuWQjumAmui/h+aKimNvbnRleHTlvZNjdHjkvKDpgJLov4fljrsKICAgICAgICAgKiDov5nlsIblr7zoh7RjdHjlvJXnlKjplJnor68KICAgICAgICAgKi8KICAgICAgICBjb25zdCBjdHggPSBjb250ZXh0IHx8IHRoaXM7CiAgICAgICAgcmV0dXJuIHQuX3J1bkhvb2tzKHBhcmVudE9iaiwgbWV0aG9kTmFtZSwgb3JpZ2luTWV0aG9kLCBob29rTWV0aG9kLCBvcmlnaW5NZXRob2QsIGN0eCwgYXJndW1lbnRzLCBjbGFzc0hvb2ssIHQuaG9va1Byb3BlcnRpZXNLZXlOYW1lKQogICAgICB9OwoKICAgICAgLyog56Gu5L+d5a2Q5a+56LGh5ZKM5Y6f5Z6L6ZO+6Lefb3JpZ2luTWV0aG9k5L+d5oyB5LiA6Ie0ICovCiAgICAgIGNvbnN0IGtleXMgPSBSZWZsZWN0Lm93bktleXMob3JpZ2luTWV0aG9kKTsKICAgICAga2V5cy5mb3JFYWNoKGtleU5hbWUgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoaG9va01ldGhvZCwga2V5TmFtZSwgewogICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICByZXR1cm4gb3JpZ2luTWV0aG9kW2tleU5hbWVdCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHNldDogZnVuY3Rpb24gKHZhbCkgewogICAgICAgICAgICAgIG9yaWdpbk1ldGhvZFtrZXlOYW1lXSA9IHZhbDsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAvLyDorr7nva5kZWZpbmVQcm9wZXJ0eeeahOaXtuWAmeWHuueOsOW8guW4uO+8jOWPr+iDveWvvOiHtGhvb2tNZXRob2Tpg6jliIblip/og73nvLrlpLHvvIzkuZ/lj6/og73kuI3lj5flvbHlk40KICAgICAgICAgIHV0aWwuZGVidWcubG9nKGBbcHJveHlNZXRob2RjR2VuZXJhdG9y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CJIOm7mOiupGZhbHNl77yM5oyH5a6a5piv5ZCm5Li66ZKI5a+5bmV377yIY2xhc3PvvInmk43kvZznmoRob29rCiAgICogQHBhcmFtIGNvbnRleHQge09iamVjdH0gLeWPr+mAiSDmjIflrprov5DooYzooqtob29r5Ye95pWw5pe255qE5LiK5LiL5paH5a+56LGhCiAgICogQHBhcmFtIHByb3h5SGFuZGxlciB7T2JqZWN0fSAt5Y+v6YCJIOS7heW9k+eUqFByb3h56L+b6KGMaG9va+aXtuacieaViO+8jOm7mOiupOS9v+eUqOeahOaYr1Byb3h555qEYXBwbHkgaGFuZGxlcui/m+ihjGhvb2vvvIzlpoLmnpzkvaDmnInnibnmrorpnIDmsYLkuZ/lj6/ku6XphY3nva7oh6rlt7HnmoRoYW5kbGVy5Lul5a6e546w5pu05aSN5p2C55qE5Yqf6IO9CiAgICog6ZmE5rOo77ya5LiN5L2/55SoUHJveHnov5vooYxob29r77yM5Y+v5Lul6I635b6X5pu06auY5oCn6IO977yM5L2G5Lmf5oSP5ZGz552A6YCa55So5oCn5pu05beu5Lqb77yM5a+55LqO6KaBaG9vayBIVE1MRWxlbWVudC5wcm90b3R5cGXjgIFFdmVudFRhcmdldC5wcm90b3R5cGXov5nkupvlr7nosaHph4zpnaLnmoTpnZ7lrp7kvovnmoTlh73mlbDlvoDlvoDkvJrlpLHotKXogIzlr7zoh7Tooqtob29r5Ye95pWw5omn6KGM5Ye66ZSZCiAgICogQHJldHVybnMge2Jvb2xlYW59CiAgICovCiAgaG9vayAocGFyZW50T2JqLCBob29rTWV0aG9kcywgZm4sIHR5cGUsIGNsYXNzSG9vaywgY29udGV4dCwgcHJveHlIYW5kbGVyKSB7CiAgICAvKiDmlK/mjIHlr7nosaHlvaLlvI/nmoTkvKDlj4IgKi8KICAgIGNvbnN0IG9wdHMgPSBhcmd1bWVudHNbMF07CiAgICBpZiAodXRpbC5pc09iaihvcHRzKSAmJiBvcHRzLnBhcmVudE9iaiAmJiBvcHRzLmhvb2tNZXR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JpcHRvci53cml0YWJsZSA9PT0gZmFsc2UpIHsKICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocGFyZW50T2JqLCBtZXRob2ROYW1lLCB7IHdyaXRhYmxlOiB0cnVlIH0pOwogICAgICB9CgogICAgICBjb25zdCBvcmlnaW5NZXRob2QgPSBwYXJlbnRPYmpbbWV0aG9kTmFtZV07CiAgICAgIGxldCBob29rTWV0aG9kID0gbnVsbDsKCiAgICAgIC8qIOmdnuWHveaVsOaXoOazlei/m+ihjGhvb2vmk43kvZwgKi8KICAgICAgaWYgKCF1dGlsLmlzRm4ob3JpZ2luTWV0aG9kKSkgewogICAgICAgIHJldHVybiBmYWxzZQogICAgICB9CgogICAgICBob29rTWV0aG9kID0gdC5fcHJveHlNZXRob2RjR2VuZXJhdG9yKHBhcmVudE9iaiwgbWV0aG9kTmFtZSwgb3JpZ2luTWV0aG9kLCBjbGFzc0hvb2ssIGNvbnRleHQsIHByb3h5SGFuZGxlcik7CgogICAgICBjb25zdCBob29rTWV0aG9kUHJvcGVydGllcyA9IGhvb2tNZXRob2RbdC5ob29rUHJvcGVydGllc0tleU5hbWVdOwogICAgICBpZiAoaG9va01ldGhvZFByb3BlcnRpZXMuY2xhc3NIb29rICE9PSBjbGFzc0hvb2spIHsKICAgICAgICB1dGlsLmRlYnVnLmxvZyhgJHt1dGlsLnRvU3RyKHBhcmVudE9iail9IFske21ldGhvZE5hbWV9XSBDYW5ub3Qgc3VwcG9ydCBmdW5jdGlvbnMgaG9vayBhbmQgY2xhc3NlcyBob29rIGF0IHRoZSBzYW1lIHRpbWUgYCk7CiAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgIH0KCiAgICAgIC8qIOS9v+eUqGhvb2tNZXRob2TmjqXnrqHpnIDopoHooqtob29r55qE5pa55rOVICovCiAgICAgIGlmIChwYXJlbnRPYmpbbWV0aG9kTmFtZV0gIT09IGhvb2tNZXRob2QpIHsKICAgICAgICBwYXJlbnRPYmpbbWV0aG9kTmFtZV0gPSBob29rTWV0aG9kOwogICAgICB9CgogICAgICB0Ll9hZGRIb29rKGhvb2tNZXRob2QsIGZuLCB0eXBlLCBjbGFzc0hvb2spOwogICAgfSk7CiAgfQoKICAvKiDkuJPpl6jpkojlr7luZXfmk43kvZznmoRob29r77yM5pys6LSo5LiK5pivaG9va+WHveaVsOeahOWIq+WQje+8jOWPr+S7peWwkeS8oGNsYXNzSG9va+i/meS4quWPguaVsO+8jOW5tuS4lOaYjuehruivreS5iSAqLwogIGhvb2tDbGFzcyAocGFyZW50T2JqLCBob29rTWV0aG9kcywgZm4sIHR5cGUsIGNvbnRleHQsIHByb3h5SGFuZGxlcikgewogICAgcmV0dXJuIHRoaXMuaG9vayhwYXJlbnRPYmosIGhvb2tNZXRob2RzLCBmbiwgdHlwZSwgdHJ1ZSwgY29udGV4dCwgcHJveHlIYW5kbGVyKQogIH0KCiAgLyoqCiAgICog5Y+W5raI5a+55p+Q5Liq5Ye95pWw55qEaG9vawogICAqIEBwYXJhbSBwYXJlbnRPYmoge09iamVjdH0gLeW/hemAiSDopoHlj5bmtojooqtob29r5Ye95pWw5L6d6LWW55qE54i25a+56LGhCiAgICogQHBhcmFtIGhvb2tNZXRob2RzIHtPYmplY3R8QXJyYXl8UmVnRXhwfHN0cmluZ30gLeW/hemAiSDopoHlj5bmtojooqtob29r5Ye95pWw55qE5Ye95pWw5ZCN5oiW5Ye95pWw5ZCN55qE5Yy56YWN6KeE5YiZCiAgICogQHBhcmFtIHR5cGUge1N0cmluZ30gLeWPr+mAiSDpu5jorqRiZWZvcmXvvIzmjIflrpropoHlj5bmtojnmoRob29r57G75Z6L77yM5Y+v6YCJ5a2X56ym5Liy77yaYmVmb3Jl44CBYWZ0ZXLjgIFyZXBsYWNl44CBZXJyb3LjgIFoYW5nVXDvvIzlpoLmnpzkuI3mjIflrpror6XpgInpobnliJnlj5bmtojmiYDmnInnsbvlnovkuIvnmoTmiYDmnInlm57osIMKICAgKiBAcGFyYW0gZm4ge0Z1bmN0aW9ufSAt5b+F6YCJIOWPlua2iOaMh+WumueahGhvb2vlm57osIPlh73mlbDvvIzlpoLmnpzkuI3mjIflrpror6XpgInpobnliJnlj5bmtojlr7nlupR0eXBl57G75Z6L5LiL55qE5omA5pyJ5Zue6LCDCiAgICogQHJldHVybnMge2Jvb2xlYW59CiAgICovCiAgdW5Ib29rIChwYXJlbnRPYmosIGhvb2tNZXRob2RzLCB0eXBlLCBmbikgewogICAgaWYgKCF1dGlsLmlzUmVmKHBhcmVudE9iaikgfHwgIWhvb2tNZXRob2RzKSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIGNvbnN0IHQgPSB0aGlzOwogICAgaG9va01ldGhvZHMgPSB0Ll9nZXRPYmpLZXlzQnlSdWxlKHBhcmVudE9iaiwgaG9va01ldGhvZHMpOwogICAgaG9va01ldGhvZHMuZm9yRWFjaChtZXRob2ROYW1lID0+IHsKICAgICAgaWYgKCF0LmlzQWxsb3dIb29rKHBhcmVudE9iaiwgbWV0aG9kTmFtZSkpIHsKICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgfQoKICAgICAgY29uc3QgaG9va01ldGhvZCA9IHBhcmVudE9ialttZXRob2ROYW1lXTsKCiAgICAgIGlmICghdC5pc0hvb2soaG9va01ldGhvZCkpIHsKICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgfQoKICAgICAgY29uc3QgaG9va01ldGhvZFByb3BlcnRpZXMgPSBob29rTWV0aG9kW3QuaG9va1Byb3BlcnRpZXNLZXlOYW1lXTsKICAgICAgY29uc3Qgb3JpZ2luTWV0aG9kID0gaG9va01ldGhvZFByb3BlcnRpZXMub3JpZ2luTWV0aG9kOwoKICAgICAgaWYgKHR5cGUpIHsKICAgICAgICBjb25zdCBob29rS2V5TmFtZSA9IHR5cGUgKyAnSG9va3MnOwogICAgICAgIGNvbnN0IGhvb2tzID0gaG9va01ldGhvZFByb3BlcnRpZXNbaG9va0tleU5hbWVdIHx8IFtdOwoKICAgICAgICBpZiAoZm4pIHsKICAgICAgICAgIC8qIOWIoOmZpOaMh+Wumuexu+Wei+S4i+eahOaMh+Wummhvb2vlh73mlbAgKi8KICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaG9va3MubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgaWYgKGZuID09PSBob29rc1tpXSkgewogICAgICAgICAgICAgIGhvb2tNZXRob2RQcm9wZXJ0aWVzW2hvb2tLZXlOYW1lXS5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgdXRpbC5kZWJ1Zy5sb2coYFt1bkhvb2sgJHtob29rS2V5TmFtZX0gZnVuY10gJHt1dGlsLnRvU3RyKHBhcmVudE9iail9ICR7bWV0aG9kTmFtZX1gLCBmbik7CiAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvKiDliKDpmaTmjIflrprnsbvlnovkuIvnmoTmiYDmnIlob29r5Ye95pWwICovCiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShob29rTWV0aG9kUHJvcGVydGllc1tob29rS2V5TmFtZV0pKSB7CiAgICAgICAgICAgIGhvb2tNZXRob2RQcm9wZXJ0aWVzW2hvb2tLZXlOYW1lXSA9IFtdOwogICAgICAgICAgICB1dGlsLmRlYnVnLmxvZyhgW3VuSG9vayBhbGwgJHtob29rS2V5TmFtZX1dICR7dXRpbC50b1N0cihwYXJlbnRPYmopfSAke21ldGhvZE5hbWV9YCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIC8qIOW9u+W6lei/mOWOn+iiq2hvb2vnmoTlh73mlbAgKi8KICAgICAgICBpZiAodXRpbC5pc0ZuKG9yaWdpbk1ldGhvZCkpIHsKICAgICAgICAgIHBhcmVudE9ialttZXRob2ROYW1lXSA9IG9yaWdpbk1ldGhvZDsKICAgICAgICAgIGRlbGV0ZSBwYXJlbnRPYmpbbWV0aG9kTmFtZV1bdC5ob29rUHJvcGVydGllc0tleU5hbWVdOwoKICAgICAgICAgIC8vIE9iamVjdC5rZXlzKGhvb2tNZXRob2QpLmZvckVhY2goa2V5TmFtZSA9PiB7CiAgICAgICAgICAvLyAgIGlmICgvSG9va3MkLy50ZXN0KGtleU5hbWUpICYmIEFycmF5LmlzQXJyYXkoaG9va01ldGhvZFtrZXlOYW1lXSkpIHsKICAgICAgICAgIC8vICAgICBob29rTWV0aG9kW2tleU5hbWVdID0gW10KICAgICAgICAgIC8vICAgfQogICAgICAgICAgLy8gfSkKICAgICAgICAgIC8vCiAgICAgICAgICAvLyBob29rTWV0aG9kLmlzSG9vayA9IGZhbHNlCiAgICAgICAgICAvLyBwYXJlbnRPYmpbbWV0aG9kTmFtZV0gPSBvcmlnaW5NZXRob2QKICAgICAgICAgIC8vIGRlbGV0ZSBwYXJlbnRPYmpbbWV0aG9kTmFtZV0ub3JpZ2luTWV0aG9kCiAgICAgICAgICAvLyBkZWxldGUgcGFyZW50T2JqW21ldGhvZE5hbWVdLmhvb2tNZXRob2QKICAgICAgICAgIC8vIGRlbGV0ZSBwYXJlbnRPYmpbbWV0aG9kTmFtZV0uaXNIb29rCiAgICAgICAgICAvLyBkZWxldGUgcGFyZW50T2JqW21ldGhvZE5hbWVdLmlzQ2xhc3NIb29rCgogICAgICAgICAgdXRpbC5kZWJ1Zy5sb2coYFt1bkhvb2sgbWV0aG9kXSAke3V0aWwudG9TdHIocGFyZW50T2JqKX0gJHttZXRob2ROYW1lfWApOwogICAgICAgIH0KICAgICAgfQogICAgfSk7CiAgfQoKICBfaG9vayAoYXJncywgdHlwZSkgewogICAgY29uc3QgdCA9IHRoaXM7CiAgICByZXR1cm4gZnVuY3Rpb24gKG9iaiwgaG9va01ldGhvZHMsIGZuLCBjbGFzc0hvb2ssIGNvbnRleHQsIHByb3h5SGFuZGxlcikgewogICAgICBjb25zdCBvcHRzID0gYXJnc1swXTsKICAgICAgaWYgKHV0aWwuaXNPYmoob3B0cykgJi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ICBjb25zdCBtZW51TGlzdCA9IG1lbnVPcHRzKCk7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KG1lbnVMaXN0KSkgewogICAgICAgIHRoaXMuX21lbnVCdWlsZGVyXyA9IG1lbnVPcHRzOwoKICAgICAgICBtZW51TGlzdC5mb3JFYWNoKG1lbnUgPT4gewogICAgICAgICAgaWYgKG1lbnUuZGlzYWJsZSA9PT0gdHJ1ZSkgeyByZXR1cm4gfQoKICAgICAgICAgIGNvbnN0IG1lbnVGbiA9ICgpID0+IHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBtZW51LmZuLmFwcGx5KG1lbnUsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCdbbW9ua2V5TWVudV0nLCBtZW51LnRpdGxlLCBlKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgLy8g5q+P5qyh6I+c5Y2V54K55Ye75ZCO77yM6YeN5paw5rOo5YaM6I+c5Y2V77yM6L+Z5qC35Y+v5Lul56Gu5L+d6I+c5Y2V55qE54q25oCB5piv5pyA5paw55qECiAgICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4gewogICAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCdbbW9ua2V5TWVudSByZWJ1aWxkXScsIG1lbnUudGl0bGUpCiAgICAgICAgICAgICAgdGhpcy5idWlsZCh0aGlzLl9tZW51QnVpbGRlcl8pOwogICAgICAgICAgICB9LCAxMDApOwogICAgICAgICAgfTsKCiAgICAgICAgICB0aGlzLm9uKG1lbnUudGl0bGUsIG1lbnVGbiwgbWVudS5hY2Nlc3NLZXkpOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnNvbGUuZXJyb3IoJ21vbmtleU1lbnUgYnVpbGQgZXJyb3IsIG5vIG1lbnVMaXN0IHJldHVybicsIG1lbnVPcHRzKTsKICAgICAgfQogICAgfQogIH0K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sKICAgIH0KICB9Cl07CgovKiDoj5zljZXmnoTpgKDlh73mlbDvvIjlv4XpobvmmK/lh73mlbDmiY3og73lnKjngrnlh7vlkI7liqjmgIHmm7TmlrDoj5zljZXnirbmgIHvvIkgKi8KZnVuY3Rpb24gbWVudUJ1aWxkZXIgKCkgewogIHJldHVybiBtb25rZXlNZW51TGlzdAp9CgovKiDms6jlhozliqjmgIHoj5zljZUgKi8KZnVuY3Rpb24gbWVudVJlZ2lzdGVyICgpIHsKICBtb25rZXlNZW51LmJ1aWxkKG1lbnVCdWlsZGVyKTsKfQoKLyoqCiAqIOWinuWKoOiPnOWNlemhuQogKiBAcGFyYW0ge09iamVjdHxBcnJheX0gbWVudU9wdHMg6I+c5Y2V55qE6YWN572u6aG555uu77yM5aSa5Liq6YWN572u6aG555uu55So5pWw57uE6KGo56S6CiAqLwpmdW5jdGlvbiBhZGRNZW51IChtZW51T3B0cywgYmVmb3JlKSB7CiAgbWVudU9wdHMgPSBBcnJheS5pc0FycmF5KG1lbnVPcHRzKSA/IG1lbnVPcHRzIDogW21lbnVPcHRzXTsKICBtZW51T3B0cyA9IG1lbnVPcHRzLmZpbHRlcihpdGVtID0+IGl0ZW0udGl0bGUgJiYgIWl0ZW0uZGlzYWJsZWQpOwoKICBpZiAoYmVmb3JlKSB7CiAgICAvKiDlsIboj5zljZXov73liqDliLDlhbblroPoj5zljZXnmoTliY3pnaIgKi8KICAgIG1vbmtleU1lbnVMaXN0ID0gbWVudU9wdHMuY29uY2F0KG1vbmtleU1lbnVMaXN0KTsKICB9IGVsc2UgewogICAgbW9ua2V5TWVudUxpc3QgPSBtb25rZXlNZW51TGlzdC5jb25jYXQobWVudU9wdHMpOwogIH0KCiAgLyog6YeN5paw5rOo5YaM6I+c5Y2VICovCiAgbWVudVJlZ2lzdGVyKCk7Cn0KCi8qKgogKiDms6jlhozot59oNXBsYXllcuebuOWFs+eahOiPnOWNle+8jOWPquacieajgOa1i+WIsOWtmOWcqOWqkuS9k+agh+etvu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nRUaW1lJykpOwogICAgICAgICAgaWYgKGNvbmZpcm0pIHsKICAgICAgICAgICAgY29uZmlnTWFuYWdlci5zZXRMb2NhbFN0b3JhZ2UoJ2VuaGFuY2UuYmxvY2tTZXRDdXJyZW50VGltZScsICFjb25maWdNYW5hZ2VyLmdldCgnZW5oYW5jZS5ibG9ja1NldEN1cnJlbnRUaW1lJykpOwogICAgICAgICAgICB3aW5kb3cubG9jYXRpb24ucmVsb2FkKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9LAogICAgICB7CiAgICAgICAgdGl0bGU6ICgpID0+IGAke2NvbmZpZ01hbmFnZXIuZ2V0KCdlbmhhbmNlLmJsb2NrU2V0Vm9sdW1lJykgPyBpMThuLnQoJ3VuYmxvY2tTZXRWb2x1bWUnKSA6IGkxOG4udCgnYmxvY2tTZXRWb2x1bWUnKX0g44CMJHtpMThuLnQoJ2xvY2FsU2V0dGluZycpfeOAjWAsCiAgICAgICAgdHlwZTogJ2xvY2FsJywKICAgICAgICBkaXNhYmxlOiBmb2xkTWVudSwKICAgICAgICBmbjogKCkgPT4gewogICAgICAgICAgY29uc3QgY29uZmlybSA9IHdpbmRvdy5jb25maXJtKGNvbmZpZ01hbmFnZXIuZ2V0KCdlbmhhbmNlLmJsb2NrU2V0Vm9sdW1lJykgPyBpMThuLnQoJ3VuYmxvY2tTZXRWb2x1bWUnKSA6IGkxOG4udCgnYmxvY2tTZXRWb2x1bWUnKSk7CiAgICAgICAgICBpZiAoY29uZmlybSkgewogICAgICAgICAgICBjb25maWdNYW5hZ2VyLnNldExvY2FsU3RvcmFnZSgnZW5oYW5jZS5ibG9ja1NldFZvbHVtZScsICFjb25maWdNYW5hZ2VyLmdldCgnZW5oYW5jZS5ibG9ja1NldFZvbHVtZScpKTsKICAgICAgICAgICAgd2luZG93LmxvY2F0aW9uLnJlbG9hZCgpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSwKICAgICAgewogICAgICAgIHRpdGxlOiAoKSA9Pi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ZW5lciA9IGFyZ3NbMV07CiAgICAgIGlmIChsaXN0ZW5lciBpbnN0YW5jZW9mIEZ1bmN0aW9uICYmIGV2ZW50TmFtZSA9PT0gJ3JhdGVjaGFuZ2UnKSB7CiAgICAgICAgLyog5a+55rOo5YaM5LqGcmF0ZWNoYW5nZeS6i+S7tui/m+ihjOajgOa1i++8jOWmguaenOWtmOWcqOW8guW4uOihjOS4uu+8jOWImeWwneivleaMgui1t+S6i+S7tiAqLwoKICAgICAgICBhcmdzWzFdID0gbmV3IFByb3h5KGxpc3RlbmVyLCB7CiAgICAgICAgICBhcHBseSAodGFyZ2V0LCBjdHgsIGFyZ3MpIHsKICAgICAgICAgICAgaWYgKGN0eCkgewogICAgICAgICAgICAgIC8qIOmYu+atouiwg+mAn+ajgOa1i++8jOW5tui/m+ihjOWPjemYu+atoiAqLwogICAgICAgICAgICAgIGlmIChjdHgucGxheWJhY2tSYXRlICYmIGV2ZW50TmFtZSA9PT0gJ3JhdGVjaGFuZ2UnKSB7CiAgICAgICAgICAgICAgICBpZiAoY3R4Ll9oYXNCbG9ja1JhdGVjaGFuZ2VFdmVudF8pIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWUKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBjb25zdCBvbGRSYXRlID0gY3R4LnBsYXliYWNrUmF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0VGltZSA9IERhdGUubm93KCk7CgogICAgICAgICAgICAgICAgY29uc3QgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KGN0eCwgYXJncyk7CgogICAgICAgICAgICAgICAgLyoqCiAgICAgICAgICAgICAgICAgKiDpgJrov4fliKTmlq3miafooYxyYXRlY2hhbmdl5YmN5ZCO55qE6YCf546H5piv5ZCm6KKr5pS55Y+Y77yMCiAgICAgICAgICAgICAgICAgKiDku6Xlj4rmmK/lkKblh7rnjrDkuobotoXplb/nmoTmiafooYzml7bpl7TvvIjlj6/og73lh7rnjrDkuoZhbGVydOW8ueeql++8ieadpeajgOa1i+aYr+WQpuWPr+iDveWtmOWcqOmYu+atouiwg+mAn+eahOihjOS4ugogICAgICAgICAgICAgICAgICog5YW25LuW5qOA5rWL5omL5q615b6F6KGl5YWFCiAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrUmF0ZWNoYW5nZUJlaGF2ZTEgPSBvbGRSYXRlICE9PSBjdHgucGxheWJhY2tSYXRlIHx8IERhdGUubm93KCkgLSBzdGFydFRpbWUgPiAxMDAwOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2tSYXRlY2hhbmdlQmVoYXZlMiA9IGN0eC5fc2V0UGxheWJhY2tSYXRlXyAmJiBjdHguX3NldFBsYXliYWNrUmF0ZV8udmFsdWUgIT09IGN0eC5wbGF5YmFja1JhdGU7CiAgICAgICAgICAgICAgICBpZiAoYmxvY2tSYXRlY2hhbmdlQmVoYXZlMSB8fCBibG9ja1JhdGVjaGFuZ2VCZWhhdmUyKSB7CiAgICAgICAgICAgICAgICAgIGRlYnVnLmluZm8oYFtleGVjVmlkZW9FdmVudF1bJHtldmVudE5hbWV9XeajgOa1i+WIsOWPr+iDveWtmOWcqOmYu+atouiwg+mAn+eahOihjOS4uu+8jOW3suemgeatoiR7ZXZlbnROYW1lfeS6i+S7tueahOaJp+ihjGAsIGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgY3R4Ll9oYXNCbG9ja1JhdGVjaGFuZ2VFdmVudF8gPSB0cnVlOwogICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZQogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0LmFwcGx5KGN0eCwgYXJncykKICAgICAgICAgICAgfSBjY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5hdmlnYXRvciA9PT0gJ29iamVjdCcgJiYgL01hY3xpUG9kfGlQaG9uZXxpUGFkLy50ZXN0KG5hdmlnYXRvci5wbGF0Zm9ybSkgPyAnTWV0YScgOiAnQ3RybCc7CiAgICAvLyAnQ29udHJvbCcsICdTaGlmdCcsICdBbHQnLCAnTWV0YScKCiAgICB0aGlzLnByZXZQcmVzcyA9IG51bGw7CiAgICB0aGlzLl9wcmV2VGltZXJfID0gbnVsbDsKCiAgICB0aGlzLnNldEhvdGtleXMoaG90a2V5cyk7CiAgICBjb21iaW5hdGlvbktleXNNb25pdG9yLmluaXQod2luKTsKICB9CgogIC8qIOiuvue9ruWFtuWug3dpbmRvd+WvueixoeeahOe7hOWQiOmUruebkeaOp+mAu+i+kSAqLwogIHNldENvbWJpbmF0aW9uS2V5c01vbml0b3IgKHdpbikgewogICAgdGhpcy53aW5kb3cgPSB3aW47CiAgICBjb21iaW5hdGlvbktleXNNb25pdG9yLmluaXQod2luKTsKICB9CgogIC8qIOaVsOaNrumihOWkhOeQhiAqLwogIGhvdGtleXNQcmVwcm9jZXNzIChob3RrZXlzKSB7CiAgICBpZiAoIUFycmF5LmlzQXJyYXkoaG90a2V5cykpIHsKICAgICAgcmV0dXJuIGZhbHNlCiAgICB9CgogICAgaG90a2V5cy5mb3JFYWNoKChjb25maWcpID0+IHsKICAgICAgaWYgKCFpc09iaiQxKGNvbmZpZykgfHwgIWNvbmZpZy5rZXkgfHwgdHlwZW9mIGNvbmZpZy5rZXkgIT09ICdzdHJpbmcnKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgIH0KCiAgICAgIGNvbnN0IGtleU5hbWUgPSBjb25maWcua2V5LnRyaW0oKS50b0xvd2VyQ2FzZSgpOwogICAgICBjb25zdCBtb2QgPSB0aGlzLk1PRC50b0xvd2VyQ2FzZSgpOwoKICAgICAgLyog5aKe5Yqg5qC85byP5YyW5ZCO55qEaG90a2V5c+aVsOe7hCAqLwogICAgICBjb25maWcua2V5QmluZGluZ3MgPSBrZXlOYW1lLnNwbGl0KCcgJykubWFwKHByZXNzID0+IHsKICAgICAgICBjb25zdCBrZXlzID0gcHJlc3Muc3BsaXQoL1xiXCsvKTsKICAgICAgICBjb25zdCBtb2RzID0gW107CiAgICAgICAgbGV0IGtleSA9ICcnOwoKICAgICAgICBrZXlzLmZvckVhY2goKGspID0+IHsKICAgICAgICAgIGsgPSBrID09PSAnJG1vZCcgPyBtb2QgOiBrOwoKICAgICAgICAgIGlmIChpc01vZGlmaWVyS2V5KGspKSB7CiAgICAgICAgICAgIG1vZHMucHVzaChrKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGtleSA9IGs7CiAgICAgICAgICB9CiAgICAgICAgfSk7CgogICAgICAgIHJldHVybiBbbW9kcywga2V5XQogICAgICB9KTsKICAgIH0pOwoKICAgIHJldHVybiBob3RrZXlzCiAgfQoKICBzZXRIb3RrZXlzIChob3RrZXlzKSB7CiAgICB0aGlzLmhvdGtleXMgPSB0aGlzLmhvdGtleXNQcmVwcm9jZXNzKGhvdGtleXMpIHx8IFtdOwogIH0KCiAgLyoqCiAgICog5Yik5pat5b2T5YmN5o+Q5L6b55qE6ZSu55uY5LqL5Lu25ZKM6aKE5pyf55qE54Ot6ZSu6YWN572u5piv5ZCm5Yy56YWNCiAgICogQHBhcmFtIHtLZXlib2FyZEV2ZW50fSBldmVudAogICAqIEBwYXJhbSB7QXJyYXl9IHByZXNzIOS+i+Wmgu+8mltbJ2FsdCcsICdzaGlmdCddLCAncyddCiAgICogQHBhcmFtIHtPYmplY3R9IHByZXZDb21iaW5hdGlvbktleXMKICAgKiBAcmV0dXJucwogICAqLwogIGlzTWF0Y2ggKGV2ZW50LCBwcmVzcykgewogICAgaWYgKCFldmVudCB8fCAhQXJyYXkuaXNBcnJheShwcmVzcykpIHsgcmV0dXJuIGZhbHNlIH0KCiAgICBjb25zdCBjb21iaW5hdGlvbktleXMgPSBldmVudC5jb21iaW5hdGlvbktleXMgfHwgY29tYmluYXRpb25LZXlzTW9uaXRvci5nZXRDb21iaW5hdGlvbktleXMoKTsKICAgIGNvbnN0IG1vZHMgPSBwcmVzc1swXTsKICAgIGNvbnN0IGtleSA9IHByZXNzWzFdOwoKICAgIC8qIOS/rumlsOespuS4quaVsOS4jeWMuemFjSAqLwogICAgaWYgKG1vZHMubGVuZ3RoICE9PSBjb21iaW5hdGlvbktleXMuc2l6ZSkgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KCiAgICAvKiDlvZPliY3mjInkuIvnmoTplK7kvY3lkozpooTmnJ/nmoTplK7kvY3kuI3ljLnphY0gKi8KICAgIGlmIChrZXkgJiYgZXZlbnQua2V5LnRvTG93ZXJDYXNlKCkgIT09IGtleSAmJiBldmVudC5jb2RlLnRvTG93ZXJDYXNlKCkgIT09IGtleSkgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KCiAgICAvKiDlvZPliY3mjInkuIvnmoTkv67ppbDnrKblkozpooTmnJ/nmoTkv67ppbDnrKbkuI3ljLnphY0gKi8KICAgIGxldCByZXN1bHQgPSB0cnVlOwogICAgY29uc3QgbW9kc0tleSA9IG5ldyBNYXAkMSgpOwogICAgY29tYmluYXRpb25LZXlzLmZvckVhY2goKHZhbCwga2V5KSA9PiB7CiAgICAgIC8qIOihpeWFheWQhOenjeWPr+iDveaDheWGteeahOagh+ivhiAqLwogICAgICBtb2RzS2V5LnNldChrZXksIHZhbCk7CiAgICAgIG1vZHNLZXkuc2V0KGtleS50b0xvd2VyQ2FzZSgpLCB2YWwpOwogICAgICBrZXlBbGlhc1trZXldICYmIG1vZHNLZXkuc2V0KGtleUFsaWFzW2tleV0sIHZhbCk7CiAgICB9KTsKCiAgICBtb2RzLmZvckVhY2goKGtleSkgPT4gewogICAgICBpZiAoIW1vZHNLZXkuaGFzKGtleSkpIHsKICAgICAgICByZXN1bHQgPSBmYWxzZTsKICAgICAgfQogICAgfSk7CgogICAgcmV0dXJuIHJlc3VsdAogIH0KCiAgaXNNYXRjaF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bmYua2V5QmluZGluZ3MubGVuZ3RoID4gMSkgewogICAgICAgIC8qIOWwhnByZXZQcmVzc+WPmOaIkOS4gOS4quWFt+aciWV2ZW5055u45YWz5a2X5q6155qE5a+56LGhICovCiAgICAgICAgdGhpcy5wcmV2UHJlc3MgPSB7CiAgICAgICAgICBjb21iaW5hdGlvbktleXM6IGNvbWJpbmF0aW9uS2V5c01vbml0b3IuZ2V0Q29tYmluYXRpb25LZXlzKCksCiAgICAgICAgICBjb2RlOiBldmVudC5jb2RlLAogICAgICAgICAga2V5OiBldmVudC5rZXksCiAgICAgICAgICBrZXlDb2RlOiBldmVudC5rZXlDb2RlLAogICAgICAgICAgYWx0S2V5OiBldmVudC5hbHRLZXksCiAgICAgICAgICBzaGlmdEtleTogZXZlbnQuc2hpZnRLZXksCiAgICAgICAgICBjdHJsS2V5OiBldmVudC5jdHJsS2V5LAogICAgICAgICAgbWV0YUtleTogZXZlbnQubWV0YUtleQogICAgICAgIH07CgogICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9wcmV2VGltZXJfKTsKICAgICAgICB0aGlzLl9wcmV2VGltZXJfID0gc2V0VGltZW91dCgoKSA9PiB7IHRoaXMucHJldlByZXNzID0gbnVsbDsgfSwgMTAwMCk7CgogICAgICAgIHJldHVybiB0cnVlCiAgICAgIH0KCiAgICAgIC8qIOWmguaenOW9k+WJjeWMuemFjeWIsOS6huesrOS6jOS4quW/q+aNt+mUru+8jOWImeW9k2ZvckVhY2jlvqrnjq/nu5PmnZ/lkI7vvIzpqazkuIrms6jplIBwcmV2UHJlc3PvvIznu5nlhbblroPlv6vmjbfplK7orqnooYwgKi8KICAgICAgaWYgKGhvdGtleUNvbmYua2V5QmluZGluZ3MubGVuZ3RoID4gMSAmJiBwcmVzcyAhPT0gaG90a2V5Q29uZi5rZXlCaW5kaW5nc1swXSkgewogICAgICAgIHNldFRpbWVvdXQoKCkgPT4geyB0aGlzLnByZXZQcmVzcyA9IG51bGw7IH0sIDApOwogICAgICB9C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ICAgIGlmIChkb3dubG9hZFR5cGUgPT09ICdibG9iJyB8fCBtZWRpYUVsLmR1cmF0aW9uIDwgNjAgKiA1KSB7CiAgICAgIGlmIChtZWRpYUVsLmRvd25sb2FkaW5nKSB7CiAgICAgICAgLyog6Led5LiK5qyh54K55LiL6L295bCP5LqOMXPnmoTmg4XlhrXnm7TmjqXkuI3lk43lupTku7vkvZXmk43kvZwgKi8KICAgICAgICBpZiAoRGF0ZS5ub3coKSAtIG1lZGlhRWwuZG93bmxvYWRpbmcgPCAxMDAwICogMSkgewogICAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IGNvbmZpcm0gPSBvcmlnaW5hbC5jb25maXJtKCfmlofku7bmraPlnKjkuIvovb3kuK3vvIznoa7lrprph43lpI3miafooYzmraTmk43kvZzvvJ8nKTsKICAgICAgICAgIGlmICghY29uZmlybSkgewogICAgICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIGlmIChtZWRpYUVsLmhhc0Rvd25sb2FkKSB7CiAgICAgICAgY29uc3QgY29uZmlybSA9IG9yaWdpbmFsLmNvbmZpcm0oJ+ivpeWqkuS9k+aWh+S7tuW3sue7j+S4i+i9vei/h+S6hu+8jOehruWumumcgOimgeWGjeasoeS4i+i9ve+8nycpOwogICAgICAgIGlmICghY29uZmlybSkgewogICAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgICAgfQogICAgICB9CgogICAgICBtZWRpYVRpdGxlID0gb3JpZ2luYWwucHJvbXB0KCfor7fnoa7orqTmlofku7bmoIfpopjvvJonLCBtZWRpYVRpdGxlKSB8fCBtZWRpYVRpdGxlOwoKICAgICAgaWYgKCFtZWRpYVRpdGxlLmVuZHNXaXRoKG1lZGlhSW5mby5mb3JtYXQpKSB7CiAgICAgICAgbWVkaWFUaXRsZSA9IG1lZGlhVGl0bGUgKyAnLicgKyBtZWRpYUluZm8uZm9ybWF0OwogICAgICB9CgogICAgICBsZXQgZmV0Y2hVcmwgPSBtZWRpYVVybDsKICAgICAgaWYgKG1lZGlhVXJsLnN0YXJ0c1dpdGgoJ2h0dHA6Ly8nKSAmJiBsb2NhdGlvbi5ocmVmLnN0YXJ0c1dpdGgoJ2h0dHBzOi8vJykpIHsKICAgICAgICAvKiDlnKhodHRwc+mHjGZldGNoIGh0dHDotYTmupDkvJrlr7zoh7QgYmxvY2s6bWl4ZWQtY29udGVudCDplJnor6/vvIzmiYDku6XlsJ3or5XlsIblnLDlnYDnu5/kuIDmiJBodHRwc+W8gOWktCAqLwogICAgICAgIGZldGNoVXJsID0gbWVkaWFVcmwucmVwbGFjZSgnaHR0cDovLycsICdodHRwczovLycpOwogICAgICB9CgogICAgICBtZWRpYUVsLmRvd25sb2FkaW5nID0gRGF0ZS5ub3coKTsKICAgICAgZmV0Y2goZmV0Y2hVcmwpLnRoZW4ocmVzID0+IHsKICAgICAgICByZXMuYmxvYigpLnRoZW4oYmxvYiA9PiB7CiAgICAgICAgICBjb25zdCBibG9iVXJsID0gd2luZG93LlVSTC5jcmVhdGVPYmplY3RVUkwoYmxvYik7CiAgICAgICAgICBkb3dubG9hZChibG9iVXJsLCBtZWRpYVRpdGxlKTsKCiAgICAgICAgICBtZWRpYUVsLmhhc0Rvd25sb2FkID0gdHJ1ZTsKICAgICAgICAgIGRlbGV0ZSBtZWRpYUVsLmRvd25sb2FkaW5nOwogICAgICAgICAgd2luZG93LlVSTC5yZXZva2VPYmplY3RVUkwoYmxvYlVybCk7CiAgICAgICAgfSk7CiAgICAgIH0pLmNhdGNoKGVyciA9PiB7CiAgICAgICAgb3JpZ2luYWwuY29uc29sZS5lcnJvcignZmV0Y2jkuIvovb3mk43kvZzlpLHotKU6JywgZXJyKTsKCiAgICAgICAgLyog5LiL6L295YWc5bqVICovCiAgICAgICAgZG93bmxvYWQobWVkaWFVcmwsIG1lZGlhVGl0bGUpOwogICAgICB9KTsKICAgIH0gZWxzZS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VudCk7CgogICAgLy8g6KKr5bCB6KOF5ZyoIHNoYWRvdyBkb20g6YeM6Z2i55qEdmlkZW8KICAgIGlmICh3aW5kb3cuX3NoYWRvd0RvbUxpc3RfKSB7CiAgICAgIHdpbmRvdy5fc2hhZG93RG9tTGlzdF8uZm9yRWFjaChmdW5jdGlvbiAoc2hhZG93Um9vdCkgewogICAgICAgIGZpbmRQbGF5ZXIoc2hhZG93Um9vdCk7CiAgICAgIH0pOwogICAgfQoKICAgIHJldHVybiBsaXN0CiAgfSwKCiAgZ2V0UGxheWVyV3JhcERvbTogZnVuY3Rpb24gKCkgewogICAgY29uc3QgdCA9IHRoaXM7CiAgICBjb25zdCBwbGF5ZXIgPSB0LnBsYXllcigpOwogICAgaWYgKCFwbGF5ZXIpIHJldHVybgoKICAgIGxldCB3cmFwRG9tID0gbnVsbDsKICAgIGNvbnN0IHBsYXllckJveCA9IHBsYXllci5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKTsKICAgIGVhY2hQYXJlbnROb2RlKHBsYXllciwgZnVuY3Rpb24gKHBhcmVudCkgewogICAgICBpZiAocGFyZW50ID09PSBkb2N1bWVudCB8fCAhcGFyZW50LmdldEJvdW5kaW5nQ2xpZW50UmVjdCkgcmV0dXJuCiAgICAgIGNvbnN0IHBhcmVudEJveCA9IHBhcmVudC5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKTsKICAgICAgaWYgKHBhcmVudEJveC53aWR0aCAmJiBwYXJlbnRCb3guaGVpZ2h0KSB7CiAgICAgICAgaWYgKHBhcmVudEJveC53aWR0aCA9PT0gcGxheWVyQm94LndpZHRoICYmIHBhcmVudEJveC5oZWlnaHQgPT09IHBsYXllckJveC5oZWlnaHQpIHsKICAgICAgICAgIHdyYXBEb20gPSBwYXJlbnQ7CiAgICAgICAgfQogICAgICB9CiAgICB9KTsKICAgIHJldHVybiB3cmFwRG9tCiAgfSwKCiAgLyog5oyC6L295Yiw6aG16Z2i5LiK55qEd2luZG935a+56LGh77yM55So5LqO6LCD6K+VICovCiAgYXN5bmMgbW91bnRUb0dsb2JhbCAoKSB7CiAgICB0cnkgewogICAgICBjb25zdCBwYWdlV2luZG93ID0gYXdhaXQgZ2V0UGFnZVdpbmRvdygpOwogICAgICBpZiAocGFnZVdpbmRvdykgewogICAgICAgIHBhZ2VXaW5kb3cuX2g1UGxheWVyID0gaDVQbGF5ZXIgfHwgJ251bGwnOwogICAgICAgIGlmICh3aW5kb3cudG9wICE9PSB3aW5kb3cpIHsKICAgICAgICAgIHBhZ2VXaW5kb3cuX2g1UGxheWVySW5GcmFtZSA9IGg1UGxheWVyIHx8ICdudWxsJzsKICAgICAgICB9CiAgICAgICAgcGFnZVdpbmRvdy5fd2luZG93ID0gd2luZG93IHx8ICcnOwogICAgICAgIGRlYnVnLmxvZygnaDVQbGF5ZXLlr7nosaHlt7LmiJDlip/mjILovb3liLDlhajlsYAnKTsKICAgICAgfQogICAgfSBjYXRjaCAoZSkgewogICAgICBkZWJ1Zy5lcnJvcihlKTsKICAgIH0KICB9LAoKICAvKioKICAgKiDliJ3lp4vljJbmkq3mlL7lmajlrp7kvosKICAgKiBAcGFyYW0gaXNTaW5nbGUg5piv5ZCm5Li65Y2V5a6e5L6LdmlkZW/moIfnrb4KICAgKi8KICBpbml0UGxheWVySW5zdGFuY2UgKGlzU2luZ2xlKSB7CiAgICBjb25zdCB0ID0gdGhpczsKICAgIGlmICghdC5wbGF5ZXJJbnN0YW5jZSkgcmV0dXJuCgogICAgY29uc3QgcGxheWVyID0gdC5wbGF5ZXJJbnN0YW5jZTsKCiAgICB0Lm1lZGlhUGx1c0FwaSA9IG1lZGlhQ29yZS5tZWRpYVBsdXMocGxheWVyKTsKCiAgICB0LmluaXRQbGF5YmFja1JhdGUoKTsKICAgIHQuaXNGb3VjcygpOwogICAgdC5wcm94eVBsYXllckluc3RhbmNlKHBsYXllcik7CgogICAgdC51bkxvY2tQbGF5YmFja1JhdGUoKTsKICAgIHQuc2V0UGxheWJhY2tSYXRlKCk7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mIGV2ZW50LnRhcmdldC5tdXRlZCA9PT0gZmFsc2UpIHsKICAgICAgICAgIHQuc2V0Vm9sdW1lKGNvbmZpZ01hbmFnZXIuZ2V0R2xvYmFsU3RvcmFnZSgnbWVkaWEudm9sdW1lJyksIHRydWUpOwogICAgICAgIH0KCiAgICAgICAgLyog56aB5q2i6buY6K6k55qE6L+b5bqm5o6n5Yi2ICovCiAgICAgICAgaWYgKGNvbmZpZ01hbmFnZXIuZ2V0KCdlbmhhbmNlLmJsb2NrU2V0Q3VycmVudFRpbWUnKSA9PT0gdHJ1ZSkgewogICAgICAgICAgdC5sb2NrQ3VycmVudFRpbWUoKTsKICAgICAgICB9CgogICAgICAgIC8qIOaBouWkjeaSreaUvui/m+W6piAqLwogICAgICAgIHQuc2V0UGxheVByb2dyZXNzKHBsYXllcik7CgogICAgICAgIGlmIChzZXRQbGF5YmFja1JhdGVPblBsYXlpbmdDb3VudCA9PT0gMCkgewogICAgICAgICAgLyog5ZCM5q2l5LmL5YmN6K6+5a6a55qE5pKt5pS+6YCf5bqm77yM6Z+z6YeP562JICovCiAgICAgICAgICB0LnVuTG9ja1BsYXliYWNrUmF0ZSgpOwogICAgICAgICAgdC5zZXRQbGF5YmFja1JhdGUoKTsKICAgICAgICAgIHQubG9ja1BsYXliYWNrUmF0ZSgxMDAwKTsKCiAgICAgICAgICAvKiDlkK/liqjmkq3mlL7ov5vluqborrDlvZUgKi8KICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4gewogICAgICAgICAgICB0LnBsYXlQcm9ncmVzc1JlY29yZGVyKHBsYXllcik7CiAgICAgICAgICB9LCAyMDAwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdC51bkxvY2tQbGF5YmFja1JhdGUoKTsKICAgICAgICAgIHQuc2V0UGxheWJhY2tSYXRlKG51bGwsIHRydWUpOwogICAgICAgICAgdC5sb2NrUGxheWJhY2tSYXRlKDEwMDApOwogICAgICAgIH0KICAgICAgICBzZXRQbGF5YmFja1Jhd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fCB7fTsKICAgICAgICAgICAgY29uc3QgaGFuZ1VwRGV0YWlsID0gaGFuZ1VwSW5mb1trZXldIHx8IGhhbmdVcEluZm9bJ2hhbmdVcF8nICsga2V5XTsKICAgICAgICAgICAgY29uc3QgbmVlZEhhbmdVcCA9IGhhbmdVcERldGFpbCAmJiBoYW5nVXBEZXRhaWwudGltZW91dCA+PSBEYXRlLm5vdygpOwogICAgICAgICAgICBpZiAobmVlZEhhbmdVcCkgewogICAgICAgICAgICAgIGRlYnVnLmxvZyhrZXkgKyAn5bey6KKr5oyC6LW377yM5pys5qyh6LCD55So5bCG6KKr5b+955WlJyk7CiAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlCiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoY3R4IHx8IHBsYXllciwgYXJncykKICAgICAgICAgIH0KICAgICAgICB9KTsKCiAgICAgICAgcGxheWVyW2tleV0gPSBwcm94eTsKICAgICAgfQogICAgfSk7CgogICAgaWYgKCFwbGF5ZXIuX2hhbmdVcF8pIHsKICAgICAgcGxheWVyLl9oYW5nVXBJbmZvXyA9IHt9OwogICAgICAvKioKICAgICAgICog5oyC6LW3cGxheWVy5p+Q5Liq5Ye95pWw55qE6LCD55SoCiAgICAgICAqIEBwYXJhbSBuYW1lIHtTdHJpbmd9IC3lv4XpgIkgcGxheWVy5pa55rOV5oiW5bGe5oCn5ZCN77yM5ZCN5a2X5YaZ5a+55aSW77yM6L+Y6aG76KaB6K+l5pa55rOV5oiW5bGe5oCn6KKr5Luj55CG5LqG5omN6IO96L+b6KGM5oyC6LW377yM5ZCm5YiZ6L+Z5bCG5piv5Liq5peg5pWI55qE6LCD55SoCiAgICAgICAqIEBwYXJhbSB0aW1lb3V0IHtOdW1iZXJ9IC3lj6/pgIkg5oyC6LW35aSa6ZW/5pe26Ze077yM6buY6K6kMjAwbXMKICAgICAgICogQHByaXZhdGUKICAgICAgICovCiAgICAgIHBsYXllci5faGFuZ1V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vUGxheScpID09PSBudWxsKSB7CiAgICAgICAgY29uZmlnTWFuYWdlci5zZXRMb2NhbFN0b3JhZ2UoJ21lZGlhLmF1dG9QbGF5JywgdHJ1ZSk7CiAgICAgIH0KCiAgICAgIGFkZE1lbnUoewogICAgICAgIHRpdGxlOiAoKSA9PiBjb25maWdNYW5hZ2VyLmdldExvY2FsU3RvcmFnZSgnbWVkaWEuYXV0b1BsYXknKSA/IGkxOG4udCgnZGlzYWJsZUluaXRBdXRvUGxheScpIDogaTE4bi50KCdlbmFibGVJbml0QXV0b1BsYXknKSwKICAgICAgICBmbjogKCkgPT4gewogICAgICAgICAgY29uc3QgY29uZmlybSA9IHdpbmRvdy5jb25maXJtKGNvbmZpZ01hbmFnZXIuZ2V0TG9jYWxTdG9yYWdlKCdtZWRpYS5hdXRvUGxheScpID8gaTE4bi50KCdkaXNhYmxlSW5pdEF1dG9QbGF5JykgOiBpMThuLnQoJ2VuYWJsZUluaXRBdXRvUGxheScpKTsKICAgICAgICAgIGlmIChjb25maXJtKSB7CiAgICAgICAgICAgIGNvbnN0IGF1dG9QbGF5ID0gY29uZmlnTWFuYWdlci5nZXRMb2NhbFN0b3JhZ2UoJ21lZGlhLmF1dG9QbGF5Jyk7CiAgICAgICAgICAgIGlmIChhdXRvUGxheSA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGFsZXJ0KGkxOG4udCgnY29uZmlnRmFpbCcpKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25maWdNYW5hZ2VyLnNldExvY2FsU3RvcmFnZSgnbWVkaWEuYXV0b1BsYXknLCAhYXV0b1BsYXkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KCiAgICAvLyDlnKjova7or6Lph43or5XnmoTml7blgJnvvIzlpoLmnpzlrp7kvovlj5jkuobvvIzmiJblpITkuo7pmpDol4/pobXpnaLkuK3liJnkuI3ov5vooYzoh6rliqjmkq3mlL7mk43kvZwKICAgIGlmICghY29uZmlnTWFuYWdlci5nZXQoJ21lZGlhLmF1dG9QbGF5JykgfHwgKCFwICYmIHQuaGFzSW5pdEF1dG9QbGF5KSB8fCAhcGxheWVyIHx8IChwICYmIHAgIT09IHQucGxheWVyKCkpIHx8IGRvY3VtZW50LmhpZGRlbikgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KCiAgICAvKioKICAgICAqIOWFg+e0oOS4jeWcqOWPr+inhuiMg+WbtO+8jOS4jeWFgeiuuOi/m+ihjOWIneWni+WMluiHquWKqOaSreaUvumAu+i+kQogICAgICog55Sx5LqOaWZyYW1l5LiL5YWD57Sg55qE5Y+v6KeG6IyD5Zu05Yik5pat5LiN5YeG56Gu77yM5omA5LulaWZyYW1l5LiL5Lmf56aB5q2i5Yid5aeL5YyW6Ieq5Yqo5pKt5pS+6YC76L6RCiAgICAgKiBUT0RPIOW+heS8mOWMlgogICAgICovCiAgICBpZiAoIWlzSW5WaWV3UG9ydChwbGF5ZXIpIHx8IGlzSW5JZnJhbWUoKSkgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KCiAgICBpZiAoIXRhc2tDb25mLmF1dG9QbGF5KSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIHQuaGFzSW5pdEF1dG9QbGF5ID0gdHJ1ZTsKCiAgICBpZiAocGxheWVyICYmIHRhc2tDb25mLmF1dG9QbGF5ICYmIHBsYXllci5wYXVzZWQpIHsKICAgICAgVENDJDEuZG9UYXNrKCdhdXRvUGxheScpOwogICAgICBpZiAocGxheWVyLnBhdXNlZCkgewogICAgICAgIC8vIOi9ruivoumHjeivlQogICAgICAgIGlmICghcGxheWVyLl9pbml0QXV0b1BsYXlDb3VudF8pIHsKICAgICAgICAgIHBsYXllci5faW5pdEF1dG9QbGF5Q291bnRfID0gMTsKICAgICAgICB9CiAgICAgICAgcGxheWVyLl9pbml0QXV0b1BsYXlDb3VudF8gKz0gMTsKICAgICAgICBpZiAocGxheWVyLl9pbml0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ybgogICAgfQoKICAgIGlmICghcGxheWVyKSByZXR1cm4KCiAgICBsZXQgY3VyUGxheWJhY2tSYXRlOwogICAgaWYgKG51bSkgewogICAgICBudW0gPSBOdW1iZXIobnVtKTsKICAgICAgaWYgKE51bWJlci5pc05hTihudW0pKSB7CiAgICAgICAgZGVidWcuZXJyb3IoJ2g1cGxheWVyOiDmkq3mlL7pgJ/luqbovazmjaLlh7rplJknKTsKICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgfQoKICAgICAgaWYgKG51bSA8PSAwKSB7CiAgICAgICAgbnVtID0gMC4xOwogICAgICB9IGVsc2UgaWYgKG51bSA+IDE2KSB7CiAgICAgICAgbnVtID0gMTY7CiAgICAgIH0KCiAgICAgIG51bSA9IE51bWJlcihudW0udG9GaXhlZCgxKSk7CiAgICAgIGN1clBsYXliYWNrUmF0ZSA9IG51bTsKICAgIH0gZWxzZSB7CiAgICAgIGN1clBsYXliYWNrUmF0ZSA9IHQuZ2V0UGxheWJhY2tSYXRlKCk7CiAgICB9CgogICAgLyog6K6w5b2V5pKt5pS+6YCf5bqm55qE5L+h5oGvICovCiAgICB0LnBsYXliYWNrUmF0ZSA9IGN1clBsYXliYWNrUmF0ZTsKICAgIGlmIChpc0luSWZyYW1lKCkpIHsKICAgICAgY29uZmlnTWFuYWdlci5zZXRHbG9iYWxTdG9yYWdlKCdtZWRpYS5wbGF5YmFja1JhdGUnLCBjdXJQbGF5YmFja1JhdGUpOwogICAgfSBlbHNlIHsKICAgICAgY29uZmlnTWFuYWdlci5zZXQoJ21lZGlhLnBsYXliYWNrUmF0ZScsIGN1clBsYXliYWNrUmF0ZSk7CiAgICB9CgogICAgaWYgKHQubWVkaWFQbHVzQXBpKSB7CiAgICAgIHQubWVkaWFQbHVzQXBpLnNldFBsYXliYWNrUmF0ZShjdXJQbGF5YmFja1JhdGUpOwoKICAgICAgaWYgKCEoIW51bSAmJiBjdXJQbGF5YmFja1JhdGUgPT09IDEpICYmICFub3RpcHMpIHsKICAg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fQogIH0sCgogIC8qKgogICAqIOWKoOW8uueJiOeahOWAjemAn+iwg+iKgu+8jOW9k+efreaXtumXtOWGheiuvue9ruWQjOS4gOS4quWAvOaXtu+8jOS8muiupOS4uumcgOabtOW/q+eahOi3s+mAn+iDveWKmwogICAqIOWImeS8muWvueiwg+mAn+eahOaVsOWAvOi/m+ihjOWPoOWKoOaUvuWkp++8jOS7juiAjOi+vuWIsOW/q+mAn+i3s+i3g+WcsOi/m+ihjOWAjemAn+iwg+iKgueahOebrueahAogICAqIOWPr+eUqOS6juinhumikeW5v+WRiueahOmrmOmAn+W/q+i/m++8jOeJh+WktOeJh+WwvueahOmAn+eci+etieWcuuaZrwogICAqIEBwYXJhbSB7Kn0gbnVtCiAgICovCiAgc2V0UGxheWJhY2tSYXRlUGx1czogZnVuY3Rpb24gKG51bSkgewogICAgbnVtID0gTnVtYmVyKG51bSk7CiAgICBpZiAoIW51bSB8fCAhTnVtYmVyLmlzSW50ZWdlcihudW0pKSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIGNvbnN0IHQgPSB0aGlzOwogICAgdC5wbGF5YmFja1JhdGVQbHVzSW5mbyA9IHQucGxheWJhY2tSYXRlUGx1c0luZm8gfHwge307CiAgICB0LnBsYXliYWNrUmF0ZVBsdXNJbmZvW251bV0gPSB0LnBsYXliYWNrUmF0ZVBsdXNJbmZvW251bV0gfHwgewogICAgICB0aW1lOiBEYXRlLm5vdygpIC0gMTAwMCwKICAgICAgdmFsdWU6IG51bQogICAgfTsKCiAgICBpZiAoRGF0ZS5ub3coKSAtIHQucGxheWJhY2tSYXRlUGx1c0luZm9bbnVtXS50aW1lIDwgMzAwKSB7CiAgICAgIHQucGxheWJhY2tSYXRlUGx1c0luZm9bbnVtXS52YWx1ZSA9IHQucGxheWJhY2tSYXRlUGx1c0luZm9bbnVtXS52YWx1ZSArIG51bTsKICAgIH0gZWxzZSB7CiAgICAgIHQucGxheWJhY2tSYXRlUGx1c0luZm9bbnVtXS52YW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iAgICBpZiAodGhpcy5wbGF5ZXIoKSkgewogICAgICB0aGlzLnVuTG9ja1BsYXliYWNrUmF0ZSgpOwogICAgICB0aGlzLnNldFBsYXliYWNrUmF0ZSh0aGlzLnBsYXllcigpLnBsYXliYWNrUmF0ZSArIG51bSk7CgogICAgICAvKiDpmLLmraLlpJbpg6josIPpgJ/pgLvovpHnmoTlubLmibDvvIzmiYDku6XplIHlrprkuIDmrrXml7bpl7QgKi8KICAgICAgdGhpcy5sb2NrUGxheWJhY2tSYXRlKDEwMDApOwogICAgfQogIH0sCgogIC8qIOmZjeS9juaSreaUvumAn+eOhyAqLwogIHNldFBsYXliYWNrUmF0ZURvd24gKG51bSkgewogICAgbnVtID0gbnVtRG93bihudW0pIHx8IC0wLjE7CiAgICBpZiAodGhpcy5wbGF5ZXIoKSkgewogICAgICB0aGlzLnVuTG9ja1BsYXliYWNrUmF0ZSgpOwogICAgICB0aGlzLnNldFBsYXliYWNrUmF0ZSh0aGlzLnBsYXllcigpLnBsYXliYWNrUmF0ZSArIG51bSk7CgogICAgICAvKiDpmLLmraLlpJbpg6josIPpgJ/pgLvovpHnmoTlubLmibDvvIzmiYDku6XplIHlrprkuIDmrrXml7bpl7QgKi8KICAgICAgdGhpcy5sb2NrUGxheWJhY2tSYXRlKDEwMDApOwogICAgfQogIH0sCgogIC8qKgogICAqIOmUgeWumuaSreaUvui/m+W6pueahOaOp+WItumAu+i+kQogICAqIOi3n+mUgeWumumfs+mHj+WSjOWAjemAn+S4jeS4gOagt++8jOaSreaUvui/m+W6puaYr+i3n+inhumikeWunuS+i+acieWvhuWIh+ebuOWFs+eahO+8jOaJgOS7peWFtumUgeWumuS/oeaBr+W/hemhu+S+nemZhOS6juaSreaUvuWunuS+iwogICAqLwogIGxvY2tDdXJyZW50VGltZTogZnVuY3Rpb24gKHRpbWVvdXQgPSAyMDApIHsKICAgIGlmICh0aGlzLm1lZGlhUGx1c0FwaSkgewogICAgICBpZiAoY29uZmlnTWFuYWdlci5nZXQ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lhUGx1c0FwaSkgewogICAgICByZXR1cm4gdGhpcy5tZWRpYVBsdXNBcGkuaXNMb2NrQ3VycmVudFRpbWUoKQogICAgfQoKICAgIGNvbnN0IHBsYXllciA9IHRoaXMucGxheWVyKCk7CiAgICBpZiAocGxheWVyICYmIHBsYXllci5jdXJyZW50VGltZUluZm8gJiYgcGxheWVyLmN1cnJlbnRUaW1lSW5mby5sb2NrVGltZW91dCkgewogICAgICByZXR1cm4gRGF0ZS5ub3coKSAtIHBsYXllci5jdXJyZW50VGltZUluZm8ubG9ja1RpbWVvdXQgPCAwCiAgICB9IGVsc2UgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KICB9LAoKICAvKiDorr7nva7mkq3mlL7ov5vluqYgKi8KICBzZXRDdXJyZW50VGltZTogZnVuY3Rpb24gKG51bSkgewogICAgaWYgKCFudW0gJiYgbnVtICE9PSAwKSByZXR1cm4KICAgIG51bSA9IE51bWJlcihudW0pOwogICAgY29uc3QgX251bSA9IE1hdGguYWJzKE51bWJlcihudW0udG9GaXhlZCgxKSkpOwoKICAgIGNvbnN0IHQgPSB0aGlzOwogICAgY29uc3QgcGxheWVyID0gdC5wbGF5ZXIoKTsKCiAgICBpZiAodC5pc0xvY2tDdXJyZW50VGltZSgpKSB7CiAgICAgIHJldHVybiBmYWxzZQogICAgfQoKICAgIGlmIChUQ0MkMS5kb1Rhc2soJ2N1cnJlbnRUaW1lJykpIHsKICAgICAgLy8gZGVidWcubG9nKCdbVENDXVtjdXJyZW50VGltZV0nLCAnc3VjJykKICAgICAgcmV0dXJuCiAgICB9CgogICAgaWYgKHRoaXMubWVkaWFQbHVzQXBpKSB7CiAgICAgIHRoaXMubWVkaWFQbHVzQXBpLnNldEN1cnJlbnRUaW1lKF9udW0pOwogICAgICByZXR1cm4gdHJ1ZQogICAgfQoKICAgIGRlbGV0ZSBwbGF5ZXIuY3VycmVudFRpbWU7CiAgICBwbGF5ZXIuY3VycmVudFRpbWUgPSBfbnVtOwogICAgcGxheWV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ICAgICAgICAgcGxheWVyLmN1cnJlbnRUaW1lSW5mby52YWx1ZSA9IHZhbDsKCiAgICAgICAgICByZXR1cm4gY3VycmVudFRpbWVEZXNjcmlwdG9yLnNldC5hcHBseShwbGF5ZXIsIGFyZ3VtZW50cykKICAgICAgICB9CiAgICAgIH0pOwogICAgfSBjYXRjaCAoZSkgewogICAgICBkZWJ1Zy5lcnJvcign6Kej6ZSBY3VycmVudFRpbWXlpLHotKUnLCBlKTsKICAgIH0KICB9LAoKICBzZXRDdXJyZW50VGltZVVwIChudW0pIHsKICAgIG51bSA9IE51bWJlcihudW1VcChudW0pIHx8IHRoaXMuc2tpcFN0ZXApOwoKICAgIGlmIChUQ0MkMS5kb1Rhc2soJ2FkZEN1cnJlbnRUaW1lJykpIDsgZWxzZSB7CiAgICAgIGlmICh0aGlzLnBsYXllcigpKSB7CiAgICAgICAgdGhpcy51bkxvY2tDdXJyZW50VGltZSgpOwogICAgICAgIHRoaXMuc2V0Q3VycmVudFRpbWUodGhpcy5wbGF5ZXIoKS5jdXJyZW50VGltZSArIG51bSk7CgogICAgICAgIC8qIOmYsuatouWklumDqOi/m+W6puaOp+WItumAu+i+keeahOW5suaJsO+8jOaJgOS7pemUgeWumuS4gOauteaXtumXtCAqLwogICAgICAgIHRoaXMubG9ja0N1cnJlbnRUaW1lKDUwMCk7CgogICAgICAgIHRoaXMudGlwcyhpMThuLnQoJ3RpcHNNc2cuZm9yd2FyZCcpICsgbnVtICsgaTE4bi50KCd0aXBzTXNnLnNlY29uZHMnKSk7CiAgICAgIH0KICAgIH0KICB9LAoKICBzZXRDdXJyZW50VGltZURvd24gKG51bSkgewogICAgbnVtID0gTnVtYmVyKG51bURvd24obnVtKSB8fCAtdGhpcy5za2lwU3RlcCk7CgogICAgaWYgKFRDQyQxLmRvVGFzaygnc3VidHJhY3RDdXJyZW50VGltZScpKSA7IGVsc2UgewogICAgICBpZiAodGhpcy5wbGF5ZXIoKSkgewogICAgICAgIGxldCBjdXJyZW50VGlt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Wb2x1bWUoKQogICAgfQoKICAgIHJldHVybiBEYXRlLm5vdygpIC0gdGhpcy52b2x1bWVJbmZvLmxvY2tUaW1lb3V0IDwgMAogIH0sCgogIC8qIOiuvue9ruWjsOmfs+Wkp+WwjyAqLwogIHNldFZvbHVtZTogZnVuY3Rpb24gKG51bSwgbm90aXBzLCBvdXRlckNhbGwpIHsKICAgIGNvbnN0IHQgPSB0aGlzOwogICAgY29uc3QgcGxheWVyID0gdC5wbGF5ZXIoKTsKCiAgICBpZiAodC5pc0xvY2tWb2x1bWUoKSkgewogICAgICByZXR1cm4gZmFsc2UKICAgIH0KCiAgICBpZiAoIW51bSAmJiBudW0gIT09IDApIHsKICAgICAgbnVtID0gdC5nZXRWb2x1bWUoKTsKICAgIH0KCiAgICBudW0gPSBOdW1iZXIobnVtKS50b0ZpeGVkKDIpOwogICAgaWYgKG51bSA8IDApIHsKICAgICAgbnVtID0gMDsKICAgIH0KCiAgICBpZiAobnVtID4gMSAmJiBjb25maWdNYW5hZ2VyLmdldCgnZW5oYW5jZS5hbGxvd0Fjb3VzdGljR2FpbicpKSB7CiAgICAgIG51bSA9IE1hdGguY2VpbChudW0pOwoKICAgICAgdHJ5IHsKICAgICAgICBwbGF5ZXIuX2FtcF8gPSBwbGF5ZXIuX2FtcF8gfHwgbmV3IE1lZGlhRWxlbWVudEFtcGxpZmllcihwbGF5ZXIpOwogICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgbnVtID0gMTsKICAgICAgICBkZWJ1Zy5lcnJvcign5aqS5L2T5aOw6Z+z5ZON5bqm5aKe55uK6YC76L6R5byC5bi4JywgZSk7CiAgICAgIH0KCiAgICAgIC8qIOmZkOWumuWinuebiueahOacgOWkp+WAvCAqLwogICAgICBpZiAobnVtID4gNikgewogICAgICAgIG51bSA9IDY7CiAgICAgIH0KCiAgICAgIGlmICghcGxheWVyLl9hbXBfIHx8ICFwbGF5ZXIuX2FtcF8uc2V0TG91ZG5lc3MpIHsKICAgICAgICBudW0gPS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29uZmlnTWFuYWdlci5nZXQoJ2VuaGFuY2UuYmxvY2tTZXRWb2x1bWUnKSA9PT0gdHJ1ZSkgewogICAgICAgICAgICAgIHJldHVybiBmYWxzZQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHQuc2V0Vm9sdW1lKHZhbCwgZmFsc2UsIHRydWUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICBkZWJ1Zy5lcnJvcign6Kej6ZSBdm9sdW1l5aSx6LSlJywgZSk7CiAgICAgIH0KICAgIH0KCiAgICAvKiDosIPoioLpn7Pph4/nmoTml7blgJnpobrkvr/miorpnZnpn7PmqKHlvI/lhbPpl60gKi8KICAgIGlmICghb3V0ZXJDYWxsKSB7IHBsYXllci5tdXRlZCA9IGZhbHNlOyB9CgogICAgIW5vdGlwcyAmJiB0LnRpcHMoaTE4bi50KCd0aXBzTXNnLnZvbHVtZScpICsgcGFyc2VJbnQocGxheWVyLnZvbHVtZSAqIDEwMCkgKyAnJScpOwogIH0sCgogIHNldFZvbHVtZVVwIChudW0pIHsKICAgIG51bSA9IG51bVVwKG51bSkgfHwgMC4yOwogICAgY29uc3QgcGxheWVyID0gdGhpcy5wbGF5ZXIoKTsKICAgIGlmIChwbGF5ZXIpIHsKICAgICAgdGhpcy51bkxvY2tWb2x1bWUoKTsKCiAgICAgIGlmICh0aGlzLnZvbHVtZSA+IDEgJiYgcGxheWVyLl9hbXBfKSB7CiAgICAgICAgdGhpcy5zZXRWb2x1bWUodGhpcy52b2x1bWUgKyBudW0pOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuc2V0Vm9sdW1lKHBsYXllci52b2x1bWUgKyBudW0pOwogICAgICB9CgogICAgICAvKiDpmLLmraLlpJbpg6josIPpn7PpgLvovpHnmoTlubLmibDvvIzmiYDku6XplIHlrprkuIDmrrXml7bpl7QgKi8KICAgICAgdGhpcy5sb2NrVm9sdW1l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gKz0gYCAke2kxOG4udCgndGlwc01zZy5ob3Jpem9udGFsTWlycm9yJyl9ICR7dC5yb3RhdGVZfWRlZ2A7CiAgICB9CgogICAgdC5zZXRUcmFuc2Zvcm0odHJ1ZSk7CiAgICB0LnRpcHModGlwc01zZyk7CiAgfSwKCiAgLyog57yp5pS+6KeG6aKR55S76Z2iICovCiAgc2V0U2NhbGUgKG51bSkgewogICAgaWYgKE51bWJlci5pc05hTih0aGlzLnNjYWxlKSB8fCBOdW1iZXIuaXNOYU4obnVtKSkgewogICAgICB0aGlzLnNjYWxlID0gMTsKICAgIH0gZWxzZSB7CiAgICAgIHRoaXMuc2NhbGUgPSBudW07CiAgICB9CgogICAgdGhpcy5zZXRUcmFuc2Zvcm0oKTsKICB9LAoKICAvKiDop4bpopHmlL7lpKcgKzAuMSAqLwogIHNldFNjYWxlVXAgKG51bSkgewogICAgbnVtID0gbnVtVXAobnVtKSB8fCAwLjA1OwogICAgdGhpcy5zZXRTY2FsZShOdW1iZXIodGhpcy5zY2FsZSkgKyBudW0pOwogIH0sCgogIC8qIOinhumikee8qeWwjyAtMC4xICovCiAgc2V0U2NhbGVEb3duIChudW0pIHsKICAgIG51bSA9IG51bURvd24obnVtKSB8fCAtMC4wNTsKICAgIHRoaXMuc2V0U2NhbGUoTnVtYmVyKHRoaXMuc2NhbGUpICsgbnVtKTsKICB9LAoKICAvKiDorr7nva7op4bpopHnlLvpnaLnmoTkvY3np7vlsZ7mgKcgKi8KICBzZXRUcmFuc2xhdGUgKHgsIHkpIHsKICAgIGlmICh0eXBlb2YgeCA9PT0gJ251bWJlcicpIHsKICAgICAgdGhpcy50cmFuc2xhdGUueCA9IHg7CiAgICB9CgogICAgaWYgKHR5cGVvZiB5ID09PSAnbnVtYmVyJykgewogICAgICB0aGlzLnRyYW5zbGF0ZS55ID0geTsKICAgIH0KCiAgICB0aGlzLnNldFRyYW5zZm9ybSgpOwogIH0sCgogIC8qIOinhumikeeUu+mdouWQkeWPs+W5s+enuyAqL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NlIHsKICAgICAgcGxheWVyLnJlcXVlc3RQaWN0dXJlSW5QaWN0dXJlICYmIHBsYXllci5yZXF1ZXN0UGljdHVyZUluUGljdHVyZSgpLnRoZW4oKCkgPT4gewogICAgICAgIHdpbmRvdy5faXNQaWN0dXJlSW5QaWN0dXJlXyA9IHRydWU7CiAgICAgIH0pLmNhdGNoKChlKSA9PiB7CiAgICAgICAgd2luZG93Ll9pc1BpY3R1cmVJblBpY3R1cmVfID0gbnVsbDsKICAgICAgICBkZWJ1Zy5lcnJvcignW3RvZ2dsZVBpY3R1cmVJblBpY3R1cmVdJywgZSk7CiAgICAgIH0pOwogICAgfQogIH0sCgogIC8qIOaSreaUvuS4i+S4gOS4quinhumike+8jOm7mOiupOaYr+ayoeaciei/meS4quWKn+iDveeahO+8jOWPquacieWcqFRDQ+mHjOmFjee9ruS6hm5leHTlrZfmrrXmiY3kvJrmnInor6Xlip/og70gKi8KICBzZXROZXh0VmlkZW8gKCkgewogICAgY29uc3QgaXNEbyA9IFRDQyQxLmRvVGFzaygnbmV4dCcpOwogICAgaWYgKCFpc0RvKSB7CiAgICAgIGRlYnVnLmxvZygn5b2T5YmN572R6aG15LiN5pSv5oyB5LiA6ZSu5pKt5pS+5LiL5Liq6KeG6aKR5Yqf6IO9ficpOwogICAgfQogIH0sCgogIC8qIOWIh+aNouaSreaUvueKtuaAgSAqLwogIHN3aXRjaFBsYXlTdGF0dXMgKCkgewogICAgY29uc3QgdCA9IHRoaXM7CiAgICBjb25zdCBwbGF5ZXIgPSB0LnBsYXllcigpOwogICAgaWYgKFRDQyQxLmRvVGFzaygnc3dpdGNoUGxheVN0YXR1cycpKSB7CiAgICAgIC8vIGRlYnVnLmxvZygnW1RDQ11bc3dpdGNoUGxheVN0YXR1c10nLCAnc3VjJykKICAgICAgcmV0dXJuCiAgICB9CgogICAgaWYgKHBsYXllci5wYXVzZWQpIHsKICAgICAgaWYgKFRDQyQxLmRvVGFzaygncGxheScpKSA7IGVsc2UgewogICAgICAgIGlmICh0Lm1lZGlhUGx1c0FwaSkgewogICAgICAgICAgdC5tZWRpYVBsdXNBcGkubG9ja1BhdXNlKDQwMCk7CiAgICAgICAgICB0Lm1lZGlhUGx1c0FwaS5hcHBseVBsYXkoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgLyog5oyC6LW35YW25a6D6YC76L6R55qE5pqC5YGc5pON5L2c77yM56Gu5L+d5pKt5pS+54q25oCB55Sf5pWIICovCiAgICAgICAgICBpZiAocGxheWVyLl9oYW5nVXBfIGluc3RhbmNlb2YgRnVuY3Rpb24pIHsKICAgICAgICAgICAgcGxheWVyLl9oYW5nVXBfKCdwYXVzZScsIDQwMCk7CiAgICAgICAgICAgIHBsYXllci5fdW5IYW5nVXBfKCdwbGF5Jyk7CiAgICAgICAgICB9CgogICAgICAgICAgcGxheWVyLnBsYXkoKTsKICAgICAgICB9CgogICAgICAgIHQudGlwcyhpMThuLnQoJ3RpcHNNc2cucGxheScpKTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgaWYgKFRDQyQxLmRvVGFzaygncGF1c2UnKSkgOyBlbHNlIHsKICAgICAgICBpZiAodC5tZWRpYVBsdXNBcGkpIHsKICAgICAgICAgIHQubWVkaWFQbHVzQXBpLmxvY2tQbGF5KDQwMCk7CiAgICAgICAgICB0Lm1lZGlhUGx1c0FwaS5hcHBseVBhdXNlKCk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIC8qIOaMgui1t+WFtuWug+mAu+i+keeahOaSreaUvuaTjeS9nO+8jOehruS/neaaguWBnOeKtuaAgeeUn+aViCAqLwogICAgICAgICAgaWYgKHBsYXllci5faGFuZ1VwXyBpbnN0YW5jZW9mIEZ1bmN0aW9uKSB7CiAgICAgICAgICAgIHBsYXllci5faGFuZ1VwXygncGxheScsIDQwMCk7CiAgICAgICAgICAgIHBsYXllci5fdW5IYW5nVXBfKCdwYXVzZScpOwogICAgICAgICAgfQoKICAgICAgICAgIHBsYXllci5wYXVzZSgpOwogICA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cykgewogICAgICB0LnRpcHMoaTE4bi50KCd0aXBzTXNnLmFycGwnKSk7CiAgICAgIHQuc2V0UGxheVByb2dyZXNzKHQucGxheWVyKCkpOwogICAgfSBlbHNlIHsKICAgICAgdC50aXBzKGkxOG4udCgndGlwc01zZy5kcnBsJykpOwogICAgfQogIH0sCiAgdGlwc0NsYXNzTmFtZTogJ2h0bWxfcGxheWVyX2VuaGFuY2VfdGlwcycsCgogIGdldFRpcHNDb250YWluZXI6IGZ1bmN0aW9uICh2aWRlb0VsKSB7CiAgICBjb25zdCB0ID0gaDVQbGF5ZXI7CiAgICBjb25zdCBwbGF5ZXIgPSB2aWRlb0VsIHx8IHQucGxheWVyKCk7CiAgICAvLyDkvb/nlKhnZXRDb250YWluZXLojrflj5bliLDnmoTniLboioLngrnlvIrnq6/lpKrlpJrvvIzmmoLml7blvIPnlKgKICAgIC8vIGNvbnN0IF90aXNwQ29udGFpbmVyXyA9IHBsYXllci5fdGlzcENvbnRhaW5lcl8gIHx8ICBnZXRDb250YWluZXIocGxheWVyKTsKCiAgICBsZXQgdGlzcENvbnRhaW5lciA9IHBsYXllci5wYXJlbnROb2RlIHx8IHBsYXllcjsKCiAgICAvKiDlpoLmnpzniLboioLngrnkuLrml6Dplb/lrr3nmoTlhYPntKDvvIzliJnlho3lvoDkuIrmn6Xmib7kuIDnuqcgKi8KICAgIGNvbnN0IGNvbnRhaW5lckJveCA9IHRpc3BDb250YWluZXIuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICBpZiAoKCFjb250YWluZXJCb3gud2lkdGggfHwgIWNvbnRhaW5lckJveC5oZWlnaHQpICYmIHRpc3BDb250YWluZXIucGFyZW50Tm9kZSkgewogICAgICB0aXNwQ29udGFpbmVyID0gdGlzcENvbnRhaW5lci5wYXJlbnROb2RlOwogICAgfQoKICAgIHJldHVybiB0aXNwQ29udGFpbmVyCiAgfSwKICB0aXBzOiBmdW5jdGlvbiAoc3RyKSB7CiAgICBjb25zdCB0ID0g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iAgICAvLyB0cmFuc2Zvcm06IHRyYW5zbGF0ZSgtNTAlLC01MCUpOwogICAgbGV0IHRpcHNTdHlsZSA9IGAKICAgICAgcG9zaXRpb246IGFic29sdXRlOwogICAgICB6LWluZGV4OiA5OTk5OTk7CiAgICAgIGZvbnQtc2l6ZTogJHt0LmZvbnRTaXplIHx8IDE2fXB4OwogICAgICBwYWRkaW5nOiA1cHggMTBweDsKICAgICAgYmFja2dyb3VuZDogcmdiYSgwLDAsMCwwLjQpOwogICAgICBjb2xvcjp3aGl0ZTsKICAgICAgdG9wOiAwOwogICAgICBsZWZ0OiAwOwogICAgICB0cmFuc2l0aW9uOiBhbGwgNTAwbXMgZWFzZTsKICAgICAgb3BhY2l0eTogMDsKICAgICAgYm9yZGVyLWJvdHRvbS1yaWdodC1yYWRpdXM6IDVweDsKICAgICAgZGlzcGxheTogbm9uZTsKICAgICAgLXdlYmtpdC1mb250LXNtb290aGluZzogc3VicGl4ZWwtYW50aWFsaWFzZWQ7CiAgICAgIGZvbnQtZmFtaWx5OiAnbWljcm9zb2Z0IHlhaGVpJywgVmVyZGFuYSwgR2VuZXZhLCBzYW5zLXNlcmlmOwogICAgICAtd2Via2l0LXVzZXItc2VsZWN0OiBub25lOwogICAgYDsKCiAgICBpZiAoaXNBdWRpbykgewogICAgICB0aXBzU3R5bGUgPSBgCiAgICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICAgIHotaW5kZXg6IDk5OTk5OTsKICAgICAgICBmb250LXNpemU6ICR7dC5mb250U2l6ZSB8fCAxNn1weDsKICAgICAgICBwYWRkaW5nOiA1cHggMTBweDsKICAgICAgICBiYWNrZ3JvdW5kOiByZ2JhKDAsMCwwLDAuNCk7CiAgICAgICAgY29sb3I6d2hpdGU7CiAgICAgICAgYm90dG9tOiAwOwogICAgICAgIHJpZ2h0OiAwOwogICAgICAgIHRyYW5zaXRpb246IGFsbCA1MDBtcyBlYXNlOwogICAgICAgIG9wYWNpdHk6IDA7CiAgICAgICAgYm9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dXAoKTsKICAgIHQudGlwcyhpMThuLnQoYHRpcHNNc2cuJHtuYW1lTWFwW2l0ZW1dfWApICsgcGFyc2VJbnQodC5maWx0ZXIua2V5W2l0ZW1dICogMTAwKSArICclJyk7CiAgfSwKCiAgLyog6K6+572u6KeG6aKR55qE5Lqu5bqmICovCiAgc2V0QnJpZ2h0bmVzcyAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigwLCBudW0pOwogIH0sCgogIC8qIOaPkOWNh+inhumikeeahOS6ruW6piAqLwogIHNldEJyaWdodG5lc3NVcCAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigwLCBudW0gfHwgMC4xKTsKICB9LAoKICAvKiDpmY3kvY7op4bpopHnmoTkuq7luqYgKi8KICBzZXRCcmlnaHRuZXNzRG93biAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigwLCBudW0gfHwgLTAuMSwgdHJ1ZSk7CiAgfSwKCiAgLyog6K6+572u6KeG6aKR55qE5a+55q+U5bqmICovCiAgc2V0Q29udHJhc3QgKG51bSkgewogICAgdGhpcy5zZXRGaWx0ZXIoMSwgbnVtKTsKICB9LAoKICAvKiDmj5DljYfop4bpopHnmoTlr7nmr5TluqYgKi8KICBzZXRDb250cmFzdFVwIChudW0pIHsKICAgIHRoaXMuc2V0RmlsdGVyKDEsIG51bSB8fCAwLjEpOwogIH0sCgogIC8qIOmZjeS9juinhumikeeahOWvueavlOW6piAqLwogIHNldENvbnRyYXN0RG93biAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigxLCBudW0gfHwgLTAuMSwgdHJ1ZSk7CiAgfSwKCiAgLyog6K6+572u6aWx5ZKM5bqmICovCiAgc2V0U2F0dXJhdGlvbiAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigyLCBudW0pOwogIH0sCgogIC8qIOaPkOWNh+mlseWSjOW6piAqLwogIHNldFNhdHVyYXRpb25VcCAobnVtKSB7CiAgICB0aGlzLnNldEZpbHRlcigyLCBudW0gfHwg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b25zdCBrZXlDb2RlID0gZXZlbnQua2V5Q29kZTsKICAgIGNvbnN0IGtleSA9IGV2ZW50LmtleS50b0xvd2VyQ2FzZSgpOwoKICAgIGlmIChldmVudC5zaGlmdEtleSAmJiAhZXZlbnQuY3RybEtleSAmJiAhZXZlbnQuYWx0S2V5ICYmICFldmVudC5tZXRhS2V5KSB7CiAgICAgIC8vIOe9kemhteWFqOWxjwogICAgICBpZiAoa2V5ID09PSAnZW50ZXInKSB7CiAgICAgICAgdC5zZXRXZWJGdWxsU2NyZWVuKCk7CiAgICAgIH0KCiAgICAgIC8vIOi/m+WFpeaIlumAgOWHuueUu+S4reeUu+aooeW8jwogICAgICBpZiAoa2V5ID09PSAncCcpIHsKICAgICAgICB0LnRvZ2dsZVBpY3R1cmVJblBpY3R1cmUoKTsKICAgICAgfQoKICAgICAgLy8g5oiq5Zu+5bm25LiL6L295L+d5a2YCiAgICAgIGlmIChrZXkgPT09ICdzJykgewogICAgICAgIHQuY2FwdHVyZSgpOwogICAgICB9CgogICAgICBpZiAoa2V5ID09PSAncicpIHsKICAgICAgICB0LnN3aXRjaFJlc3RvcmVQbGF5UHJvZ3Jlc3NTdGF0dXMoKTsKICAgICAgfQoKICAgICAgaWYgKGtleSA9PT0gJ20nKSB7CiAgICAgICAgLyog5Z6C55u06ZWc5YOP57+76L2sICovCiAgICAgICAgdC5zZXRNaXJyb3IodHJ1ZSk7CiAgICAgIH0KCiAgICAgIGlmIChrZXkgPT09ICdkJykgewogICAgICAgIHQubWVkaWFEb3dubG9hZCgpOwogICAgICB9CgogICAgICAvLyDop4bpopHnlLvpnaLnvKnmlL7nm7jlhbPkuovku7YKICAgICAgY29uc3QgYWxsb3dLZXlzID0gWyd4JywgJ2MnLCAneicsICdhcnJvd3JpZ2h0JywgJ2Fycm93bGVmdCcsICdhcnJvd3VwJywgJ2Fycm93ZG93biddOwogICAgICBpZiAoIWFsbG93S2V5cy5pbmNsdWRlcyhrZXkpKSByZXR1cm4KCiAgICAgIHQuc2NhbGUgPSBOdW1iZXIodC5zY2FsZSk7CiAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgLy8gc2hpZnQrWO+8muinhumikee8qeWwjyAtMC4xCiAgICAgICAgY2FzZSAneCc6CiAgICAgICAgICB0LnNldFNjYWxlRG93bigpOwogICAgICAgICAgYnJlYWsKICAgICAgICAvLyBzaGlmdCtD77ya6KeG6aKR5pS+5aSnICswLjEKICAgICAgICBjYXNlICdjJzoKICAgICAgICAgIHQuc2V0U2NhbGVVcCgpOwogICAgICAgICAgYnJlYWsKICAgICAgICAvLyBzaGlmdCta77ya6KeG6aKR5oGi5aSN5q2j5bi45aSn5bCPCiAgICAgICAgY2FzZSAneic6CiAgICAgICAgICB0LnJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICBicmVhawogICAgICAgIGNhc2UgJ2Fycm93cmlnaHQnOgogICAgICAgICAgdC5zZXRUcmFuc2xhdGVSaWdodCgpOwogICAgICAgICAgYnJlYWsKICAgICAgICBjYXNlICdhcnJvd2xlZnQnOgogICAgICAgICAgdC5zZXRUcmFuc2xhdGVMZWZ0KCk7CiAgICAgICAgICBicmVhawogICAgICAgIGNhc2UgJ2Fycm93dXAnOgogICAgICAgICAgdC5zZXRUcmFuc2xhdGVVcCgpOwogICAgICAgICAgYnJlYWsKICAgICAgICBjYXNlICdhcnJvd2Rvd24nOgogICAgICAgICAgdC5zZXRUcmFuc2xhdGVEb3duKCk7CiAgICAgICAgICBicmVhawogICAgICB9CgogICAgICAvLyDpmLvmraLkuovku7blhpLms6EKICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgIHJldHVybiB0cnVlCiAgICB9CgogICAgLy8gY3RybCvmlrnlkJHplK7lj7PihpLvvJrlv6vov5szMOenkgogICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYga2V5Q29kZSA9PT0gMzkpIHsKICAgICAgdC5zZXRDdX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AgICB9CgogICAgLy8g5oyJ6ZSuRe+8muS6ruW6puWinuWKoCUKICAgIGlmIChrZXlDb2RlID09PSA2OSkgewogICAgICB0LnNldEJyaWdodG5lc3NVcCgpOwogICAgfQogICAgLy8g5oyJ6ZSuV++8muS6ruW6puWHj+WwkSUKICAgIGlmIChrZXlDb2RlID09PSA4NykgewogICAgICB0LnNldEJyaWdodG5lc3NEb3duKCk7CiAgICB9CgogICAgLy8g5oyJ6ZSuVO+8muWvueavlOW6puWinuWKoCUKICAgIGlmIChrZXlDb2RlID09PSA4NCkgewogICAgICB0LnNldENvbnRyYXN0VXAoKTsKICAgIH0KICAgIC8vIOaMiemUrlLvvJrlr7nmr5Tluqblh4/lsJElCiAgICBpZiAoa2V5Q29kZSA9PT0gODIpIHsKICAgICAgdC5zZXRDb250cmFzdERvd24oKTsKICAgIH0KCiAgICAvLyDmjInplK5V77ya6aWx5ZKM5bqm5aKe5YqgJQogICAgaWYgKGtleUNvZGUgPT09IDg1KSB7CiAgICAgIHQuc2V0U2F0dXJhdGlvblVwKCk7CiAgICB9CiAgICAvLyDmjInplK5Z77ya6aWx5ZKM5bqm5YeP5bCRJQogICAgaWYgKGtleUNvZGUgPT09IDg5KSB7CiAgICAgIHQuc2V0U2F0dXJhdGlvbkRvd24oKTsKICAgIH0KCiAgICAvLyDmjInplK5P77ya6Imy55u45aKe5YqgIDEg5bqmCiAgICBpZiAoa2V5Q29kZSA9PT0gNzkpIHsKICAgICAgdC5zZXRIdWVVcCgpOwogICAgfQogICAgLy8g5oyJ6ZSuSe+8muiJsuebuOWHj+WwkSAxIOW6pgogICAgaWYgKGtleUNvZGUgPT09IDczKSB7CiAgICAgIHQuc2V0SHVlRG93bigpOwogICAgfQoKICAgIC8vIOaMiemUrkvvvJrmqKHns4rlop7liqAgMSBweAogICAgaWYgKGtleUNvZGUgPT09IDc1KSB7CiAgICAgIHQuc2V0Qmx1clVwKCk7CiAgICB9CiAgICAvLyDmjInplK5K77ya5qih57OK5YeP5bCRIDEgcHgKICAgIGlmIChrZXlDb2RlID09PSA3NCkgewogICAgICB0LnNldEJsdXJEb3duKCk7CiAgICB9CgogICAgLy8g5oyJ6ZSuUe+8muWbvuWDj+WkjeS9jQogICAgaWYgKGtleUNvZGUgPT09IDgxKSB7CiAgICAgIHQucmVzZXRGaWx0ZXJBbmRUcmFuc2Zvcm0oKTsKICAgIH0KCiAgICAvLyDmjInplK5T77ya55S76Z2i5peL6L2sIDkwIOW6pgogICAgaWYgKGtleUNvZGUgPT09IDgzKSB7CiAgICAgIHQuc2V0Um90YXRlKCk7CiAgICB9CgogICAgLyog5rC05bmz6ZWc5YOP57+76L2sICovCiAgICBpZiAoa2V5Q29kZSA9PT0gNzcpIHsKICAgICAgdC5zZXRNaXJyb3IoKTsKICAgIH0KCiAgICAvLyDmjInplK7lm57ovabvvIzov5vlhaXlhajlsY8KICAgIGlmIChrZXlDb2RlID09PSAxMykgewogICAgICB0LnNldEZ1bGxTY3JlZW4oKTsKICAgIH0KCiAgICBpZiAoa2V5ID09PSAnbicpIHsKICAgICAgdC5zZXROZXh0VmlkZW8oKTsKICAgIH0KCiAgICAvLyDpmLvmraLkuovku7blhpLms6EKICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgIHJldHVybiB0cnVlCiAgfSwKCiAgLyog6L+Q6KGM6Ieq5a6a5LmJ55qE5b+r5o236ZSu5pON5L2c77yM5aaC5p6c6L+Q6KGM5LqG5Lya6L+U5ZuedHJ1ZSAqLwogIHJ1bkN1c3RvbVNob3J0Y3V0czogZnVuY3Rpb24gKHBsYXllciwgZXZlbnQpIHsKICAgIGlmICghcGxheWVyIHx8ICFldmVudCkgcmV0dXJuCiAgICBjb25zdCBrZXkgPSBldmVudC5rZXkudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IHRhc2tDb25mID0gVENDJDEuZ2V0VGFza0NvbmZpZygpOwogICAgY29uc3QgY29uZklzQ29ycmVjdCA9IGlzT2JqKHRhc2tDb25mLnNob3J0Y3V0cykgJiYKICAgICAgQXJyYXkuaXNBcnJheSh0YXNrQ29uZi5zaG9ydGN1dHMucmVnaXN0ZXIpICYmCiAgICAgIHRhc2tDb25mLnNob3J0Y3V0cy5jYWxsYmFjayBpbnN0YW5jZW9mIEZ1bmN0aW9uOwoKICAgIC8qIOWIpOaWreW9k+WJjeinpuWPkeeahOW/q+aNt+mUruaYr+WQpuW3suiiq+azqOWGjCAqLwogICAgZnVuY3Rpb24gaXNSZWdpc3RlciAoKSB7CiAgICAgIGNvbnN0IGxpc3QgPSB0YXNrQ29uZi5zaG9ydGN1dHMucmVnaXN0ZXI7CgogICAgICAvKiDlvZPliY3op6blj5HnmoTnu4TlkIjplK4gKi8KICAgICAgY29uc3QgY29tYmluZUtleSA9IFtdOwogICAgICBpZiAoZXZlbnQuY3RybEtleSkgewogICAgICAgIGNvbWJpbmVLZXkucHVzaCgnY3RybCcpOwogICAgICB9CiAgICAgIGlmIChldmVudC5zaGlmdEtleSkgewogICAgICAgIGNvbWJpbmVLZXkucHVzaCgnc2hpZnQnKTsKICAgICAgfQogICAgICBpZiAoZXZlbnQuYWx0S2V5KSB7CiAgICAgICAgY29tYmluZUtleS5wdXNoKCdhbHQnKTsKICAgICAgfQogICAgICBpZiAoZXZlbnQubWV0YUtleSkgewogICAgICAgIGNvbWJpbmVLZXkucHVzaCgnY29tbWFuZCcpOwogICAgICB9CgogICAgICBjb21iaW5lS2V5LnB1c2goa2V5KTsKCiAgICAgIC8qIOmAmui/h+W+queOr+WIpOaWreW9k+WJjeinpuWPkeeahOe7hOWQiOmUruWSjOW3suazqOWGjOeahOe7hOWQiOmUruaYr+WQpuWujOWFqOS4gOiHtCAqLwogICAgICBsZXQgaGFzUmVnID0gZmFsc2U7CiAgICAgIGxpc3QuZm9yRWFjaCgoc2hvcnRjdXQpID0+IHsKICAgICAgICBjb25zdCByZWdLZXkgPSBzaG9ydGN1dC5zcGxpdCgnKycpOwogICAgICAgIGlmIChjb21iaW5lS2V5Lmxlbmd0aCA9PT0gcmVnS2V5Lmxlbmd0aCkgewogICAgICAgICAgbGV0IGFsbE1hdGNoID0gdHJ1ZTsKICAgICAgICAgIHJlZ0tleS5mb3JFYWNoKChrZXkpID0+IHsKICAgICAgICAgICAgaWYgKCFjb21iaW5lS2V5LmluY2x1ZGVzKGtleSkpIHsKICAgICAgICAgICAgICBhbGxNYXRjaCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9KTsKICAgICAgICAgIGlmIChhbGxNYXRjaCkgewogICAgICAgICAgICBoYXNSZWcgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSk7CgogICAgICByZXR1cm4gaGFzUmVnCiAgICB9CgogICAgaWYgKGNvbmZJc0NvcnJlY3QgJiYgaXNSZWdpc3RlcigpKSB7CiAgICAgIC8vIOaJp+ihjOiHquWumuS5ieW/q+aNt+mUruaTjeS9nAogICAgICBjb25zdCBpc0RvID0gVENDJDEuZG9UYXNrKCdzaG9ydGN1dHMnLCB7CiAgICAgICAgZXZlbnQsCiAgICAgICAgcGxheWVyLAogICAgICAgIGg1UGxheWVyCiAgICAgIH0pOwoKICAgICAgaWYgKGlzRG8pIHsKICAgICAgICBldmVudC5zdG9wUHJvcGFnYXRpb24oKTsKICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICB9CgogICAgICByZXR1cm4gaXNEbwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuIGZhbHNlCiAgICB9CiAgfSwKCiAgLyog5oyJ6ZSu5ZON5bqU5pa55rOVICovCiAga2V5ZG93bkV2ZW50OiBmdW5jdGlvbiAoZXZlbnQpIHsKICAgIGNvbnN0IHQgPSBoNVBsYXllcjsKICAgIGNvbnN0IGtleUNvZGUgPSBldmVudC5rZXlDb2RlOwogICAgLy8gY29uc3Qga2V5ID0gZXZlbnQua2V5LnRvTG93ZXJDYXNlKCkKICAgIGNvbnN0IHBsYXllciA9IHQucGxheWVyKCk7CgogICAgLyog5aSE5LqO5Y+v57yW6L6R5YWD57Sg5Lit5LiN5omn6KGM5Lu75L2V5b+r5o236ZSuICovCiAgICBpZiAoaXNFZGl0YWJsZVRhcmdldChldmVudC50YXJnZXQpKSByZXR1cm4KCiAgICAvKiDlub/mkq3mjInplK7mtojmga/vvIzov5vooYzot6jln5/mjqfliLYgKi8KICAgIG1vbmtleU1zZy5zZW5kKCdnbG9iYWxLZXlkb3duRXZlbnQnLCBldmVudCwgMCk7CgogICAgaWYgKCFwbGF5ZXIpIHsKICAgICAgaWYgKHQuaGFzQ3Jvc3NPcmlnaW5WaWRlb0RldGVjdGVkKSB7CiAgICAgICAgaWYgKCFjb25maWdNYW5hZ2VyLmdldCgnZW5oYW5jZS5hbGxvd0Nyb3NzT3JpZ2luQ29udHJvbCcpKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgICB9CgogICAgICAgIC8qKgogICAgICAgICAqIOWIqeeUqOeDremUrui/kOihjOWZqOeahOWMuemFjeiDveWKm+adpeWGs+WumuimgeS4jeimgeemgeatouS6i+S7tuWGkuazoeWSjOmYu+atoum7mOiupOS6i+S7tgogICAgICAgICAqIOino+WGs+WkhOS6jui3qFRBQuOAgei3qOWfn+aOp+WItuaXtumAoOaIkOWFtuWug+m7mOiupOW/q+aNt+mUruWTjeW6lOW8guW4uOeahOmXrumimAogICAgICAgICAqLwogICAgICAgIGlmICh0LmhvdGtleXNSdW5uZXIgJiYgdC5ob3RrZXlzUnVubmVyLnJ1bikgewogICAgICAgICAgdC5ob3RrZXlzUnVubmVyLnJ1bih7CiAgICAgICAgICAgIGV2ZW50LAogICAgICAgICAgICBzdG9wUHJvcGFnYXRpb246IHRydWUsCiAgICAgICAgICAgIHByZXZlbnREZWZhdWx0OiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdC5yZWdpc3RlckhvdGtleXNSdW5uZXIoKTsKICAgICAgICAgIGV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lCiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9KTsKCiAgICAgIGlmIChtYXRjaFJlc3VsdCkgewogICAgICAgIGRlYnVnLmluZm8oJ1tob3RrZXlzUnVubmVyXVttYXRjaFJlc3VsdF0nLCBtYXRjaFJlc3VsdCk7CiAgICAgICAgcmV0dXJuIHRydWUKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgLyog5pyq55So5Yiw55qE5oyJ6ZSu5LiN6L+b6KGM5Lu75L2V5LqL5Lu255uR5ZCsICovCiAgICAgIGlmICghaXNSZWdpc3RlcktleShldmVudCkpIHsgcmV0dXJuIGZhbHNlIH0KCiAgICAgIC8qIOWTjeW6lOaSreaUvuWZqOebuOWFs+aTjeS9nCAqLwogICAgICB0LnBhbHllclRyaWdnZXIocGxheWVyLCBldmVudCk7CiAgICB9CiAgfSwKCiAgLyoqCiAgICog6I635Y+W5pKt5pS+6L+b5bqmCiAgICogQHBhcmFtIHBsYXllciAt5Y+v6YCJIOWvueW6lOeahGg1IOaSreaUvuWZqOWvueixoe+8jCDlpoLmnpzkuI3kvKDvvIzliJnojrflj5bliLDnmoTmmK/mlbTkuKrmkq3mlL7ov5vluqbooajvvIzkvKDliJnojrflj5blvZPliY3mkq3mlL7lmajnmoTmkq3mlL7ov5vluqYKICAgKi8KICBnZXRQbGF5UHJvZ3Jlc3M6IGZ1bmN0aW9uIChwbGF5ZXIpIHsKICAgIGNvbnN0IHByb2dyZXNzTWFwID0gY29uZmlnTWFuYWdlci5nZXQoJ21lZGlhLnByb2dyZXNzJykgfHwge307CgogICAgaWYgKCFwbGF5ZXIpIHsKICAgICAgcmV0dXJuIHByb2dyZXNzTWFwCiAgICB9IGVsc2UgewogICAgICBjb25zdCBrZXlOYW1lID0gd2luZG93LmxvY2F0aW9uLmhyZWYgKyBwbGF5ZXIuZHVyYXRpb247CiAgICAgIGlmIChwcm9ncmVzc01hcFtrZXlOYW1lXSkgewogICAgICAgIC8qIOWvueS6juebtOaSreeahOinhumikea1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PCAxMjA7CiAgICAgICAgY29uc3QgaXNMZWF2ZSA9IGRvY3VtZW50LnZpc2liaWxpdHlTdGF0ZSAhPT0gJ3Zpc2libGUnICYmIHBsYXllci5wYXVzZWQ7CgogICAgICAgIGlmICghdC5pc0FsbG93UmVzdG9yZVBsYXlQcm9ncmVzcygpIHx8IGlzVG9TaG9ydCB8fCBpc0xlYXZlKSB7CiAgICAgICAgICByZWNvcmRlcihwbGF5ZXIpOwogICAgICAgICAgcmV0dXJuIHRydWUKICAgICAgICB9CgogICAgICAgIGNvbnN0IHByb2dyZXNzTWFwID0gdC5nZXRQbGF5UHJvZ3Jlc3MoKSB8fCB7fTsKICAgICAgICBjb25zdCBsaXN0ID0gT2JqZWN0LmtleXMocHJvZ3Jlc3NNYXApOwogICAgICAgIGNvbnN0IGtleU5hbWUgPSB3aW5kb3cubG9jYXRpb24uaHJlZiArIHBsYXllci5kdXJhdGlvbjsKCiAgICAgICAgLyoqCiAgICAgICAgICog5a+56aaW5qyh6K6w5b2V5YiwcHJvZ3Jlc3NNYXDnmoTlgLzov5vooYzmoIforrAKICAgICAgICAgKiDnlKjkuo7pmLLmraLmiYvliqjliIfmjaLmkq3mlL7ov5vluqbml7bvvIzmiafooYzliLDplJnor6/nmoTmgaLlpI3pgLvovpEKICAgICAgICAgKi8KICAgICAgICBpZiAoIXByb2dyZXNzTWFwW2tleU5hbWVdKSB7CiAgICAgICAgICB0Ll9maXJzdFByb2dyZXNzUmVjb3JkXyA9IGtleU5hbWU7CiAgICAgICAgICB0Ll9oYXNSZXN0b3JlUGxheVByb2dyZXNzXyA9IGtleU5hbWU7CiAgICAgICAgfQoKICAgICAgICAvKiDlj6rkv53lrZjmnIDov5ExMOS4quinhumikeeahOaSreaUvui/m+W6piAqLwogICAgICAgIGlmIChsaXN0Lmxlbmd0aCA+IDEwKSB7CiAgICAgICAgICAvKiDmoLnmja7mm7TmlrDnmoTml7bpl7TmiLPvvIzlj5blh7rmnIDml6nmt7vliqDmkq3mlL7ov5vluqbnmoTorrDlvZXpobkgKi8KICAgICAgICAgIGxldCB0aW1lTGlzdCA9IFtdOwogICAgICAgICAgbGlzdC5mb3JFYWNoKGZ1bmN0aW9uIChrZXlOYW1lKSB7CiAgICAgICAgICAgIHByb2dyZXNzTWFwW2tleU5hbWVdICYmIHByb2dyZXNzTWFwW2tleU5hbWVdLnQgJiYgdGltZUxpc3QucHVzaChwcm9ncmVzc01hcFtrZXlOYW1lXS50KTsKICAgICAgICAgIH0pOwogICAgICAgICAgdGltZUxpc3QgPSBxdWlja1NvcnQodGltZUxpc3QpOwogICAgICAgICAgY29uc3QgdGltZXN0YW1wID0gdGltZUxpc3RbMF07CgogICAgICAgICAgLyog5Yig6Zmk5pyA5pep5re75Yqg55qE6K6w5b2V6aG5ICovCiAgICAgICAgICBsaXN0LmZvckVhY2goZnVuY3Rpb24gKGtleU5hbWUpIHsKICAgICAgICAgICAgaWYgKHByb2dyZXNzTWFwW2tleU5hbWVdLnQgPT09IHRpbWVzdGFtcCkgewogICAgICAgICAgICAgIGRlbGV0ZSBwcm9ncmVzc01hcFtrZXlOYW1lXTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfQoKICAgICAgICAvKiDorrDlvZXlvZPliY3mkq3mlL7ov5vluqYgKi8KICAgICAgICBwcm9ncmVzc01hcFtrZXlOYW1lXSA9IHsKICAgICAgICAgIHByb2dyZXNzOiBwbGF5ZXIuY3VycmVudFRpbWUsCiAgICAgICAgICBkdXJhdGlvbjogcGxheWVyLmR1cmF0aW9uLAogICAgICAgICAgdDogbmV3IERhdGUoKS5nZXRUaW1lKCkKICAgICAgICB9OwoKICAgICAgICAvKiDlrZjlgqjmkq3mlL7ov5vluqbooaggKi8KICAgICAgICBjb25maWdNYW5hZ2VyLnNldExvY2FsU3RvcmFnZSgnbWVkaWEucHJvZ3Jlc3MnLCBwcm9ncmVzc01hcCk7CgogICAgICAgIC8qIOW+queOr+S+puWQrCAqLwogICAgICAgIHJlY29yZGVy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W50KSB7CiAgICAgICAgICAgIHQuc2V0UGxheWVySW5zdGFuY2UoZXZlbnQudGFyZ2V0KTsKICAgICAgICAgIH0pOwogICAgICAgICAgcGxheWVyLl9oYXNNb3VzZVJlZGlyZWN0RXZlbnRfID0gdHJ1ZTsKICAgICAgICB9CgogICAgICAgIC8qIOaSreaUvuWZqOW8gOWni+aSreaUvueahOaXtuWAmemHjeaWsOaMh+WQkeWunuS+iyAqLwogICAgICAgIGlmICghcGxheWVyLl9oYXNQbGF5aW5nUmVkaXJlY3RFdmVudF8pIHsKICAgICAgICAgIHBsYXllci5hZGRFdmVudExpc3RlbmVyKCdwbGF5aW5nJywgZnVuY3Rpb24gKGV2ZW50KSB7CiAgICAgICAgICAgIGNvbnN0IG1lZGlhID0gZXZlbnQudGFyZ2V0OwoKICAgICAgICAgICAgLyog5a+55LqO6LaF55+t55qE6Z+z6KeG6aKR5Y+v6IO95piv5p+Q5Lqb5pON5L2c5Y+N6aaI55qE54m55pWI77yM5Y+v5b+955Wl5a+55YW26L+b6KGM5pKt5pS+5a6e5L6L5YiH5o2iICovCiAgICAgICAgICAgIGlmIChtZWRpYS5kdXJhdGlvbiAmJiBtZWRpYS5kdXJhdGlvbiA8IDgpIHsKICAgICAgICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgICAgICAgfQoKICAgICAgICAgICAgdC5zZXRQbGF5ZXJJbnN0YW5jZShtZWRpYSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIHBsYXllci5faGFzUGxheWluZ1JlZGlyZWN0RXZlbnRfID0gdHJ1ZTsKICAgICAgICB9CgogICAgICAgIC8qIOW9k+iiq+inguWvn+WIsOWHuueOsOWcqOa1j+iniOWZqOinhuWPo+mHjOaXtu+8jOWIh+aNouinhumikeWunuS+iyAqLwogICAgICAgIGlmICghcGxheWVyLl9oYXNJbnRlcnNlY3Rpb25PYnNlcnZlcl8pIHsKICAgICAgICAgIHQuaW50ZXJzZWN0aW9uT2JzZXJ2ZXIub2JzZXJ2Z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ICAgICBkZWJ1Zy5sb2coJ+W3suWTjeW6lOi3qFRhYi/ot6jln5/mjInplK7mjqfliLbkv6Hmga/vvJonLCBuZXdWYWwpOwogICAgICB9CiAgICB9OwoKICAgIC8qKgogICAgICog5pON5L2c6IqC5rWB5o6n5Yi277yM5YeP5bCR5oyJ6ZSu5raI5oGv6aKR546H77yMCiAgICAgKiDms6jmhI/vvIzlvIDlkK/oioLmtYHmjqfliLblkI7lr7zoh7TlpI3lkIjmjInplK7vvIjlpoLvvJpzaGlmdCtz77yJ5rKh5rOV55Sf5pWICiAgICAgKi8KICAgIGlmICghY3Jvc3NUYWJDdGwuaGFzT3BlblBpY3R1cmVJblBpY3R1cmUoKSAmJiAhdC5oYXNDcm9zc09yaWdpblZpZGVvRGV0ZWN0ZWQpIHsKICAgICAgdHJpZ2dlckZha2VFdmVudCA9IHRocm90dGxlKHRyaWdnZXJGYWtlRXZlbnQsIDgwKTsKICAgIH0KCiAgICAvKiDms6jlhozlk43lupTmnaXoh6rmjInplK7mtojmga/nmoTlub/mkq3nmoTkuovku7YgKi8KICAgIG1vbmtleU1zZy5vbignZ2xvYmFsS2V5ZG93bkV2ZW50JywgYXN5bmMgKG5hbWUsIG9sZFZhbCwgbmV3VmFsLCByZW1vdGUpID0+IHsKICAgICAgaWYgKHJlbW90ZSkgewogICAgICAgIGlmIChpc0luQ3Jvc3NPcmlnaW5GcmFtZSgpKSB7CiAgICAgICAgICAvKioKICAgICAgICAgICAqIOWQjOWkhOi3qOWfn+WPl+mZkOmhtemdou+8jOS4lOmDveWkhOS6juWPr+ingeeKtuaAge+8jOWkp+amgueOh+WkhOS6juWQjOS4gOS4qlRhYuagh+etvumHjO+8jOS9huS4jeaYrzEwMCUKICAgICAgICAgICAqIHRhYklk5LiA6Ie05YiZMTAwJeS4uuWQjOS4gOagh+etvuS4iwogICAgICAgICAgICovCiAgICAgICAgICBpZiAoZG9jdW1lbnQudmlzaWJpbGl0eVN0YXRlID09PSAndmlzaWJsZScgJiYgb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aVtOS4qmluaXTpg710cnnotbfmnaUKICog5L6L5aaC77yad3d3Lmljb3Vyc2UxNjMub3JnIOWwseacieS4gOWumueahOacuueOh+W8guW4uAogKi8KbGV0IGluaXRUcnlDb3VudCA9IDA7CnRyeSB7CiAgaW5pdCgwKTsKfSBjYXRjaCAoZSkgewogIHNldFRpbWVvdXQoKCkgPT4gewogICAgaWYgKGluaXRUcnlDb3VudCA8IDIwMCkgewogICAgICBpbml0VHJ5Q291bnQrKzsKICAgICAgaW5pdCgwKTsKICAgICAgY29uc29sZS5lcnJvcignW2g1cGxheWVyIG1lc3NhZ2U6XScsICdpbml0IGVycm9yJywgaW5pdFRyeUNvdW50LCBlKTsKICAgIH0KICB9LCAxMCk7Cn0K
Add Comment
Please, Sign In to add comment