xiaomianao666

小程序:简易播放器

Aug 19th, 2024
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@简易播放器@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi566A5piT5pKt5pS+5ZmoIiwiYXV0aG9yIjoiQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5I25vUmVmcmVzaCMiLCJ2ZXJzaW9uIjo2LCJjb2xfdHlwZSI6Im1vdmllXzMiLCJjbGFzc19uYW1lIjoiIiwidHlwZSI6ImFsbCIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOlxubGV0IGlzbmV3ID0gZ2V0TXlWYXIoXCJpc25ld1wiLCBcIlwiKTtcbiQucmVxdWlyZShcImhpa2VyOi8vcGFnZS9tdXNpYzE2M1wiKVxuaWYgKGlzbmV3KSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICAgIHRpdGxlOiBcIuaSreaUvumhtemdolwiLFxuICAgICAgICB1cmw6ICQoXCIjbm9Mb2FkaW5nI1wiKS5sYXp5UnVsZSgoKSA9PiB7XG4gICAgICAgICAgICBwdXRNeVZhcihcImlzbmV3XCIsIFwiMVwiKTtcbiAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vcGFnZS9wbGF5I2dhbWVUaGVtZSMjbm9SZWZyZXNoI1wiO1xuICAgICAgICB9KSxcbiAgICAgICAgY29sX3R5cGU6IFwidGV4dF9jZW50ZXJfMVwiLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgbmV3V2luZG93OiB0cnVlLFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBcIumfs+S5kOaSreaUvuWZqFwiLFxuICAgICAgICA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FwiLFxcbiAgICAgICAgICAgICAgICAgICAgbGluZU51bWJlciA9IC0xO1xcbiAgICAgICAgICAgICAgICBpZiAoZSBpbnN0YW5jZW9mIEVycm9yKSB7XFxuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlID0gZS5tZXNzYWdlO1xcbiAgICAgICAgICAgICAgICAgICAgbGluZU51bWJlciA9IGUubGluZU51bWJlcjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBTdHJpbmcoZSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbG9nKG1lc3NhZ2UpO1xcbiAgICAgICAgICAgICAgICBzZXRFcnJvcihcXFwiXFxcXG7ooYzmlbDvvJpcXFwiICsgbGluZU51bWJlciArIFxcXCJcXFxcbuivpuaDhe+8mlxcXCIgKyBtZXNzYWdlKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0pKS5zdGFydCgpO1xcbn1cXG5cXG5mdW5jdGlvbiB0b01hcChvYmplY3QpIHtcXG4gICAgbGV0IG1hcCA9IG5ldyBqYXZhLnV0aWwuSGFzaE1hcCgpO1xcbiAgICBmb3IgKGxldCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMob2JqZWN0KSkge1xcbiAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gXFxcInN0cmluZ1xcXCIpIGNvbnRpbnVlO1xcbiAgICAgICAgbWFwLnB1dChrZXksIHZhbHVlKTtcXG4gICAgfVxcbiAgICByZXR1cm4gbWFwO1xcbn1cXG5cXG5mdW5jdGlvbiBwbGF5KHVybCwgaGVhZGVycywgY2FsbEJhY2spIHtcXG4gICAgdHJ5IHtcXG4gICAgICAgIHJlbGVhc2UoKTtcXG4gICAgICAgIG1lZGlhUGxheWVyID0gbmV3IE1lZGlhUGxheWVyKCk7XFxuICAgICAgICBpZiAoJC50eXBlKGhlYWRlcnMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgIG1lZGlhUGxheWVyLnNldERhdGFTb3VyY2UodXJsLCB0b01hcChoZWFkZXJzKSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIG1lZGlhUGxheWVyLnNldERhdGFTb3VyY2UodXJsKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHNldFBsYXllclNwZWVkKHBsYXlTcGVlZCk7XFxuICAgICAgICBtZWRpYVBsYXllci5zZXRPbkNvbXBsZXRpb25MaXN0ZW5lcigoKSA9PiB7XFxuICAgICAgICAgICAgcmVsZWFzZSgpO1xcbiAgICAgICAgICAgIHJ1bkNvbXBsZXRpb25MaXN0ZW5lcigpO1xcbiAgICAgICAgfSk7XFxuICAgICAgICBtZWRpYVBsYXllci5zZXRPbkVycm9yTGlzdGVuZXIoKGUpID0+IHtcXG4gICAgICAgICAgICAvLyDlvZPlj5HnlJ/plJnor6/ml7bvvIzlsIYgTWVkaWFQbGF5ZXIg6K6+572u5Li6IG51bGxcXG4gICAgICAgICAgICBtZWRpYVBsYXllciA9IG51bGw7XFxuICAgICAgICAgICAgaXNQcmVwYXJlID0gZmFsc2U7XFxuICAgICAgICAgICAgY3VycmVudFVybCA9IG51bGw7XFxuICAgICAgICAgICAgcnVuRXJyb3JMaXN0ZW5lcihlKTtcXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XFxuICAgICAgICB9KTtcXG4gICAgICAgIG1lZGlhUGxheWVyLnByZXBhcmUoKTtcXG4gICAgICAgIGlzUHJlcGFyZSA9IHRydWU7XFxuICAgICAgICBjdXJyZW50VXJsID0gdXJsO1xcbiAgICAgICAgbWVkaWFQbGF5ZXIuc3RhcnQoKTtcXG4gICAgICAgIHJ1blN0YXJ0TGlzdGVuZXIoKTtcXG4gICAgICAgIHRyeUNhbGxCYWNrKGNhbGxCYWNrKTtcXG4gICAgICAgIHJldHVybiBtZWRpYVBsYXllcjtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgcmVsZWFzZSgpO1xcbiAgICAgICAgcnVuRXJyb3JMaXN0ZW5lcihlKTtcXG4gICAgICAgIC8vbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gcGxheUFzeW5jKHVybCwgaGVhZGVycywgY2FsbEJhY2spIHtcXG4gICAgdHJ5IHtcXG4gICAgICAgIHJlbGVhc2UoKTtcXG4gICAgICAgIGxldCBhc3luY01lZGlhUGxheWVyID0gbmV3IE1lZGlhUGxheWVyKCk7XFxuICAgICAgICBpZiAoJC50eXBlKGhlYWRlcnMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgIGFzeW5jTWVkaWFQbGF5ZXIuc2V0RGF0YVNvdXJjZSh1cmwsIHRvTWFwKGhlYWRlcnMpKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgYXN5bmNNZWRpYVBsYXllci5zZXREYXRhU291cmNlKHVybCk7XFxuICAgICAgICB9XFxuICAgICAgICBhc3luY01lZGlhUGxheWVyLnNldE9uQ29tcGxldGlvbkxpc3RlbmVyKCgpID0+IHtcXG4gICAgICAgICAgICByZWxlYXNlKCk7XFxuICAgICAgICAgICAgcnVuQ29tcGxldGlvbkxpc3RlbmVyKCk7XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFzeW5jTWVkaWFQbGF5ZXIuc2V0T25FcnJvckxpc3RlbmVyKChlKSA9PiB7XFxuICAgICAgICAgICAgLy8g5b2T5Y+R55Sf6ZSZ6K+v5pe277yM5bCGIE1lZGlhUGxheWVyIOiuvue9ruS4uiBudWxsXFxuICAgICAgICAgICAgLy9tZWRpYVBsYXllciA9IG51bGw7XFxuICAgICAgICAgICAgYXN5bmNNZWRpYVBsYXllciA9IG51bGw7XFxuICAgICAgICAgICAgaXNQcmVwYXJlID0gZmFsc2U7XFxuICAgICAgICAgICAgY3VycmVudFVybCA9IG51bGw7XFxuICAgICAgICAgICAgcnVuRXJyb3JMaXN0ZW5lcihlKTtcXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFzeW5jTWVkaWFQbGF5ZXIuc2V0T25QcmVwYXJlZExpc3RlbmVyKCgpID0+IHtcXG4gICAgICAgICAgICBpZiAoYXN5bmNNZWRpYVBsYXllciA9PT0gbWVkaWFQbGF5ZXIgJiYgYXN5bmNNZWRpYVBsYXllciAhPSBudWxsKSB7XFxuICAgICAgICAgICAgICAgIGlzUHJlcGFyZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRVcmwgPSB1cmw7XFxuICAgICAgICAgICAgICAgIGFzeW5jTWVkaWFQbGF5ZXIuc3RhcnQoKTtcXG4gICAgICAgICAgICAgICAgcnVuU3RhcnRMaXN0ZW5lcigpO1xcbiAgICAgICAgICAgICAgICB0cnlDYWxsQmFjayhjYWxsQmFjayk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYXN5bmNNZWRpYVBsYXllciA9IG51bGw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBhc3luY01lZGlhUGxheWVyLnByZXBhcmVBc3luYygpO1xcbiAgICAgICAgbWVkaWFQbGF5ZXIgPSBhc3luY01lZGlhUGxheWVyO1xcbiAgICAgICAgc2V0UGxheWVyU3BlZWQocGxheVNwZWVkKTtcXG4gICAgICAgIHJldHVybiBhc3luY01lZGlhUGxheWVyO1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICByZWxlYXNlKCk7XFxuICAgICAgICBydW5FcnJvckxpc3RlbmVyKGUpO1xcbiAgICAgICAgLy9sb2coZS50b1N0cmluZygpKTtcXG4gICAgfVxcbn1cXG4vL+ebtOaOpeaSreaUvue9kee7nOmfs+mikemTvuaOpe+8jOacieWPr+iDveaSreaUvuWksei0pei/mOayoeaciee8k+WtmO+8jOi/mOaYr+S4i+i9veS4gOS4i+avlO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ZXIgLSBwZXIpKS5zbWFsbCgpXFxuICAgICAgICB9KTtcXG4gICAgfSwgbm93RGF0ZSwgcG9zLCB0b3RhbCkpO1xcbiAgICBpZiAoIWF1ZGlvU2luZ2xlLmlkKSByZXR1cm47XFxuICAgIGxldCBzb25nSWQgPSBhdWRpb1NpbmdsZS5pZDtcXG4gICAgbGV0IGxyYyA9IExyY1BhcnNlci5wYXJzZXJOZXRlYXNlTHlyaWNzKHNvbmdJZCk7XFxuICAgIGlmIChscmMubGVuZ3RoID09PSAwKSByZXR1cm47XFxuICAgIHJlZ2lzdGVyVGFzayhcXFwic2ltcGxlUGxheWVyOmxyY1xcXCIsIDEwMCwgJC50b1N0cmluZygobm93RGF0ZSwgcG9zLCB0b3RhbCwgbHJjTGlzdCkgPT4ge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBmb3JtYXRTZWNvbmRzKHRvdGFsU2Vjb25kcykge1xcbiAgICAgICAgICAgICAgICBjb25zdCBtaW51dGVzID0gU3RyaW5nKE1hdGguZmxvb3IodG90YWxTZWNvbmRzIC8gNjApKS5wYWRTdGFydCgyLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICBjb25zdCBzZWNvbmRzID0gU3RyaW5nKE1hdGguZmxvb3IodG90YWxTZWNvbmRzICUgNjApKS5wYWRTdGFydCgyLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gYCR7bWludXRlc306JHtzZWNvbmRzfWA7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCB0cnVlTm93RGF0ZSA9IERhdGUubm93KCkgLSBub3dEYXRlO1xcbiAgICAgICAgICAgIGxldCBjdXJyZW50UG9zaXRpb24gPSBwb3MgKyB0cnVlTm93RGF0ZTtcXG4gICAgICAgICAgICBpZiAoY3VycmVudFBvc2l0aW9uID4gdG90YWwpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFBvc2l0aW9uID0gdG90YWw7XFxuICAgICAgICAgICAgICAgIHVuUmVnaXN0ZXJUYXNrKFxcXCJzaW1wbGVQbGF5ZXI6bHJjXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBpbmRleCA9IDA7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBscmNMaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGlmIChpIDwgbHJjTGlzdC5sZW5ndGggLSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudFBvc2l0aW9uIDwgbHJjTGlzdFtpXS50aW1lc3RhbXAgJiYgaSA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRQb3NpdGlvbiA+IGxyY0xpc3RbaV0udGltZXN0YW1wICYmXFxuICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudFBvc2l0aW9uIDwgbHJjTGlzdFtpICsgMV0udGltZXN0YW1wKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChpID09IGxyY0xpc3QubGVuZ3RoIC0gMSAmJlxcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudFBvc2l0aW9uID4gbHJjTGlzdFtpXS50aW1lc3RhbXApIHtcXG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gaTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3ltYm9sID0gXFxcIuOAgFxcXCI7XFxuICAgICAgICAgICAgbGV0IGxyY1RleHQgPSBmaW5kSXRlbShcXFwic2ltcGxlUGxheWVyOmxyY1xcXCIpIHx8IHt9O1xcbiAgICAgICAgICAgIGxldCBscmNDb250ZW50ID0gbHJjVGV4dC5kZXNjIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGxldCBhID0gU3RyaW5nKGxyY0xpc3RbaW5kZXhdLnRleHQgfHwgc3ltYm9sKTtcXG4gICAgICAgICAgICBsZXQgYiA9IGluZGV4IDwgbHJjTGlzdC5sZW5ndGggLSAxID8gKGxyY0xpc3RbaW5kZXggKyAxXS50ZXh0IHx8IHN5bWJvbCkgOiBzeW1ib2w7XFxuICAgICAgICAgICAgbGV0IGMgPSBpbmRleCAtIDEgPiAwID8gKGxyY0xpc3RbaW5kZXggLSAxXS50ZXh0IHx8IHN5bWJvbCkgOiBzeW1ib2w7XFxuICAgICAgICAgICAgbGV0IGRlc2MgPSBjICsgYSArIGI7XFxuICAgICAgICAgICAgaWYgKGRlc2MgPT09IGxyY0NvbnRlbnQpIHJldHVybjtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJzaW1wbGVQbGF5ZXI6bHJjXFxcIiwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJzxicj48aDQgc3R5bGU9XFxcInRleHQtYWxpZ246IGNlbnRlcjtcXFwiPicgK1xcbiAgICAgICAgICAgICAgICAgICAgYy5zbWFsbCgpLnNtYWxsKCkuZm9udGNvbG9yKFxcXCJncmV5XFxcIikgKyBcXFwiPGJyPlxcXCIgK1xcbiAgICAgICAgICAgICAgICAgICAgYS5mb250Y29sb3IoXFxcIiMxM0I2NkFcXFwiKSArIFxcXCI8YnI+XFxcIiArXFxuICAgICAgICAgICAgICAgICAgICBiLnNtYWxsKCkuc21hbGwoKS5mb250Y29sb3IoXFxcImdyZXlcXFwiKSArIFxcXCI8YnI+XFxcIiArXFxuICAgICAgICAgICAgICAgICAgICAnPC9oND4nLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgLy9sb2coZS50b1N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dHNuYW1lLCBpbmZvLm5pY2tuYW1lLCBpbmZvLmF2YXRhcnVybCwgaW5mby5jb250ZW50LCB1cmwpO1xcbiAgICAgICAgICAgICAgICBzZXRIZWFkKGluZm8ucGljdXJsLCBpbmZvLm5hbWUsIGluZm8uYXJ0aXN0c25hbWUsIHVybCk7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmraPlnKjmkq3mlL7vvJpcXFwiICsgaW5mby5uYW1lKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjaWQgIT09IGlkKSByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29tbSA9IG11c2ljMTYzLmdldFJhbmRvbUNvbW1lbnQoY2lkKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjaWQgPT09IGlkKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29tbWVudChjb21tLm5pY2tuYW1lLCBjb21tLmF2YXRhcnVybCwgY29tbS5jb250ZW50LCBjaWQpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRDb21tZW50KCk7XFxuICAgICAgICAgICAgICAgICAgICAvL2xvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBmdW5jdGlvbiBnZXRTb25nKCkge1xcbiAgICAgICAgICAgIGlmIChtb2RlID09PSBcXFwi6Ieq5a6a5LmJ5q2M5Y2VSURcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtdXNpYzE2My5nZXRSYW5kb21MaXN0U29uZyhtaWQpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtdXNpYzE2My5nZXRSYW5kb21Tb25nKG1vZGUpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIHBsYXlWaXAoKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaWYgKGlkKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoZmV0Y2goXFxcImh0dHBzOi8vYXBpLnhpbmd6aGlnZS5jb20vQVBJL05ldEVhc2VfQ2xvdWRNdXNpY19uZXcvP3NvbmdpZD1cXFwiICsgaWQgKyBcXFwiJmJyPTJcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICBwbGF5QXVkaW8oanNvbi5kYXRhLnNyYywgc29uZ0luZm8pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gcGxheSgpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBzb25nSW5mbyA9IGdldFNvbmcoKTtcXG4gICAgICAgICAgICAgICAgaWQgPSBzb25nSW5mby5pZDtcXG4gICAgICAgICAgICAgICAgYXVkaW9TaW5nbGUuaWQgPSBzb25nSW5mby5pZDtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibWlkXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibW9kZVxcXCIpO1xcbiAgICAgICAgICAgICAgICB0b2FzdChlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBsYXlBdWRpbyhzb25nS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lvbiBwYXJzZXIobHJjKSB7XFxuICAgIGxyYyA9IGxyYy5zcGxpdChcXFwiXFxcXG5cXFwiKTtcXG4gICAgbGV0IGx5cmljcyA9IFtdO1xcbiAgICBmb3IgKGxldCBsaW5lIG9mIGxyYykge1xcbiAgICAgICAgaWYgKGxpbmUuc3RhcnRzV2l0aChcXFwiW1xcXCIpICYmIGxpbmUuaW5jbHVkZXMoXFxcIl1cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCB0aW1lc3RhbXBzID0gW107XFxuICAgICAgICAgICAgd2hpbGUgKHRydWUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHN0YXJ0SW5kZXggPSBsaW5lLmluZGV4T2YoXFxcIltcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGVuZEluZGV4ID0gbGluZS5pbmRleE9mKFxcXCJdXFxcIik7XFxuICAgICAgICAgICAgICAgIGlmIChzdGFydEluZGV4IDwgMCB8fCBlbmRJbmRleCA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCB0aW1lU3RyID0gbGluZS5zdWJzdHJpbmcoc3RhcnRJbmRleCArIDEsIGVuZEluZGV4KTtcXG4gICAgICAgICAgICAgICAgdGltZVN0ciA9IHRpbWVTdHIucmVwbGFjZShcXFwiLlxcXCIsIFxcXCI6XFxcIikucmVwbGFjZShcXFwiLVxcXCIsIFxcXCI6XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB0aW1lQXJyID0gdGltZVN0ci5zcGxpdChcXFwiOlxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgbWludXRlID0gTnVtYmVyKHRpbWVBcnJbMF0pO1xcbiAgICAgICAgICAgICAgICBsZXQgc2Vjb25kID0gTnVtYmVyKHRpbWVBcnJbMV0pO1xcbiAgICAgICAgICAgICAgICBsZXQgbWlsbGlzZWNvbmQgPSBOdW1iZXIodGltZUFyclsyXSkgfHwgMDtcXG4gICAgICAgICAgICAgICAgLyppZiAobWlsbGlzZWNvbmQgPCAxMDApIHtcXG4gICAgICAgICAgICAgICAgICAgIG1pbGxpc2Vjb25kID0gbWlsbGlzZWNvbmQgKiAxMDtcXG4gICAgICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgICAgIGxldCB0aW1lc3RhbXAgPSAobWludXRlICogNjAgKyBzZWNvbmQpICogMTAwMCArIG1pbGxpc2Vjb25kO1xcblxcbiAgICAgICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcoZW5kSW5kZXggKyAxKTtcXG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTih0aW1lc3RhbXApKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgdGltZXN0YW1wcy5wdXNoKHRpbWVzdGFtcCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRpbWVzdGFtcHMuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgICAgbHlyaWNzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGltZXN0YW1wOiB2LFxcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogbGluZVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcblxcbiAgICByZXR1cm4gbHlyaWNzLnNvcnQoKGEsIGIpID0+IGEudGltZXN0YW1wIC0gYi50aW1lc3RhbXApO1xcbn1cXG5cXG5mdW5jdGlvbiBkb3duTmV0ZWFzZUx5cmljcyhpZCwgcGF0aCkge1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IGx5cmljcyA9IEpTT04ucGFyc2UoZmV0Y2goXFxcImh0dHA6Ly9tdXNpYy4xNjMuY29tL2FwaS9zb25nL2x5cmljP2lkPVxcXCIgKyBpZCArIFxcXCImbHY9LTEma3Y9LTEmdHY9LTFcXFwiLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgIC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H0sXFxuICAgIGRlZmluZShrZXksIHZhbCkge1xcbiAgICAgICAgaWYgKHRoaXMuaGFzQnV0Tm9DYWxsKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiB0aGlzLnB1dChrZXksIHZhbCk7XFxuICAgIH0sXFxuICAgIGRlZmluZUxhenkoa2V5LCBsYXp5KSB7XFxuICAgICAgICBpZiAodGhpcy5oYXNCdXROb0NhbGwoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHRoaXMucHV0KGtleSwgbGF6eSgpKTtcXG4gICAgfSxcXG4gICAgZGVmaW5lTW9kdWxlKGtleSwgcGF0aCwgaXNOZXcpIHtcXG4gICAgICAgIGlmIChpc05ldykgcmV0dXJuIHRoaXMucHV0KGtleSwgJC5yZXF1aXJlKHBhdGgsIGtleSkpO1xcbiAgICAgICAgcmV0dXJuIHRoaXMuZGVmaW5lTGF6eShrZXksICgpID0+ICQucmVxdWlyZShwYXRoLCBrZXkpKTtcXG4gICAgfSxcXG4gICAgbGlzdEtleXMoKSB7XFxuICAgICAgICBsZXQgZW50cnlTZXQgPSB0aGlzLmdldEhhc2hNYXAobWFwU3ltYm9sKS5lbnRyeVNldCgpO1xcbiAgICAgICAgbGV0IHNlbGZLZXkgPSB0aGlzW3NlbGZTeW1ib2xdO1xcbiAgICAgICAgbGV0IGtleXMgPSBbXTtcXG5cXG4gICAgICAgIGZvciAobGV0IGVudHJ5IG9mIGVudHJ5U2V0KSB7XFxuICAgICAgICAgICAgbGV0IGtleSA9IGVudHJ5LmdldEtleSgpO1xcbiAgICAgICAgICAgIGlmIChpc1N0cmluZyhrZXkpICYmIGtleS5zdGFydHNXaXRoKHNlbGZLZXkpKSB7XFxuICAgICAgICAgICAgICAgIGtleXMucHVzaChTdHJpbmcoa2V5KS5yZ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