Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_解除网站不允许复制的限制@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgIOino+mZpOe9keermeS4jeWFgeiuuOWkjeWItueahOmZkOWItgovLyBAZGVzY3JpcHRpb24g44CQ8J+YieKZgu+4j+aWh+acrOmAieS4reWQjueCueWHu+WkjeWItuaMiemSruWNs+WPr+WkjeWItu+8jOS4u+imgeeUqOS6jiDnmb7luqbmloflupMg6YGT5a6i5be05be0IOiFvuiur+aWh+ahoyDosYbkuIHnvZEg5peg5b+n6ICD572RIOWtpuS5oOWVpiDok6zli4PojIPmlocg5oCd5ZCm56S+5Yy6IOWKm+aJoyDnn6XkuY4g6K+t6ZuA8J+SmuOAkQovLyBAbmFtZXNwYWNlICAgV2luZHJ1bm5lck1heAovLyBAdmVyc2lvbiAgICAgMy4yLjMKLy8gQGF1dGhvciAgICAgIFdpbmRydW5uZXJNYXgKLy8gQG1hdGNoICAgICAgICo6Ly93ZW5rdS5iYWlkdS5jb20vdmlldy8qCi8vIEBtYXRjaCAgICAgICAqOi8vd2Vua3UuYmFpZHUuY29tL3NoYXJlLyoKLy8gQG1hdGNoICAgICAgICo6Ly93ZW5rdS5iYWlkdS5jb20vbGluayoKLy8gQG1hdGNoICAgICAgICo6Ly93ZW5rdS5iYWlkdS5jb20vYWdncy8qCi8vIEBtYXRjaCAgICAgICAqOi8vd2Vua3UuYmFpZHUuY29tL25kUHVyZVZpZXcvKgovLyBAbWF0Y2ggICAgICAgKjovL3d3dy41MXRlc3QubmV0L3Nob3cvKgovLyBAbWF0Y2ggICAgICAgKjovL3d3dy54dWV4aS5sYS8qCi8vIEBtYXRjaCAgICAgICAqOi8vd3d3Lnh1ZXhpbGEuY29tLyoKLy8gQG1hdGNoICAgICAgICo6Ly93d3cuY3NwZW5nYm8uY29tLyoKLy8gQG1hdGNoICAgICAgICo6Ly8qLmRvY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gIGlmIChpc1N0cmluZyhjb250ZW50KSkgewogICAgICAgICAgY29udGFpbmVyLmlubmVySFRNTCA9IGNvbnRlbnQ7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnRhaW5lci5hcHBlbmRDaGlsZChjb250ZW50KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdGFyZ2V0RE9NID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3Rvcik7CiAgICAgICAgdGFyZ2V0RE9NICYmIHRhcmdldERPTS5hcHBlbmQoY29udGFpbmVyKTsKICAgICAgICByZXR1cm4gY29udGFpbmVyOwogICAgICB9LAogICAgICByZW1vdmU6IGZ1bmN0aW9uKHNlbGVjdG9yKSB7CiAgICAgICAgY29uc3QgdGFyZ2V0RE9NID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3Rvcik7CiAgICAgICAgdGFyZ2V0RE9NICYmIHRhcmdldERPTS5yZW1vdmUoKTsKICAgICAgfQogICAgfTsKIAogICAgY29uc3QgaW5pdEJhc2VFdmVudCA9ICh3ZWJzaXRlQ29uZmlnKSA9PiB7CiAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKERPTV9SRUFEWSwgKCkgPT4gewogICAgICAgIGlmICh3ZWJzaXRlQ29uZmlnLmluaXRDb3B5RXZlbnQpIHsKICAgICAgICAgIGRvY3VtZW50Lm9uY29weSA9IChlKSA9PiBlLnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgZG9jdW1lbnQuYm9keS5vbmNvcHkgPSAoZSkgPT4gZS5zdG9wUHJvcGFnYXRpb24oKTsKICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoQ09QWSwgKGUpID0+IGUuc3RvcFByb3BhZ2F0aW9uKCkpOwogICAgICAgICAgZG9jdW1lbnQuYm9keS5hZGRFdmVudExpc3RlbmVyKENPUFksIChlKSA9PiBlLnN0b3BQcm9wYWdhdGlvbigpKTsKICAgICAgICB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ICAgIGNvbnN0IHJlc3VsdCA9IC9cKCIjY3BfdGV4dGFyZWEiXCkudmFsXCgoW1xTXSo/KVwpOy8uZXhlYyhyZXNwb25zZS5yZXNwb25zZVRleHQpOwogICAgICAgICAgICBpZiAocmVzdWx0KQogICAgICAgICAgICAgIHBhdGggPSByZXN1bHRbMV07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoImxvYWQiLCAoKSA9PiB7CiAgICAgICAgICBjb25zdCBjcEZuID0gdW5zYWZlV2luZG93LmNvcHlUZXh0LnRvU3RyaW5nKCk7CiAgICAgICAgICBjb25zdCBmblJlc3VsdCA9IC88dGV4dGFyZWFbXHNcU10qPz4nXCsoW1xTXSo/KVwrIjxcL3RleHRhcmVhPi8uZXhlYyhjcEZuKTsKICAgICAgICAgIGlmIChmblJlc3VsdCkKICAgICAgICAgICAgcGF0aCA9IGZuUmVzdWx0WzFdOwogICAgICAgIH0pOwogICAgICB9LAogICAgICBnZXRTZWxlY3RlZFRleHQ6ICgpID0+IHsKICAgICAgICBsZXQgc2VsZWN0ID0gdW5zYWZlV2luZG93OwogICAgICAgIHBhdGguc3BsaXQoIi4iKS5mb3JFYWNoKCh2KSA9PiB7CiAgICAgICAgICBzZWxlY3QgPSBzZWxlY3Rbdl07CiAgICAgICAgfSk7CiAgICAgICAgaWYgKCFzZWxlY3QpIHsKICAgICAgICAgIHVuc2FmZVdpbmRvdy5Db25maWcudmlwID0gMTsKICAgICAgICAgIHVuc2FmZVdpbmRvdy5Db25maWcubG9naW5lZCA9IDE7CiAgICAgICAgICBkb20kMS5yZW1vdmUoIiNjb3B5LWVsZW1lbnQtaGlkZSIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc2VsZWN0OwogICAgICB9CiAgICB9OwogCiAgICBjb25zdCB3ZWJzaXRlJHMgPSB7CiAgICAgIHJlZ2V4cDogLy4qc2VnbWVudGZhdWx0XC5jb21cLy4rLywKICAgICAg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RhSXRlbXMpXSkuY2F0Y2goKCkgPT4gewogICAgICAgICAgZG93bmdyYWRlQ29weShwYXJhbXMpOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGRvd25ncmFkZUNvcHkocGFyYW1zKTsKICAgICAgfQogICAgICByZXR1cm4gdHJ1ZTsKICAgIH07CiAKICAgIGxldCBkb20gPSBudWxsOwogICAgbGV0IGlzUmVhZHlUb0hpZGRlbiA9IGZhbHNlOwogICAgY29uc3QgaW5zdGFuY2UgPSB7CiAgICAgIGlkOiAiX19jb3B5IiwKICAgICAgY2xhc3NOYW1lOiAiX19jb3B5LWJ1dHRvbiIsCiAgICAgIGluaXQ6IGZ1bmN0aW9uKG5hbWUpIHsKICAgICAgICBjb25zdCBjb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICBjb250YWluZXIuaWQgPSB0aGlzLmlkOwogICAgICAgIGNvbnRhaW5lci5jbGFzc05hbWUgPSB0aGlzLmNsYXNzTmFtZTsKICAgICAgICBjb250YWluZXIuaW5uZXJUZXh0ID0gbmFtZSB8fCAi5aSN5Yi2IjsKICAgICAgICBjb250YWluZXIuYWRkRXZlbnRMaXN0ZW5lcigibW91c2V1cCIsIChlKSA9PiBlLnN0b3BQcm9wYWdhdGlvbigpLCB0cnVlKTsKICAgICAgICBjb250YWluZXIuYWRkRXZlbnRMaXN0ZW5lcigibW91c2Vkb3duIiwgKGUpID0+IGUuc3RvcFByb3BhZ2F0aW9uKCksIHRydWUpOwogICAgICAgIGRvbSA9IGNvbnRhaW5lcjsKICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGRvbSk7CiAgICAgIH0sCiAgICAgIGdldEluc3RhbmNlOiBmdW5jdGlvbigpIHsKICAgICAgICBpZiAoZG9tID09PSBudWxsKSB7CiAgICAgICAgICB0aGlzLmluaXQoKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGRvbTsKICAgICAgfSwKICAgICAgc2hvdzogZnVuY3Rpb24oZXZlbnQpIHsKICAgICAgICBpZiAoaXNSZWFkeVRvSGlkZGVuKQogICAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgICBjb25zdCBkb20yID0gdGhpcy5nZXRJbnN0YW5jZSgpOwogICAgICAgIGRvbTIuc3R5bGUubGVmdCA9IGAke2V2ZW50LnBhZ2VYICsgMzB9cHhgOwogICAgICAgIGRvbTIuc3R5bGUudG9wID0gYCR7ZXZlbnQucGFnZVl9cHhgOwogICAgICAgIGRvbTIuc3R5bGUub3BhY2l0eSA9ICIxIjsKICAgICAgICBkb20yLnN0eWxlLnpJbmRleCA9ICIxMDAwIjsKICAgICAgfSwKICAgICAgaGlkZTogZnVuY3Rpb24oa2VlcCA9IDM1MCkgewogICAgICAgIGNvbnN0IGRvbTIgPSB0aGlzLmdldEluc3RhbmNlKCk7CiAgICAgICAgZG9tMi5zdHlsZS5vcGFjaXR5ID0gIjAiOwogICAgICAgIGlmIChrZWVwKSB7CiAgICAgICAgICBpc1JlYWR5VG9IaWRkZW4gPSB0cnVlOwogICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgIGRvbTIuc3R5bGUuekluZGV4ID0gIi0xMDAwMCI7CiAgICAgICAgICAgIGlzUmVhZHlUb0hpZGRlbiA9IGZhbHNlOwogICAgICAgICAgfSwga2VlcCk7CiAgICAgICAgfQogICAgICB9LAogICAgICBvbkNvcHk6IGZ1bmN0aW9uKGNvbnRlbnQsIGV2ZW50KSB7CiAgICAgICAgY29uc3QgZG9tMiA9IHRoaXMuZ2V0SW5zdGFuY2UoKTsKICAgICAgICB0aGlzLnNob3coZXZlbnQpOwogICAgICAgIGRvbTIub25jbGljayA9ICgpID0+IHsKICAgICAgICAgIGNvcHkoY29udGVudCk7CiAgICAgICAgICB0aGlzLmhpZGUoKTsKICAgICAgICB9OwogICAgICB9LAogICAgICBlbmFibGU6IGZ1bmN0aW9uKCkgewogICAgICAgIGNvbnN0IGRvbTIgPSB0aGlzLmdldEluc3RhbmNlKCk7CiAgICAgICAgZG9tMi5zdHlsZS5kaXNwbGF5ID0gImZsZXgiOwogICAgICB9LAogICAgICBkaXNhYmxlOiBmdW5jdGlvbigpIHsKICAgICAgICBjb25zdCBkb20yID0gdGhpcy5nZXRJbnN0YW5jZSgpOwogICAgICAgIGRvbTIuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgfSwKICAgICAgZGVzdHJveTogZnVuY3Rpb24oKSB7CiAgICAgICAgY29uc3QgZWwgPSB0aGlzLmdldEluc3RhbmNlKCk7CiAgICAgICAgZWwucmVtb3ZlKCk7CiAgICAgICAgZG9tID0gbnVsbDsKICAgICAgfQogICAgfTsKIAogICAgY29uc3Qgc3RvcE5hdGl2ZVByb3BhZ2F0aW9uID0gKGV2ZW50KSA9PiB7CiAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgfTsKICAgIHZhciB1dGlscyA9IHsKICAgICAgcGFuRGF0YTpbXSwKICAgICAgcGFuVGVtcDpbXSwKICAgICAgcGFuTGlzdDpbXSwKICAgICAgcGFuS2V5OjAsCiAgICAgIGhpZGVCdXR0b246ICgpID0+IHsKICAgICAgICBpbnN0YW5jZS5kaXNhYmxlKCk7CiAgICAgIH0sCiAgICAgIHNob3dCdXR0b246ICgpID0+IHsKICAgICAgICBpbnN0YW5jZS5lbmFibGUoKTsKICAgICAgfSwKICAgICAgcmVtb3ZlQXR0cmlidXRlczogKHNlbGVjdG9yLCBhdHRyID0gW10pID0+IHsKICAgICAgICBjb25zdCBkb20gPSBpc1N0cmluZyhzZWxlY3RvcikgPyBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKHNlbGVjdG9yKSA6IHNlbGVjdG9yOwogICAgICAgIGRvbSAmJiBhdHRyLmZvckVhY2goKGl0ZW0pID0+IGRvbS5yZW1vdmVBdHRyaWJ1dGUoaXRlbSkpOwogICAgICB9LAogICAgICBlbmFibGVVc2VyU2VsZWN0Q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QkJCXV0aWxzLnBhbktleSsrOwoJCQkJCX0KCQkJCX0pCgkJCX0pCgkJCWxldCByZXF1ZXN0VGVtcD11dGlscy5wYW5UZW1wLnNwbGljZSgwLHV0aWxzLnBhbkRhdGEuc3BsTmFtZSk7CgkJCWxldCByZXF1ZXN0TGlzdD1bXTsKCQkJcmVxdWVzdFRlbXAuZm9yRWFjaChmdW5jdGlvbihzLGspewoJCQkJIGxldCB0ZW1wPXt9OwoJCQkJIHRlbXBbJ2hyZWYnXT0kKHMpLmZpbmQoJ2E6Zmlyc3QnKS5hdHRyKCdocmVmJyk7CgkJCQkgdGVtcFsnbWQ1J109JChzKS5hdHRyKCdkYXRhLW1kNS1rZXknKTsKCQkJCSByZXF1ZXN0TGlzdC5wdXNoKHRlbXApOwoJCQl9KQoJCQlpZihyZXF1ZXN0TGlzdC5sZW5ndGg+MCl7CiAgICAgICAgICAgICAgICBHTV94bWxodHRwUmVxdWVzdCh7CiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiUE9TVCIsCiAgICAgICAgICAgICAgICAgICAgZGF0YTpKU09OLnN0cmluZ2lmeSh7ZGF0YTpyZXF1ZXN0TGlzdH0pLAogICAgICAgICAgICAgICAgICAgIHVybDogYGh0dHA6Ly80OS4yMzUuMTU1LjUvc2VhcmNoLnBocGAsCiAgICAgICAgICAgICAgICAgICAgb25sb2FkOiBmdW5jdGlvbihyZXNwb25zZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzID0gcmVzcG9uc2UucmVzcG9uc2VUZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzKXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcz1KU09OLnBhcnNlKHJlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXMubWFwKGZ1bmN0aW9uKGl0ZW0pewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoaXRlbS51KXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKHV0aWxzLnBhbkxpc3RbaXRlbS5tZDVdKS5maW5kKCdhJykuYmluZCgiY2xpY2siLCBmdW5jdGlvbihlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTt1dGlscy5qdW1wKGl0ZW0udSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCQkJCQl9KQoKICAgICAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KQoKCQkJfQoKICAgICAgfSwKICAgICAgZW5hYmxlT25TZWxlY3RTdGFydDogKHNlbGVjdG9yKSA9PiB7CiAgICAgICAgY29uc3QgZG9tID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3Rvcik7CiAgICAgICAgZG9tICYmIGRvbS5hZGRFdmVudExpc3RlbmVyKFNFTEVDVF9TVEFSVCwgc3RvcE5hdGl2ZVByb3BhZ2F0aW9uKTsKICAgICAgfSwKICAgICAgZW5hYmxlT25Db250ZXh0TWVudTogKHNlbGVjdG9yKSA9PiB7CiAgICAgICAgY29uc3QgZG9tID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihzZWxlY3Rvcik7CiAgICAgICAgZG9tICYmIGRvbS5hZGRFdmVudExpc3RlbmVyKENPTlRFWFRfTUVOVSwgc3RvcE5hdGl2ZVByb3BhZ2F0aW9uKTsKICAgICAgfSwKICAgICAgZW5hYmxlT25Db3B5OiAoc2VsZWN0b3IpID0+IHsKICAgICAgICBjb25zdCBkb20gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKHNlbGVjdG9yKTsKICAgICAgICBkb20gJiYgZG9tLmFkZEV2ZW50TGlzdGVuZXIoQ09QWSwgc3RvcE5hdGl2ZVByb3BhZ2F0aW9uKTsKICAgICAgfSwKICAgICAgZW5hYmxlT25LZXlEb3duOiAoc2VsZWN0b3IpID0+I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gICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIHV0aWxzLmhpZGVCdXR0b24oKTsKICAgICAgICB1dGlscy5lbmFibGVPblNlbGVjdFN0YXJ0QnlDYXB0dXJlKCk7CiAgICAgICAgd2luZG93Lm9ubG9hZCA9ICgpID0+IHsKICAgICAgICAgIGRvbSQxLmF0dHIoIi5zZi1lZHUtd2Vua3UtdnctY29udGFpbmVyIiwgInN0eWxlIiwgIiIpOwogICAgICAgIH07CiAgICAgIH0KICAgIH07CiAKICAgIGNvbnN0IHdlYnNpdGUkcSA9IHsKICAgICAgcmVnZXhwOiAvLip6aGlodVwuY29tXC8uKi8sCiAgICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIHV0aWxzLmhpZGVCdXR0b24oKTsKICAgICAgICB1dGlscy5lbmFibGVVc2VyU2VsZWN0QnlDU1MoKTsKICAgICAgICB1dGlscy5lbmFibGVPbkNvcHlCeUNhcHR1cmUoKTsKICAgICAgICBpZiAobG9jYXRpb24uaG9zdG5hbWUgPT09ICJ6aHVhbmxhbi56aGlodS5jb20iKSB7CiAgICAgICAgICBjb25zdCByZW1vdmVGb2NhbFBvaW50TW9kYWwgPSAobXV0YXRpb25zTGlzdCkgPT4gewogICAgICAgICAgICBmb3IgKGNvbnN0IG11dGF0aW9uIG9mIG11dGF0aW9uc0xpc3QpIHsKICAgICAgICAgICAgICBjb25zdCBhZGRlZE5vZGVzID0gbXV0YXRpb24uYWRkZWROb2RlczsKICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFkZGVkTm9kZXMubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgIGNvbnN0IHRhcmdldCA9IGFkZGVkTm9kZXNbaV07CiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0Lm5vZGVUeXBlICE9IDEpCiAgICAgICAgICAgICAgICAgIHJldHVybiB2b2lkIDA7CiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0IGluc3RhbmNlb2Y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ZW1lbnRzQnlUYWdOYW1lKCJpZnJhbWUiKTsKICAgICAgICAgIGlmIChpZnJhbWVzLmxlbmd0aCA9PT0gMikgewogICAgICAgICAgICBjb25zdCBib2R5ID0gKF9hID0gaWZyYW1lc1sxXS5jb250ZW50V2luZG93KSA9PSBudWxsID8gdm9pZCAwIDogX2EuZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiYm9keSIpOwogICAgICAgICAgICBib2R5ICYmIHV0aWxzLnJlbW92ZUF0dHJpYnV0ZXMoYm9keSwgWyJvbmNvcHkiLCAib25jb250ZXh0bWVudSIsICJvbnNlbGVjdHN0YXJ0Il0pOwogICAgICAgICAgfQogICAgICAgIH07CiAgICAgIH0KICAgIH07CiAKICAgIGNvbnN0IHdlYnNpdGUkbyA9IHsKICAgICAgcmVnZXhwOiAvLipkb2NzXC5xcVwuY29tXC8uKy8sCiAgICAgIGNvbmZpZzogewogICAgICAgIGluaXRDb3B5RXZlbnQ6IGZhbHNlLAogICAgICAgIGNhcHR1cmVJbnN0YW5jZTogdHJ1ZSwKICAgICAgICBkZWxheTogMTAwCiAgICAgIH0sCiAgICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIHdpbmRvdy5vbmxvYWQgPSAoKSA9PiB7CiAgICAgICAgICB1dGlscy5oaWRlQnV0dG9uKCk7CiAgICAgICAgfTsKICAgICAgfSwKICAgICAgZ2V0U2VsZWN0ZWRUZXh0OiBmdW5jdGlvbigpIHsKICAgICAgICB2YXIgX2E7CiAgICAgICAgaWYgKHVuc2FmZVdpbmRvdy5wYWQgJiYgdW5zYWZlV2luZG93LnBhZC5lZGl0b3IgJiYgIXVuc2FmZVdpbmRvdy5wYWQuZWRpdG9yLmlzQ29weWFibGUoKSkgewogICAgICAgICAgdXRpbHMuc2hvd0J1dHRvbigpOwogICAgICAgICAgY29uc3QgZWRpdG9yID0gdW5zYWZlV2luZG93LnBhZC5lZGl0b3I7CiAgICAgICAgICBpZiAoZWRpdG9yLmdldENvcHlDb250ZW50KSB7CiAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBlZGl0b3IuZ2V0Q29weUNvbnRlbnQoKSB8fCB7fTsKICAgICAgICAgICAgY29uc3QgcGxhaW5UZXh0ID0gY29udGVudC5wbGFpbiB8fCAiIjsKICAgICAgICAgICAgY29uc3QgaHRtbFRleHQgPSBjb250ZW50Lmh0bWwgfHwgIiI7CiAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgW1RFWFRfUExBSU5dOiBwbGFpblRleHQsCiAgICAgICAgICAgICAgW1RFWFRfSFRNTF06IGh0bWxUZXh0CiAgICAgICAgICAgIH07CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlZGl0b3IuX2RvY0Vudi5jb3B5YWJsZSA9IHRydWU7CiAgICAgICAgICAgIGVkaXRvci5jbGlwYm9hcmRNYW5hZ2VyLmNvcHkoKTsKICAgICAgICAgICAgY29uc3QgcGxhaW5UZXh0ID0gZWRpdG9yLmNsaXBib2FyZE1hbmFnZXIuY3VzdG9tQ2xpcGJvYXJkLnBsYWluIHx8ICIiOwogICAgICAgICAgICBjb25zdCBodG1sVGV4dCA9IGVkaXRvci5jbGlwYm9hcmRNYW5hZ2VyLmN1c3RvbUNsaXBib2FyZC5odG1sIHx8ICIiOwogICAgICAgICAgICBlZGl0b3IuX2RvY0Vudi5jb3B5YWJsZSA9IGZhbHNlOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIFtURVhUX1BMQUlOXTogcGxhaW5UZXh0LAogICAgICAgICAgICAgIFtURVhUX0hUTUxdOiBodG1sVGV4dAogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAodW5zYWZlV2luZG93LlNwcmVhZHNoZWV0QXBwICYmIHVuc2FmZVdpbmRvdy5TcHJlYWRzaGVldEFwcC5wZXJtaXNzaW9ucyAmJiB1bnNhZmVXaW5kb3cuU3ByZWFkc2hlZXRBcHAucGVybWlzc2lvbnMuc2h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c2goIiAiLCAoKF9hID0gY2VsbC5mb3JtYXR0ZWRWYWx1ZSkgPT0gbnVsbCA/IHZvaWQgMCA6IF9hLnZhbHVlKSB8fCBjZWxsLnZhbHVlIHx8ICIiKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaSAhPT0gZW5kUm93SW5kZXggJiYgdGV4dC5wdXNoKCJcbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRleHQuam9pbigiIik7CiAgICAgICAgICAgIHJldHVybiAvXlxzKiQvLnRlc3Qoc3RyKSA/ICIiIDogc3RyOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0KICAgICAgICByZXR1cm4gIiI7CiAgICAgIH0KICAgIH07CiAKICAgIGNvbnN0IHdlYnNpdGUkbiA9IHsKICAgICAgcmVnZXhwOiBuZXcgUmVnRXhwKCIuKzovL2Jva2UxMTIuY29tL3Bvc3QvLisiKSwKICAgICAgaW5pdDogZnVuY3Rpb24oKSB7CiAgICAgICAgdXRpbHMuZW5hYmxlT25Db3B5QnlDYXB0dXJlKCk7CiAgICAgICAgY29uc3QgdGVtcGxhdGUgPSBgCiAgICAgICAgICAgIDxzdHlsZT4KICAgICAgICAgICAgICAgIDpub3QoaW5wdXQpOm5vdCh0ZXh0YXJlYSk6OnNlbGVjdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzI0NDBCMyAhaW1wb3J0YW50OwogICAgICAgICAgICAgICAgICAgIGNvbG9yOiAjZmZmICFpbXBvcnRhbnQ7CiAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgIDpub3QoaW5wdXQpOm5vdCh0ZXh0YXJlYSk6Oi1tb3otc2VsZWN0aW9uIHsKICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAjMjQ0MEIzICFpbXBvcnRhbnQ7CiAgICAgICAgICAgICAgICAgICAgY29sb3I6ICN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udSgiLm1haW4tcmVhZC1jb250YWluZXIiKTsKICAgICAgfQogICAgfTsKIAogICAgY29uc3Qgd2Vic2l0ZSRmID0gewogICAgICByZWdleHA6IG5ldyBSZWdFeHAoInpvbmdoZW5nIiksCiAgICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIHV0aWxzLnJlbW92ZUF0dHJpYnV0ZXMoIi5yZWFkZXJfYm94IiwgWyJzdHlsZSIsICJ1bnNlbGVjdGFibGUiLCAib25zZWxlY3RzdGFydCJdKTsKICAgICAgICB1dGlscy5yZW1vdmVBdHRyaWJ1dGVzKCIucmVhZGVyX21haW4iLCBbInN0eWxlIiwgInVuc2VsZWN0YWJsZSIsICJvbnNlbGVjdHN0YXJ0Il0pOwogICAgICAgIHV0aWxzLmhpZGVCdXR0b24oKTsKICAgICAgICB1dGlscy5lbmFibGVPbktleURvd24oImJvZHkiKTsKICAgICAgICB1dGlscy5lbmFibGVVc2VyU2VsZWN0QnlDU1MoKTsKICAgICAgICB1dGlscy5lbmFibGVPbkNvcHkoIi5jb250ZW50Iik7CiAgICAgICAgdXRpbHMuZW5hYmxlT25Db250ZXh0TWVudSgiYm9keSIpOwogICAgICAgIHV0aWxzLmVuYWJsZU9uU2VsZWN0U3RhcnQoIi5jb250ZW50Iik7CiAgICAgIH0KICAgIH07CiAKICAgIGNvbnN0IHdlYnNpdGUkZSA9IHsKICAgICAgcmVnZXhwOiBuZXcgUmVnRXhwKCIxN2siKSwKICAgICAgaW5pdDogKCkgPT4gewogICAgICAgIHV0aWxzLmhpZGVCdXR0b24oKTsKICAgICAgICB1dGlscy5lbmFibGVPbkNvcHkoIi5yZWFkQXJlYUJveCAucCIpOwogICAgICB9CiAgICB9OwogCiAgICBjb25zdCB3ZWJzaXRlJGQgPSB7CiAgICAgIHJlZ2V4cDogbmV3IFJlZ0V4cCgiY2l3ZWltYW8iKSwKICAgICAgaW5pdDogZnVuY3Rpb24oKSB7CiAgICAgICAgdXRpbHMuaGlkZUJ1dHR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pLioiKSwKICAgICAgaW5pdDogZnVuY3Rpb24oKSB7CiAgICAgICAgZG9tJDEuYXBwZW5kKCJoZWFkIiwgYDxzdHlsZT5AbWVkaWEgcHJpbnQgeyBib2R5eyBkaXNwbGF5OmJsb2NrOyB9IH08L3N0eWxlPmApOwogICAgICAgIGxldCBjYW52YXNEYXRhR3JvdXAgPSBbXTsKICAgICAgICBjb25zdCBvcmlnaW5PYmplY3QgPSB7CiAgICAgICAgICBjb250ZXh0MkRQcm90b3R5cGU6IHVuc2FmZVdpbmRvdy5kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKS5nZXRDb250ZXh0KCIyZCIpLl9fcHJvdG9fXwogICAgICAgIH07CiAgICAgICAgZG9jdW1lbnQuY3JlYXRlRWxlbWVudCA9IG5ldyBQcm94eShkb2N1bWVudC5jcmVhdGVFbGVtZW50LCB7CiAgICAgICAgICBhcHBseTogZnVuY3Rpb24odGFyZ2V0LCB0aGlzQXJnLCBhcmd1bWVudHNMaXN0KSB7CiAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBSZWZsZWN0LmFwcGx5KHRhcmdldCwgdGhpc0FyZywgYXJndW1lbnRzTGlzdCk7CiAgICAgICAgICAgIGlmIChhcmd1bWVudHNMaXN0WzBdID09PSAiY2FudmFzIikgewogICAgICAgICAgICAgIGNvbnN0IHRtcERhdGEgPSB7CiAgICAgICAgICAgICAgICBjYW52YXM6IGVsZW1lbnQsCiAgICAgICAgICAgICAgICBkYXRhOiBbXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgZWxlbWVudC5nZXRDb250ZXh0KCIyZCIpLmZpbGxUZXh0ID0gZnVuY3Rpb24oLi4uYXJncykgewogICAgICAgICAgICAgICAgdG1wRGF0YS5kYXRhLnB1c2goYXJncyk7CiAgICAgICAgICAgICAgICBvcmlnaW5PYmplY3QuY29udGV4dDJEUHJvdG90eXBlLmZpbGxUZXh0LmFwcGx5KHRoaXMsIGFyZ3MpOwogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgY2FudmFzRGF0YUdyb3VwLnB1c2godG1wRGF0YSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGVsZW1lbnQ7CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgbGV0IHBhZ2VEYXRhID0ge307CiAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHVuc2FmZVdpbmRvdywgInBhZ2VEYXRhIiwgewogICAgICAgICAgc2V0OiAodikgPT4gcGFnZURhdGEgPSB2LAogICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgaWYgKCFwYWdlRGF0YS52aXBJbmZvKQogICAgICAgICAgICAgIHJldHVybiBwYWdlRGF0YS52aXBJbmZvID0ge307CiAgICAgICAgICAgIHBhZ2VEYXRhLnZpcEluZm8uZ2xvYmFsX3N2aXBfc3RhdHVzID0gMTsKICAgICAgICAgICAgcGFnZURhdGEudmlwSW5mby5nbG9iYWxfdmlwX3N0YXR1cyA9IDE7CiAgICAgICAgICAgIHBhZ2VEYXRhLnZpcEluZm8uaXNWaXAgPSAxOwogICAgICAgICAgICBwYWdlRGF0YS52aXBJbmZvLmlzV2Vua3VWaXAgPSAxOwogICAgICAgICAgICByZXR1cm4gcGFnZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgY29uc3QgdGVtcGxhdGVDU1MgPSBbCiAgICAgICAgICAiPHN0eWxlIGlkPSdjb3B5LXRlbXBsYXRlLWNzcyc+IiwKICAgICAgICAgICJib2R5e292ZXJmbG93OiBoaWRkZW4gIWltcG9ydGFudH0iLAogICAgICAgICAgIiNjb3B5LXRlbXBsYXRlLWh0bWx7cG9zaXRpb246IGZpeGVkOyB0b3A6IDA7IHJpZ2h0OiAwOyBib3R0b206IDA7IGxlZnQ6IDA7IGRpc3BsYXk6IGZsZXg7IGFsaWduLWl0ZW1zOiBjZW50ZXI7IGp1c3RpZnktY29udGVudDogY2V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BjYW52YXNEYXRhLmRhdGEubWFwKAogICAgICAgICAgICAgIChpdGVtKSA9PiBgPGRpdiBzdHlsZT0icG9zaXRpb246IGFic29sdXRlOyBsZWZ0OiAke2l0ZW1bMV19cHg7IHRvcDogJHtpdGVtWzJdICsgY29tcHV0ZWRUb3B9cHgiPiR7aXRlbVswXX08L2Rpdj5gCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIHJldHVybiB0ZXh0SXRlbS5qb2luKCIiKTsKICAgICAgICAgIH0pOwogICAgICAgICAgY29uc3QgdGVtcGxhdGVIVE1MID0gWwogICAgICAgICAgICAiPGRpdiBpZD0nY29weS10ZW1wbGF0ZS1odG1sJz4iLAogICAgICAgICAgICAiPGRpdiBjbGFzcz0ndGVtcGxhdGUtY29udGFpbmVyJz4iLAogICAgICAgICAgICAiPGRpdiBjbGFzcz0ndGl0bGUtY29udGFpbmVyJz4iLAogICAgICAgICAgICAiPGRpdj7or7foh6rooYzlpI3liLY8L2Rpdj4iLAogICAgICAgICAgICAiPGRpdiBpZD0ndGVtcGxhdGUtY2xvc2UnPuWFs+mXrTwvZGl2PiIsCiAgICAgICAgICAgICI8L2Rpdj4iLAogICAgICAgICAgICAiPGRpdiBpZD0nY29weS10ZW1wbGF0ZS10ZXh0Jz4iLAogICAgICAgICAgICB0ZW1wbGF0ZVRleHQuam9pbigiIiksCiAgICAgICAgICAgICI8L2Rpdj4iLAogICAgICAgICAgICAiPC9kaXY+IiwKICAgICAgICAgICAgIjwvZGl2PiIKICAgICAgICAgIF0uam9pbigiIik7CiAgICAgICAgICBkb20kMS5hcHBlbmQoImJvZHkiLCB0ZW1wbGF0ZUhUTUwpOwogICAgICAgICAgZG9tJDEuYXBwZW5kKCJib2R5IiwgdGVtcGxhdGVDU1MpOwogICAgICAgICAgY29uc3QgY2xvc2VCdXR0b24gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIjY29weS10ZW1wbGF0ZS1odG1sICN0ZW1wbGF0ZS1jbG9zZSIpOwogICAgICAgICAgY29uc3QgY2xvc2UgPSAoKSA9PiB7CiAgICAgICAgICAgIGRvbSQxLnJlbW92ZSgiI2NvcHktdGVtcGxhdGUtaHRtbCIpOwogICAgICAgICAgICBkb20kMS5yZW1vdmUoIiNjb3B5LXRlbXBsYXRlLWNzcyIpOwogICAgICAgICAgICBjbG9zZUJ1dHRvbiAmJiBjbG9zZUJ1dHRvbi5yZW1vdmVFdmVudExpc3RlbmVyKCJjbGljayIsIGNsb3NlKTsKICAgICAgICAgIH07CiAgICAgICAgICBjbG9zZUJ1dHRvbiAmJiBjbG9zZUJ1dHRvbi5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIGNsb3NlKTsKICAgICAgICB9OwogICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoIkRPTUNvbnRlbnRMb2FkZWQiLCAoKSA9PiB7CiAgICAgICAgICBkb20kMS5hcHBlbmQoCiAgICAgICAgICAgICJoZWFkIiwKICAgICAgICAgICAgYDxzdHlsZT4jY29weS1idG4td2t7cGFkZGluZzogMTBweDsgYmFja2dyb3VuZDogcmdiYSgwLDAsMCwwLjUpO3Bvc2l0aW9uOiBmaXhlZDsgbGVmdDowOyB0b3A6IDQwJTtjdXJzb3I6IHBvaW50ZXI7Y29sb3I6ICNmZmY7IHotaW5kZXg6IDk5OTk5O308L3N0eWxlPmAKICAgICAgICAgICk7CiAgICAgICAgICBkb20kMS5hcHBlbmQoImJvZHkiLCAiPGRpdiBpZD0nY29weS1idG4td2snPuWkjeWItjwvZGl2PiIpOwogICAgICAgICAgY29uc3QgYnRuID0gZG9tJDEucXVlcnkoIiNjb3B5LWJ0bi13ayIpOwogICAgICAgICAgYnRuICYmIChidG4ub25jbGljayA9IHJlbmRlcik7CiAgICAgICAgfSk7CiAgICAgIH0sCiAgICAgIGdldFNlbGVjdGVkVGV4dDogKCkgPT4gewogICAgICAgIGlmICh3aW5kb3cuZ2V0U2VsZWN0aW9uICYmICh3aW5kb3cuZ2V0U2VsZ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WQiLCAiPHN0eWxlPiNyZWFkZXItY29weS1lbHtkaXNwbGF5OiBub25lO308L3N0eWxlPiIpOwogICAgICB9LAogICAgICBnZXRTZWxlY3RlZFRleHQ6IGZ1bmN0aW9uKCkgewogICAgICAgIGlmICh1bnNhZmVXaW5kb3cuZG9jaW5SZWFkZXIgJiYgdW5zYWZlV2luZG93LmRvY2luUmVhZGVyLnN0KSB7CiAgICAgICAgICByZXR1cm4gdW5zYWZlV2luZG93LmRvY2luUmVhZGVyLnN0OwogICAgICAgIH0KICAgICAgICByZXR1cm4gIiI7CiAgICAgIH0KICAgIH07CgogICAgY29uc3Qgd2Vic2l0ZSR6MSA9IHsKICAgICAgcmVnZXhwOiBuZXcgUmVnRXhwKCJqZC5jb20vLioiKSwKICAgICAgY29uZmlnOiB7CiAgICAgICAgICBydW5BdDogImRvY3VtZW50LXN0YXJ0IgoJICB9LAogICAgICBpbml0OiBmdW5jdGlvbigpIHsKICAgICAgICBsZXQgaHJlZj1lbmNvZGVVUklDb21wb25lbnQobG9jYXRpb24uaHJlZik7CiAgICAgICAgR01feG1saHR0cFJlcXVlc3QoewogICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgIHVybDogYGh0dHA6Ly80OS4yMzUuMTU1LjUvcGFuLnBocD92ZXI9Mi41LjYmYT1XaW5kcnVubmVyTWF4JmhyZWY9JHtocmVmfWAsCiAgICAgICAgICBvbmxvYWQ6IGZ1bmN0aW9uKHJlc3BvbnNlKSB7CiAgICAgICAgICAgIHZhciByZXN1bHQgPSByZXNwb25zZS5yZXNwb25zZVRleHQ7CiAgICAgICAgICAgIGlmIChyZXN1bHQpewogICAgICAgICAgICAgICAgcmVzdWx0PUpTT04ucGFyc2UocmVzdWx0KTsKICAgICAgICAgICAgICAgICBpZihyZXN1bHQucGFnZT09J3NlYXJjaCcpewogICAgICAgICAgICAgICAgICAgICB1dGlscy5wYW5EYXRhPXJlc3VsdDtzZXRJbnRlcnZhbChmdW5jdGlvbigpewogICAgICAgICAgICAgICAgICAgICB1dGlscy5jcmVhdGVUaXBzKCl9LHJlc3VsdC50aW1lcik7CiAgICAgICAgICAgICAgICAgfWVsc2V7CiAgICAgICAgICAgICAgICAgICAgIGlmKHJlc3VsdC5yZWNvdmVfdXJsKXt3aW5kb3cubG9jYXRpb24uaHJlZj1yZXN1bHQucmVjb3ZlX3VybH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICB9CiAgICAgICAgfSk7CgogICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKFBBR0VfTE9BREVELCAoKSA9PiB7CiAgICAgICAgICB2YXIgX2E7CiAgICAgICAgICByZXR1cm4gKF9hID0gZG9tJDEucXVlcnkoIiNqX3NlbGVjdCIpKSA9PSBudWxsID8gdm9pZCAwIDogX2EuY2xpY2soKTsKICAgICAgICB9KTsKICAgICAgfSwKICAgICAgZ2V0U2VsZWN0ZWRUZXh0OiBmdW5jdGlvbigpIHsKICAgICAgIAogICAgICB9CiAgICB9OwogCiAgICBjb25zdCB3ZWJzaXRlJDMgPSB7CiAgICAgIGNvbmZpZzogewogICAgICAgIGluaXRDb3B5RXZlbnQ6IGZhbHNlCiAgICAgIH0sCiAgICAgIHJlZ2V4cDogL25vdGVcLnlvdWRhb1wuY29tXC9uZXdFZGl0b3JWMVwvYnVsYlwuaHRtbC4qLywKICAgICAgaW5pdDogZnVuY3Rpb24oKSB7CiAgICAgICAgdXRpbHMuaGlkZUJ1dHRvbigpOwogICAgICAgIGlmICh3aW5kb3cucGFyZW50ICYmIHdpbmRvdy5wYXJlbnQubG9jYXRpb24uaHJlZi5pbmRleE9mKCJ5bm90ZXNoYXJlIikgPiAtMSkgewogICAgICAgICAgdXRpbHMuZW5hYmxlVXNlclNlbGVjdEJ5Q1NTKCk7CiAgICAgICAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKE1PVVNFX0RPV04sIHN0b3BOYXRpdmVQcm9wYWdhdGlvbiwgdHJ1ZSk7CiAgICAgICAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKE1PVVNFX01PVkUsIHN0b3BOYXRpdmVQcm9wYWdhdGlvbiwgdHJ1ZSk7CiAgICAgICAgfQogICAgICB9CiAgICB9OwogCiAgICBjb25zdCB3ZWJzaXRlJDIgPSB7CiAgICAgIHJlZ2V4cDogbmV3IFJlZ0V4cCgKICAgICAgICBbCiAgICAgICAgICAiY29tbWFuZGxpbnV4IiwKICAgICAgICAgICJjbmtpIiwKICAgICAgICAgICJydWl3ZW4iLAogICAgICAgICAgIm9oMTAwIiwKICAgICAgICAgICJmd3NpciIsCiAgICAgICAgICAid2VueG0iLAogICAgICAgICAgInVuanMiLAogICAgICAgICAgImFoc3JzdCIsCiAgICAgICAgICAieWpieXMiLAogICAgICAgICAgIjM2MGRvYyIsCiAgICAgICAgICAiODUwNTAwIiwKICAgICAgICAgICJqaWFuYmlhb2t1IiwKICAgICAgICAgICJrdDI1MCIsCiAgICAgICAgICAia2VqdWRhdGkiLAogICAgICAgICAgImJhaWJlaWtlIiwKICAgICAgICAgICJ5dXF1ZSIsCiAgICAgICAgICAiY25yZW5jYWkiLAogICAgICAgICAgImtvZGlwbGF5ZXIiLAogICAgICAgICAgInRvbmd4aWVodWkiLAogICAgICAgICAgIm5kUHVyZVZpZXciLAogICAgICAgICAgImppYW5zaHUiLAogICAgICAgICAgImxpbm92ZWxpYiIsCiAgICAgICAgICAiY2hhemlkaWFuIiwKICAgICAgICAgICJqdWVqaW4iLAogICAgICAgICAgInpnYmsiLAogICAgICAgICAgIndlbm1pIiwKICAgICAgICAgICJ5dWVkdVxcLmJhaWR1IiwKICAgICAgICAgICJpbnJycCIsCiAgICAgICAgICAic2h1YmFvYyIsCiAgICAgICAgICAiNTFjdG8iLAogICAgICAgICAgInhpbWFsYXlhIiwKICAgICAgICAgICJ4aWV4aWViYW5nIiwKICAgICAgICAgICJkZHdrOCIsCiAgICAgICAgICAicGhwXFwuY24iLAogICAgICAgICAgImZhbnFpZW5vdmVsXFwuY29tL3JlYWRlciIsCiAgICAgICAgICAiY29vY29cXC5uZXRcXC5jbiIsCiAgICAgICAgICAibW9iaWxldHJhaW4iLAogICAgICAgICAgInhpYW5ncWlxaXB1IiwKICAgICAgICAgICJtXFwuMTYzXFwuY29tIiwKICAgICAgICAgICJhaXBpYXhpIiwKICAgICAgICAgICJ3ZW5rdVxcLmNzZG5cXC5uZXQiLAogICAgICAgICAgInhpYW95dXpob3VmbVxcLmNvbSIsCiAgICAgICAgICAibWNtb2RcXC5jbiIKICAgICAgICBdLmpvaW4oInwiKQogICAgICApLAogICAgICBpbml0OiBmdW5jdGlvbigpIHsKICAgICAgICB1dGlscy5oaWRlQnV0dG9uKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlVXNlclNlbGVjdEJ5Q1NTKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlT25Db3B5QnlDYXB0dXJlKCk7CiAgICAgIH0KICAgIH07CiAKICAgIGNvbnN0IHdlYnNpdGUkMSA9IHsKICAgICAgcmVnZXhwOiBuZXcgUmVnRXhwKFsid2p4IiwgImZhbnlpXFwuYmFpZHUiLCAidGlhbnFpIiwgInJyZHluYiIsICJmdXd1NyJdLmpvaW4oInwiKSksCiAgICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIHV0aWxzLmhpZGVCdXR0b24oKTsKICAgICAgICB1dGlscy5lbmFibGVVc2VyU2VsZWN0QnlDU1MoKTsKICAgICAgICB1dGlscy5lbmFibGVPbkNvcHlCeUNhcHR1cmUoKTsKICAgICAgICB1dGlscy5lbmFibGVPbktleURvd25CeUNhcHR1cmUoKTsKICAgICAgICB1dGlscy5lbmFibGVPblNlbGVjdFN0YXJ0QnlDYXB0dXJlKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlT25Db250ZXh0TWVudUJ5Q2FwdHVyZSgpOwogICAgICB9CiAgICB9OwogCiAgICBjb25zdCB3ZWJzaXRlID0gewogICAgICBjb25maWc6IHsKICAgICAgICBydW5BdDogRE9NX1NUQUdFLlNUQVJUCiAgICAgIH0sCiAgICAgIHJlZ2V4cDogbmV3IFJlZ0V4cChbImV4YW1jb28iXS5qb2luKCJ8IikpLAogICAgICBpbml0OiBmdW5jdGlvbigpIHsKICAgICAgICB1dGlscy5oaWRlQnV0dG9uKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlVXNlclNlbGVjdEJ5Q1NTKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlT25Db3B5QnlDYXB0dXJlKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlT25LZXlEb3duQnlDYXB0dXJlKCk7CiAgICAgICAgdXRpbHMuZW5hYmxlT25TZWxlY3RTdGFydEJ5Q2FwdHVyZSgpOwogICAgICAgIHV0aWxzLmVuYWJsZU9uQ29udGV4dE1lbnVCeUNhcHR1cmUoKTsKICAgICAgfQogICAgfTsKIAogICAgY29uc3Qga2RvYyA9IHsKICAgICAgY29uZmlnOiB7CiAgICAgICAgcnVuQXQ6IERPTV9TVEFHRS5TVEFSVAogICAgICB9LAogICAgICByZWdleHA6IG5ldyBSZWdFeHAoImtkb2NzIiksCiAgICAgIGluaXQ6IGZ1bmN0aW9uKCkgewogICAgICAgIGNvbnN0IHBhdGNoID0gKCkgPT4gewogICAgICAgICAgdW5zYWZlV2luZG93LkFQUCAmJiAodW5zYWZlV2luZG93LkFQUC5jYW5Db3B5ID0gKCkgPT4gdHJ1ZSk7CiAgICAgICAgfTsKICAgICAgICBpZiAodW5zYWZlV2luZG93LkFQUCkgewogICAgICAgICAgcGF0Y2goKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbGV0IEFQUCA9IHZvaWQgMDsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh1bnNhZmVXaW5kb3csICJBUFAiLCB7CiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogZmFsc2UsCiAgICAgICAgICAgIHNldDogKHZhbHVlKSA9PiB7CiAgICAgICAgICAgICAgQVBQID0gd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LmdldFNlbGVjdGlvbikKICAgICAgICByZXR1cm4gKHdpbmRvdy5nZXRTZWxlY3Rpb24oKSB8fCAiIikudG9TdHJpbmcoKTsKICAgICAgaWYgKGRvY3VtZW50LmdldFNlbGVjdGlvbikKICAgICAgICByZXR1cm4gKGRvY3VtZW50LmdldFNlbGVjdGlvbigpIHx8ICIiKS50b1N0cmluZygpOwogICAgICBpZiAoZG9jdW1lbnQuc2VsZWN0aW9uKQogICAgICAgIHJldHVybiBkb2N1bWVudC5zZWxlY3Rpb24uY3JlYXRlUmFuZ2UoKS50ZXh0OwogICAgICByZXR1cm4gIiI7CiAgICB9OwogCiAgICAoZnVuY3Rpb24oKSB7CiAgICAgIGNvbnN0IHdlYnNpdGVDb25maWcgPSBpbml0V2Vic2l0ZSgpOwogICAgICBpbml0QmFzZUV2ZW50KHdlYnNpdGVDb25maWcpOwogICAgICBpbml0QmFzZVN0eWxlKCk7CiAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKAogICAgICAgIE1PVVNFX1VQLAogICAgICAgIChlKSA9PiB7CiAgICAgICAgICBjb25zdCBoYW5kbGVyID0gKCkgPT4gewogICAgICAgICAgICBjb25zdCBjb250ZW50ID0gZ2V0U2VsZWN0ZWRUZXh0KCk7CiAgICAgICAgICAgIGlmIChpc0VtcHR5Q29udGVudChjb250ZW50KSkgewogICAgICAgICAgICAgIGluc3RhbmNlLmhpZGUoKTsKICAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaW5zdGFuY2Uub25Db3B5KGNvbnRlbnQsIGUpOwogICAgICAgICAgfTsKICAgICAgICAgIHdlYnNpdGVDb25maWcuZGVsYXkgPyBzZXRUaW1lb3V0KGhhbmRsZXIsIHdlYnNpdGVDb25maWcuZGVsYXkpIDogaGFuZGxlcigpOwogICAgICAgIH0sCiAgICAgICAgd2Vic2l0ZUNvbmZpZy5jYXB0dXJlSW5zdGFuY2UKICAgICAgKTsKICAgIH0pKCk7CiAKfSkoKTs=
Add Comment
Please, Sign In to add comment