diff --git a/.gitignore b/.gitignore index f36e39f..b817f6b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ libs/shinkai-tools-runner/shinkai-tools-runner-resources apps/shinkai-tool-aave-load-requester/src/bundled-resources launch.json .DS_Store +libs/shinkai-tools-runner/shinkai-tools-runner-execution-storage diff --git a/Cargo.lock b/Cargo.lock index 4f80918..b1dc665 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "arbitrary" @@ -1547,7 +1547,9 @@ dependencies = [ name = "shinkai_tools_runner" version = "0.0.0" dependencies = [ + "anyhow", "base64-simd", + "chrono", "copy_to_output", "derivative", "derive_more", diff --git a/apps/shinkai-tool-aave-state/src/index.ts b/apps/shinkai-tool-aave-state/src/index.ts index 9942ba7..de6ce12 100644 --- a/apps/shinkai-tool-aave-state/src/index.ts +++ b/apps/shinkai-tool-aave-state/src/index.ts @@ -112,7 +112,7 @@ export const definition: ToolDefinition = { }; // attach-viem-script-content -const viemScriptContent = +const viemScriptContent = "KCgpID0+IHsKICB2YXIgX19kZWZQcm9wID0gT2JqZWN0LmRlZmluZVByb3BlcnR5OwogIHZhciBfX2dldE93blByb3BOYW1lcyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzOwogIHZhciBfX2VzbSA9IChmbiwgcmVzKSA9PiBmdW5jdGlvbiBfX2luaXQoKSB7CiAgICByZXR1cm4gZm4gJiYgKHJlcyA9ICgwLCBmbltfX2dldE93blByb3BOYW1lcyhmbilbMF1dKShmbiA9IDApKSwgcmVzOwogIH07CiAgdmFyIF9fZXhwb3J0ID0gKHRhcmdldCwgYWxsKSA9PiB7CiAgIC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uc3QgZG9jc1BhdGg5ID0gYXJncy5jYXVzZSBpbnN0YW5jZW9mIF9CYXNlRXJyb3IgPyBhcmdzLmNhdXNlLmRvY3NQYXRoIHx8IGFyZ3MuZG9jc1BhdGggOiBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgY29uc3QgbWVzc2FnZSA9IFsKICAgICAgICAgICAgc2hvcnRNZXNzYWdlIHx8ICJBbiBlcnJvciBvY2N1cnJlZC4iLAogICAgICAgICAgICAiIiwKICAgICAgICAgICAgLi4uYXJncy5tZXRhTWVzc2FnZXMgPyBbLi4uYXJncy5tZXRhTWVzc2FnZXMsICIiXSA6IFtdLAogICAgICAgICAgICAuLi5kb2NzUGF0aDkgPyBbYERvY3M6IGh0dHBzOi8vYWJpdHlwZS5kZXYke2RvY3NQYXRoOX1gXSA6IFtdLAogICAgICAgICAgICAuLi5kZXRhaWxzID8gW2BEZXRhaWxzOiAke2RldGFpbHN9YF0gOiBbXSwKICAgICAgICAgICAgYFZlcnNpb246IGFiaXR5cGVAJHt2ZXJzaW9ufWAKICAgICAgICAgIF0uam9pbigiXG4iKTsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkZXRhaWxzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZG9jc1BhdGgiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtZXRhTWVzc2FnZXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaG9ydE1lc3NhZ2UiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkFiaVR5cGVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKGFyZ3MuY2F1c2UpCiAgICAgICAgICAgIHRoaXMuY2F1c2UgPSBhcmdzLmNhdXNlOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5zaG9ydE1lc3NhZ2UgPSBzaG9ydE1lc3NhZ2U7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAx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HNpZ25hdHVyZT9gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIlVua25vd25UeXBlRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVua25vd25Tb2xpZGl0eVR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoIlVua25vd24gdHlwZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogW2BUeXBlICIke3R5cGV9IiBpcyBub3QgYSB2YWxpZCBBQkkgdHlwZS5gXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNvbGlkaXR5VHlwZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9lcnJvcnMvYWJpUGFyYW1ldGVyLmpzCiAgdmFyIEludmFsaWRBYmlQYXJhbWV0ZXJFcnJvciwgSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciwgSW52YWx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xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW1zIH0pIHsKICAgICAgICAgIHN1cGVyKCJGYWlsZWQgdG8gcGFyc2UgQUJJIHBhcmFtZXRlcnMuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBgcGFyc2VBYmlQYXJhbWV0ZXJzKCR7SlNPTi5zdHJpbmdpZnkocGFyYW1zLCBudWxsLCAyKX0pYCwKICAgICAgICAgICAgZG9jc1BhdGg6ICIvYXBpL2h1bWFuI3BhcnNlYWJpcGFyYW1ldGVycy0xIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZFBhcmFtZXRlckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0gfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6ICJJbnZhbGlkUGFyYW1ldGVyRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFNvbGlkaXR5UHJvdGVjdGVkS2V5d29yZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIG5hbWUgfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtLAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgIiR7bmFtZX0iIGlzIGEgcHJvdGVjdGVkIFNvbGlkaXR5IGtleXdvcmQuIE1vcmUgaW5mbzogaHR0cHM6Ly9kb2NzLnNvbGlkaXR5bGFuZy5vcmcvZW4vbGF0ZXN0L2NoZWF0c2hlZXQuaHRtbGAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiU29saWRpdHlQcm90ZWN0ZWRLZXl3b3JkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRNb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRNb2RpZmllckVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRnVuY3Rpb25Nb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gLAogICAgICAgICAgICAgIGBEYXRhIGxvY2F0aW9uIGNhbiBvbmx5IGJlIHNwZWNpZmllZCBmb3IgYXJyYXksIHN0cnVjdCwgb3IgbWFwcGluZyB0eXBlcywgYnV0ICIke21vZGlmaWVyfSIgd2FzIGdpdmVuLmAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6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8uZGVuby9hYml0eXBlQDEuMC42L25vZGVfbW9kdWxlcy9hYml0eXBlL2Rpc3QvZXNtL2h1bWFuLXJlYWRhYmxlL2Vycm9ycy9zaWduYXR1cmUuanMiKCkgewogICAgICBpbml0X2Vycm9ycygpOwogICAgICBJbnZhbGlkU2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzaWduYXR1cmUsIHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgJHt0eXBlfSBzaWduYXR1cmUuYCwgewogICAgICAgICAgICBkZXRhaWxzOiBzaWduYXR1cmUKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRTaWduYXR1cmVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgVW5rbm93blNpZ25hdHVyZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgc2lnbmF0dXJlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNpZ25hdHVyZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU3RydWN0U2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzaWduYXR1cmUgfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgc3RydWN0IHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbIk5vIHByb3BlcnRpZXMgZXhpc3QuIl0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRTdHJ1Y3RTaWduYXR1cmVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL2FiaXR5cGVAMS4wLjYvbm9kZV9tb2R1bGVzL2FiaXR5cGUvZGlzdC9lc20vaHVtYW4tcmVhZGFibGUvZXJyb3JzL3N0cnVjdC5qcwogIHZhciBDaXJjdWxhclJlZmVyZW5jZUVycm9yOwogIHZhciBpbml0X3N0cnVjdCA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9lcnJvcnMvc3RydWN0LmpzIigpIHsKICAgICAgaW5pdF9lcnJvcnMoKTsKICAgICAgQ2lyY3VsYXJSZWZlcmVuY2VFcnJvciA9IGNsYXNzIGV4dG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BhcmFtZXRlckNhY2hlID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoWwogICAgICAgIC8vIFVubmFtZWQKICAgICAgICBbImFkZHJlc3MiLCB7IHR5cGU6ICJhZGRyZXNzIiB9XSwKICAgICAgICBbImJvb2wiLCB7IHR5cGU6ICJib29sIiB9XSwKICAgICAgICBbImJ5dGVzIiwgeyB0eXBlOiAiYnl0ZXMiIH1dLAogICAgICAgIFsiYnl0ZXMzMiIsIHsgdHlwZTogImJ5dGVzMzIiIH1dLAogICAgICAgIFsiaW50IiwgeyB0eXBlOiAiaW50MjU2IiB9XSwKICAgICAgICBbImludDI1NiIsIHsgdHlwZTogImludDI1NiIgfV0sCiAgICAgICAgWyJzdHJpbmciLCB7IHR5cGU6ICJzdHJpbmciIH1dLAogICAgICAgIFsidWludCIsIHsgdHlwZTogInVpbnQyNTYiIH1dLAogICAgICAgIFsidWludDgiLCB7IHR5cGU6ICJ1aW50OCIgfV0sCiAgICAgICAgWyJ1aW50MTYiLCB7IHR5cGU6ICJ1aW50MTYiIH1dLAogICAgICAgIFsidWludDI0IiwgeyB0eXBlOiAidWludDI0IiB9XSwKICAgICAgICBbInVpbnQzMiIsIHsgdHlwZTogInVpbnQzMiIgfV0sCiAgICAgICAgWyJ1aW50NjQiLCB7IHR5cGU6ICJ1aW50NjQiIH1dLAogICAgICAgIFsidWludDk2IiwgeyB0eXBlOiAidWludDk2IiB9XSwKICAgICAgICBbInVpbnQxMTIiLCB7IHR5cGU6ICJ1aW50MTEyIiB9XSwKICAgICAgICBbInVpbnQxNjAiLCB7IHR5cGU6ICJ1aW50MTYwIiB9XSwKICAgICAgICBbInVpbnQxOTIiLCB7IHR5cGU6ICJ1aW50MTkyIiB9XSwKICAgICAgICBbInVpbnQyNTYiLCB7IHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAvLyBOYW1lZAogICAgICAgIFsiYWRkcmVzcyBvd25lciIsIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAib3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tc1tpXSwgewogICAgICAgICAgICBtb2RpZmllcnM6IGZ1bmN0aW9uTW9kaWZpZXJzLAogICAgICAgICAgICBzdHJ1Y3RzLAogICAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB7CiAgICAgICAgbmFtZTogbWF0Y2gubmFtZSwKICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgIHN0YXRlTXV0YWJpbGl0eTogbWF0Y2guc3RhdGVNdXRhYmlsaXR5ID8/ICJub25wYXlhYmxlIiwKICAgICAgICBpbnB1dHMsCiAgICAgICAgb3V0cHV0cwogICAgICB9OwogICAgfQogICAgaWYgKGlzRXZlbnRTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFdmVudFNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJldmVudCIgfSk7CiAgICAgIGNvbnN0IHBhcmFtcyA9IHNwbGl0UGFyYW1ldGVycyhtYXRjaC5wYXJhbWV0ZXJzKTsKICAgICAgY29uc3QgYWJpUGFyYW1ldGVycyA9IFtdOwogICAgICBjb25zdCBsZW5ndGggPSBwYXJhbXMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgYWJpUGFyYW1ldGVycy5wdXNoKHBhcnNlQWJpUGFyYW1ldGVyKHBhcmFtc1tpXSwgewogICAgICAgICAgbW9kaWZpZXJzOiBldmVudE1vZGlmaWVycywKICAgICAgICAgIHN0cnVjdHMsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiB7IG5hbWU6IG1hdGNoLm5hbWUsIHR5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g7IGkrKykgewogICAgICBjb25zdCBzaWduYXR1cmUgPSBzaWduYXR1cmVzW2ldOwogICAgICBpZiAoIWlzU3RydWN0U2lnbmF0dXJlKHNpZ25hdHVyZSkpCiAgICAgICAgY29udGludWU7CiAgICAgIGNvbnN0IG1hdGNoID0gZXhlY1N0cnVjdFNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJzdHJ1Y3QiIH0pOwogICAgICBjb25zdCBwcm9wZXJ0aWVzID0gbWF0Y2gucHJvcGVydGllcy5zcGxpdCgiOyIpOwogICAgICBjb25zdCBjb21wb25lbnRzID0gW107CiAgICAgIGNvbnN0IHByb3BlcnRpZXNMZW5ndGggPSBwcm9wZXJ0aWVzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBwcm9wZXJ0aWVzTGVuZ3RoOyBrKyspIHsKICAgICAgICBjb25zdCBwcm9wZXJ0eSA9IHByb3BlcnRpZXNba107CiAgICAgICAgY29uc3QgdHJpbW1lZCA9IHByb3BlcnR5LnRyaW0oKTsKICAgICAgICBpZiAoIXRyaW1tZWQpCiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjb25zdCBhYmlQYXJhbWV0ZXIgPSBwYXJzZUFiaVBhcmFtZXRlcih0cmltbWVkLCB7CiAgICAgICAgICB0eXBlOiAic3RydWN0IgogICAgICAgIH0pOwogICAgICAgIGNvbXBvbmVudHMucHVzaChhYmlQYXJhbWV0ZXIpOwogICAgICB9CiAgICAgIGlmICghY29tcG9uZW50cy5sZW5ndGgpCiAgICAgICAgdGhyb3cgbmV3IEludmFsaWRTdHJ1Y3RTaWduYXR1cmVFcnJvcih7IHNpZ25hdHVyZSB9KTsKICAgICAgc2hhbGxvd1N0cnVjdHNbbWF0Y2gubmFtZV0gPSBjb21wb25lbnRzOwogICAgfQogICAg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eXBlUGFyYW1ldGVyRXJyb3IoeyBhYmlQYXJhbWV0ZXIgfSk7CiAgICAgICAgY29uc3QgeyBhcnJheSwgdHlwZSB9ID0gbWF0Y2g7CiAgICAgICAgaWYgKHR5cGUgaW4gc3RydWN0cykgewogICAgICAgICAgaWYgKGFuY2VzdG9ycy5oYXModHlwZSkpCiAgICAgICAgICAgIHRocm93IG5ldyBDaXJjdWxhclJlZmVyZW5jZUVycm9yKHsgdHlwZSB9KTsKICAgICAgICAgIGNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgICAgIC4uLmFiaVBhcmFtZXRlciwKICAgICAgICAgICAgdHlwZTogYHR1cGxlJHthcnJheSA/PyAiIn1gLAogICAgICAgICAgICBjb21wb25lbnRzOiByZXNvbHZlU3RydWN0cyhzdHJ1Y3RzW3R5cGVdID8/IFtdLCBzdHJ1Y3RzLCAvKiBAX19QVVJFX18gKi8gbmV3IFNldChbLi4uYW5jZXN0b3JzLCB0eXBlXSkpCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGlzU29saWRpdHlUeXBlKHR5cGUpKQogICAgICAgICAgICBjb21wb25lbnRzLnB1c2goYWJpUGFyYW1ldGVyKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgdGhyb3cgbmV3IFVua25vd25UeXBlRXJyb3IoeyB0eXBlIH0pOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGNvbXBvbmVudHM7CiAgfQogIHZhciB0eXBlV2l0aG91dFR1cGxlUmVnZXg7CiAgdmFyIGluaXRfc3RydWN0cyA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9ydW50aW1lL3N0cnVjdHMuanMiKCkgewogICAgICBpbml0X3JlZ2V4KCk7CiAgICAgIGluaXRfYWJpSXRlbSgpOwogICAg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AogICAgICB9OwogICAgICBCYXNlRXJyb3IyID0gY2xhc3MgX0Jhc2VFcnJvciBleHRlbmRzIEVycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihzaG9ydE1lc3NhZ2UsIGFyZ3MgPSB7fSkgewogICAgICAgICAgY29uc3QgZGV0YWlscyA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kZXRhaWxzOwogICAgICAgICAgICBpZiAoYXJncy5jYXVzZT8ubWVzc2FnZSkKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5tZXNzYWdlOwogICAgICAgICAgICByZXR1cm4gYXJncy5kZXRhaWxzOwogICAgICAgICAgfSkoKTsKICAgICAgICAgIGNvbnN0IGRvY3NQYXRoOSA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kb2NzUGF0aCB8fCBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgICByZXR1cm4gYXJncy5kb2NzUGF0aDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBkb2NzVXJsID0gZXJyb3JDb25maWcuZ2V0RG9jc1VybD8uKHsgLi4uYXJncywgZG9jc1BhdGg6IGRvY3NQYXRoOSB9KTsKICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBbCiAgICAgICAgICAgIHNob3J0TWVzc2FnZSB8fCAiQW4gZXJyb3Igb2NjdXJyZWQuIiwKICAgICAgICAgICAgIiIsCiAgICAgICAgICAgIC4uLmFyZ3MubWV0YU1lc3NhZ2VzID8gWy4uLmFyZ3MubWV0YU1lc3NhZ2VzLCAiIl0gOiBbXSwKICAgICAgICAgICAgLi4uZG9jc1VybCA/IFtgRG9jczogJHtkb2NzVXJsfWBdIDogW10sCiAgICAgICAgICAgIC4uLmRldGFpbHMgPyBbYERldGFpbHM6ICR7ZGV0YWlsc31gXSA6IFtdLAogICAgICAgICAgICAuLi5lcnJvckNvbmZpZy52ZXJzaW9uID8gW2BWZXJzaW9uOiAke2Vycm9yQ29uZmlnLnZlcnNpb259YF0gOiBbXQogICAgICAgICAgXS5qb2luKCJcbiIpOwogICAgICAgICAgc3VwZXIobWVzc2FnZSwgYXJncy5jYXVzZSA/IHsgY2F1c2U6IGFyZ3MuY2F1c2UgfSA6IHZvaWQgMCk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRldGFpbHMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkb2NzUGF0aCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm1ldGFNZXNzYWdlcyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNob3J0TWVzc2FnZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInZlcnNpb24iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkJhc2VFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5uYW1lID0gYXJncy5uYW1lID8/IHRoaXMubmFtZTsKICAgICAgICAgIHRoaXMuc2hvcnRNZXNzYWdlID0gc2hvcnRNZXNzYWdlOwogICAgICAgICAgdGhpcy52ZXJzaW9uID0gdmVyc2lvbjI7CiAgICAgICAgfQogICAgICAgIHdhbGsoZm4pIHsKICAgICAgICAgIHJldHVybiB3YWxrKHRoaXMsIGZuKTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3Zp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ZSBvZiAke3NpemUzfSBieXRlcyBpcyB0b28gc21hbGwgZm9yIGdpdmVuIHBhcmFtZXRlcnMuYF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgUGFyYW1zOiAoJHtmb3JtYXRBYmlQYXJhbXMocGFyYW1zLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pfSlgLAogICAgICAgICAgICAgIGBEYXRhOiAgICR7ZGF0YX0gKCR7c2l6ZTN9IGJ5dGVzKWAKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkFiaURlY29kaW5nRGF0YVNpemVUb29TbWFsbEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJwYXJhbXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuZGF0YSA9IG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Jyb3JOYW1lfSIgb24gdGhlIEFCSSBkb2VzIG5vdCBjb250YWluIGFueSBwYXJhbWV0ZXJzIChcYGlucHV0c1xgKS5gLAogICAgICAgICAgICAiQ2Fubm90IGVuY29kZSBlcnJvciByZXN1bHQgd2l0aG91dCBrbm93aW5nIHdoYXQgdGhlIHBhcmFtZXRlciB0eXBlcyBhcmUuIiwKICAgICAgICAgICAgIk1ha2Ugc3VyZSB5b3UgYXJlIHVzaW5nIHRoZSBjb3JyZWN0IEFCSSBhbmQgdGhhdCB0aGUgaW5wdXRzIGV4aXN0IG9uIGl0LiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBuYW1lOiAiQWJpRXJyb3JJbnB1dHNOb3RGb3VuZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBBYmlFcnJvck5vdEZvdW5kRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKGVycm9yTmFtZSwgeyBkb2NzUGF0aDogZG9jc1BhdGg5IH0gPSB7fSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgRXJyb3IgJHtlcnJvck5hbWUgPyBgIiR7ZXJyb3JOYW1lfSIgYCA6ICIifW5vdCBmb3VuZCBvbiBBQkkuYCwKICAgICAgICAgICAgIk1ha2Ugc3VyZSB5b3UgYXJlIHVzaW5nIHRoZSBjb3JyZWN0IEFCSSBhbmQgdGhhdCB0aGUgZXJyb3IgZXhpc3RzIG9uIGl0LiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBuYW1lOiAiQWJpRXJyb3JOb3RGb3VuZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBBYmlFcnJvclNpZ25hdHVyZU5vd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ICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkYXRhIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAicGFyYW1zIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAic2l6ZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaUl0ZW0gPSBhYmlJdGVtOwogICAgICAgICAgdGhpcy5kYXRhID0gZGF0YTsKICAgICAgICAgIHRoaXMucGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgdGhpcy5zaXplID0gc2l6ZTM7CiAgICAgICAgfQogICAgICB9OwogICAgICBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBw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RBYmlEZWNvZGluZ1R5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSwgeyBkb2NzUGF0aDogZG9jc1BhdGg5IH0pIHsKICAgICAgICAgIHN1cGVyKFsKICAgICAgICAgICAgYFR5cGUgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlY29kaW5nIHR5cGUuYCwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgdmFsaWQgQUJJIHR5cGUuIgogICAgICAgICAgXS5qb2luKCJcbiIpLCB7IGRvY3NQYXRoOiBkb2NzUGF0aDksIG5hbWU6ICJJbnZhbGlkQWJpRGVjb2RpbmdUeXBlIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRBcnJheUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih2YWx1ZSkgewogICAgICAgICAgc3VwZXIoW2BWYWx1ZSAiJHt2YWx1ZX0iIGlzIG5vdCBhIHZhbGlkIGFycmF5LmBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBcnJheUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRGVmaW5pdGlvblR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlZmluaXRpb24gdHlwZS5gLAogICAgICAgICAgICAnVmFsaWQgdHlwZXM6ICJmdW5jdGlvbiIsICJldmVudCIsICJlcnJvciInCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsgbmFtZTogIkludmFsaWREZWZpbml0aW9uVHlwZUVycm9yIiB9KTsKICAgICAgIC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leChoZXgsIHRvT3JPcHRzKSB7CiAgICBjb25zdCBvcHRzID0gdHlwZW9mIHRvT3JPcHRzID09PSAic3RyaW5nIiA/IHsgdG86IHRvT3JPcHRzIH0gOiB0b09yT3B0czsKICAgIGNvbnN0IHRvID0gb3B0cy50bzsKICAgIGlmICh0byA9PT0gIm51bWJlciIpCiAgICAgIHJldHVybiBoZXhUb051bWJlcihoZXgsIG9wdHMpOwogICAgaWYgKHRvID09PSAiYmlnaW50IikKICAgICAgcmV0dXJuIGhleFRvQmlnSW50KGhleCwgb3B0cyk7CiAgICBpZiAodG8gPT09ICJzdHJpbmciKQogICAgICByZXR1cm4gaGV4VG9TdHJpbmcoaGV4LCBvcHRzKTsKICAgIGlmICh0byA9PT0gImJvb2xlYW4iKQogICAgICByZXR1cm4gaGV4VG9Cb29sKGhleCwgb3B0cyk7CiAgICByZXR1cm4gaGV4VG9CeXRlcyhoZXgsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBoZXhUb0JpZ0ludChoZXgsIG9wdHMgPSB7fSkgewogICAgY29uc3QgeyBzaWduZWQgfSA9IG9wdHM7CiAgICBpZiAob3B0cy5zaXplKQogICAgICBhc3NlcnRTaXplKGhleCwgeyBzaXplOiBvcHRzLnNpemUgfSk7CiAgICBjb25zdCB2YWx1ZSA9IEJpZ0ludChoZXgpOwogICAgaWYgKCFzaWduZWQpCiAgICAgIHJldHVybiB2YWx1ZTsKICAgIGNvbnN0IHNpemUzID0gKGhleC5sZW5ndGggLSAyKSAvIDI7CiAgICBjb25zdCBtYXggPSAoMW4gPDwgQmlnSW50KHNpemUzKSAqIDhuIC0gMW4pIC0gMW47CiAgICBpZiAodmFsdWUgPD0gbWF4KQogICAgICByZXR1cm4gdmFsdWU7CiAgICByZXR1cm4gdmFsdWUgLSBCaWdJbnQoYDB4JHsiZiIucGFkU3RhcnQoc2l6ZTMgKiAyLCAiZiIpfWApIC0gMW47CiAgfQogIGZ1bmN0aW9uIGhleFRvQm9vbChoZXhfLCBvcH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Abm9ibGUraGFzaGVzQDEuNS4wL25vZGVfbW9kdWxlcy9Abm9ibGUvaGFzaGVzL2VzbS9zaGEzLmpzIigpIHsKICAgICAgaW5pdF9hc3NlcnQoKTsKICAgICAgaW5pdF91NjQoKTsKICAgICAgaW5pdF91dGlsczIoKTsKICAgICAgU0hBM19QSSA9IFtdOwogICAgICBTSEEzX1JPVEwgPSBbXTsKICAgICAgX1NIQTNfSU9UQSA9IFtdOwogICAgICBfMG4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDApOwogICAgICBfMW4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDEpOwogICAgICBfMm4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDIpOwogICAgICBfN24gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDcpOwogICAgICBfMjU2biA9IC8qIEBfX1BVUkVfXyAqLyBCaWdJbnQoMjU2KTsKICAgICAgXzB4NzFuID0gLyogQF9fUFVSRV9fICovIEJpZ0ludCgxMTMpOwogICAgICBmb3IgKGxldCByb3VuZCA9IDAsIFIgPSBfMW4sIHggPSAxLCB5ID0gMDsgcm91bmQgPCAyNDsgcm91bmQrKykgewogICAgICAgIFt4LCB5XSA9IFt5LCAoMiAqIHggKyAzICogeSkgJSA1XTsKICAgICAgICBTSEEzX1BJLnB1c2goMiAqICg1ICogeSArIHgpKTsKICAgICAgICBTSEEzX1JPVEwucHVzaCgocm91bmQgKyAxKSAqIChyb3VuZCArIDIpIC8gMiAlIDY0KTsKICAgICAgICBsZXQgdCA9IF8wbjsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDc7IGorKykgewogICAgICAgICAgUiA9IChSIDw8IF8xbiBeIChSID4+IF83bikgKiBfMHg3MW4pICUgXzI1Nm47CiAgICAgICAgICBpZiAoUiAmIF8ybikKICAgICAgICAgICAgdCBePSBfMW4gPDwgKF8xbiA8PCAvKiBAX19QVVJFX18gKi8gQmlnSW50KGopKSAtIF8xbjsKICAgICAgICB9CiA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iA+PSAyMDApCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiU2hhMyBzdXBwb3J0cyBvbmx5IGtlY2Nhay1mMTYwMCBmdW5jdGlvbiIpOwogICAgICAgICAgdGhpcy5zdGF0ZSA9IG5ldyBVaW50OEFycmF5KDIwMCk7CiAgICAgICAgICB0aGlzLnN0YXRlMzIgPSB1MzIodGhpcy5zdGF0ZSk7CiAgICAgICAgfQogICAgICAgIGtlY2NhaygpIHsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAga2VjY2FrUCh0aGlzLnN0YXRlMzIsIHRoaXMucm91bmRzKTsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAgdGhpcy5wb3NPdXQgPSAwOwogICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiwgc3RhdGUgfSA9IHRoaXM7CiAgICAgICAgICBkYXRhID0gdG9CeXRlczIoZGF0YSk7CiAgICAgICAgICBjb25zdCBsZW4gPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDA7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGNvbnN0IHRha2UgPSBNYXRoLm1pbihibG9ja0xlbiAtIHRoaXMucG9zLCBsZW4gLSBwb3MpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRha2U7IGkrKykKICAgICAgICAgICAgICBzdGF0ZVt0aGlzLnBvcysrXSBePSBkYXRhW3BvcysrXTsKICAgICAgICAgICAgaWYgKHRoaXMucG9zID09PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGZpbmlzaCgpIHsKICAgICAgICAgIGlmICh0aGlzLmZpbmlzaGVkKQogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB0aGlzLmZpbmlzaGVkID0gdHJ1ZTsKICAgICAgICAgIGNvbnN0IHsgc3RhdGUsIHN1ZmZpeCwgcG9zLCBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIHN0YXRlW3Bvc10gXj0gc3VmZml4OwogICAgICAgICAgaWYgKChzdWZmaXggJiAxMjgpICE9PSAwICYmIHBvcyA9PT0gYmxvY2tMZW4gLSAxKQogICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgc3RhdGVbYmxvY2tMZW4gLSAxXSBePSAxMjg7CiAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgIH0KICAgICAgICB3cml0ZUludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcywgZmFsc2UpOwogICAgICAgICAgYnl0ZXMob3V0KTsKICAgICAgICAgIHRoaXMuZmluaXNoKCk7CiAgICAgICAgICBjb25zdCBidWZmZXJPdXQgPSB0aGlzLnN0YXRlOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDAsIGxlbiA9IG91dC5sZW5ndGg7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnBvc091dCA+PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvc091dCwgbGVuIC0gcG9zKTsKICAgICAgICAgICAgb3V0LnNldChidWZmZXJPdXQuc3ViYXJyYXkodGhpcy5wb3NPdXQsIHRoaXMucG9zT3V0ICsgdGFrZSksIHBvcyk7CiAgICAgICAgICAgIHRoaXMucG9zT3V0ICs9IHRha2U7CiAgICAgICAgICAgIHBvcyArPSB0YWtlOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG91dDsKICAgICAgICB9CiAgICAgICAgeG9mSW50byhvdXQpIHsKICAgICAgICAgIGlmICghdGhpcy5lbmFibGVYT0YpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiWE9GIGlzIG5vdCBwb3NzaWJsZSBmb3IgdGhpcyBpbnN0YW5jZSIpOwogICAgICAgICAgcmV0dXJuIHRoaXMud3JpdGVJbnRvKG91dCk7CiAgICAgICAgfQogICAgICAgIHhvZihieXRlczIpIHsKICAgICAgICAgIG51bWJlcihieXRlczIpOwogICAgICAgICAgcmV0dXJuIHRoaXMueG9mSW50byhuZXcgVWludDhBcnJheShieXRlczIpKTsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIG91dHB1dChvdXQsIHRoaXMpOwogICAgICAgICAgaWYgKHRoaXMuZmluaXNoZWQpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZGlnZXN0KCkgd2FzIGFscmVhZHkgY2FsbGVkIik7CiAgICAgICAgICB0aGlzLndyaXRlSW50byhvdXQpOwogICAgICAgICAgdGhpcy5kZXN0cm95KCk7CiAgICAgICAgICByZXR1cm4gb3V0OwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5kaWdlc3RJbnRvKG5ldyBVaW50OEFycmF5KHRoaXMub3V0cHV0TGVuKSk7CiAgICAgICAgfQogICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICB0aGlzLnN0YXRlLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIGNvbnN0IHsgYmxvY2tMZW4sIHN1ZmZpeCwgb3V0cHV0TGVuLCByb3VuZHMsIGVuYWJsZVhPRiB9ID0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sc2U7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNpZ25hdHVyZS5sZW5ndGg7IGkrKykgewogICAgICBjb25zdCBjaGFyID0gc2lnbmF0dXJlW2ldOwogICAgICBpZiAoWyIoIiwgIikiLCAiLCJdLmluY2x1ZGVzKGNoYXIpKQogICAgICAgIGFjdGl2ZSA9IHRydWU7CiAgICAgIGlmIChjaGFyID09PSAiKCIpCiAgICAgICAgbGV2ZWwrKzsKICAgICAgaWYgKGNoYXIgPT09ICIpIikKICAgICAgICBsZXZlbC0tOwogICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICBjb250aW51ZTsKICAgICAgaWYgKGxldmVsID09PSAwKSB7CiAgICAgICAgaWYgKGNoYXIgPT09ICIgIiAmJiBbImV2ZW50IiwgImZ1bmN0aW9uIiwgIiJdLmluY2x1ZGVzKHJlc3VsdCkpCiAgICAgICAgICByZXN1bHQgPSAiIjsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICAgICAgaWYgKGNoYXIgPT09ICIpIikgewogICAgICAgICAgICB2YWxpZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gIiAiKSB7CiAgICAgICAgaWYgKHNpZ25hdHVyZVtpIC0gMV0gIT09ICIsIiAmJiBjdXJyZW50ICE9PSAiLCIgJiYgY3VycmVudCAhPT0gIiwoIikgewogICAgICAgICAgY3VycmVudCA9ICIiOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICBjdXJyZW50ICs9IGNoYXI7CiAgICB9CiAgICBpZiAoIXZhbGlkKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigiVW5hYmxlIHRvIG5vcm1hbGl6ZSBzaWduY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X2Jhc2UoKTsKICAgICAgSW52YWxpZEFkZHJlc3NFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhZGRyZXNzIH0pIHsKICAgICAgICAgIHN1cGVyKGBBZGRyZXNzICIke2FkZHJlc3N9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIi0gQWRkcmVzcyBtdXN0IGJlIGEgaGV4IHZhbHVlIG9mIDIwIGJ5dGVzICg0MCBoZXggY2hhcmFjdGVycykuIiwKICAgICAgICAgICAgICAiLSBBZGRyZXNzIG11c3QgbWF0Y2ggaXRzIGNoZWNrc3VtIGNvdW50ZXJwYXJ0LiIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBZGRyZXNzRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9scnUuanMKICB2YXIgTHJ1TWFwOwogIHZhciBpbml0X2xydSA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvbHJ1LmpzIigpIHsKICAgICAgTHJ1TWFwID0gY2xhc3MgZXh0ZW5kcyBNYXAgewogICAgICAgIGNvbnN0cnVjdG9yKHNpemUzKSB7CiAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtYXhTaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMubWF4U2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgICBnZXQoa2V5KSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHN1cGVyLmdldChrZXkpOwogICAgICAgICAgaWYgKHN1cGVyLmhhcyhrZXkpICYmIHZhbHVlICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgdGhpcy5kZWxldGUoa2V5KTsKICAgICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0KICAgICAgICBzZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgaWYgKHRoaXMubWF4U2l6ZSAmJiB0aGlzLnNpemUgPiB0aGlzLm1heFNpemUpIHsKICAgICAgICAgICAgY29uc3QgZmlyc3RLZXkgPSB0aGlzLmtleXMoKS5uZXh0KCkudmFsdWU7CiAgICAgICAgICAgIGlmIChmaXJzdEtleSkKICAgICAgICAgICAgICB0aGlzLmRlbGV0ZShmaXJzdEtleSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9hZGRyZXNzL2dldEFkZHJlc3MuanMKICBmdW5jdGlvbiBjaGVja3N1bUFkZHJlc3MoYWRkcmVzc18sIGNoYWluSWQpIHsKICAgIGlmIChjaGVja3N1bUFkZHJlc3NDYWNoZS5oYXMoYCR7YWRkcmVzc199LiR7Y2hhaW5JZH1gKSkKICAgICAgcmV0dXJuIGNoZWNrc3VtQWRkcmVzc0NhY2hlLmdldChgJHthZGRyZXNzX30uJHtjaGFpbklkf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HV0cy5sZW5ndGggPT09IDApCiAgICAgICAgICByZXR1cm4gYWJpSXRlbTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIWFiaUl0ZW0uaW5wdXRzKQogICAgICAgIGNvbnRpbnVlOwogICAgICBpZiAoYWJpSXRlbS5pbnB1dHMubGVuZ3RoID09PSAwKQogICAgICAgIGNvbnRpbnVlOwogICAgICBpZiAoYWJpSXRlbS5pbnB1dHMubGVuZ3RoICE9PSBhcmdzLmxlbmd0aCkKICAgICAgICBjb250aW51ZTsKICAgICAgY29uc3QgbWF0Y2hlZCA9IGFyZ3MuZXZlcnkoKGFyZywgaW5kZXgyKSA9PiB7CiAgICAgICAgY29uc3QgYWJpUGFyYW1ldGVyID0gImlucHV0cyIgaW4gYWJpSXRlbSAmJiBhYmlJdGVtLmlucHV0c1tpbmRleDJdOwogICAgICAgIGlmICghYWJpUGFyYW1ldGVyKQogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIHJldHVybiBpc0FyZ09mVHlwZShhcmcsIGFiaVBhcmFtZXRlcik7CiAgICAgIH0pOwogICAgICBpZiAobWF0Y2hlZCkgewogICAgICAgIGlmIChtYXRjaGVkQWJpSXRlbSAmJiAiaW5wdXRzIiBpbiBtYXRjaGVkQWJpSXRlbSAmJiBtYXRjaGVkQWJpSXRlbS5pbnB1dHMpIHsKICAgICAgICAgIGNvbnN0IGFtYmlndW91c1R5cGVzID0gZ2V0QW1iaWd1b3VzVHlwZXMoYWJpSXRlbS5pbnB1dHMsIG1hdGNoZWRBYmlJdGVtLmlucHV0cywgYXJncyk7CiAgICAgICAgICBpZiAoYW1iaWd1b3VzVHlwZXMpCiAgICAgICAgICAgIHRocm93IG5ldyBBYmlJdGVtQW1iaWd1aXR5RXJyb3IoewogICAgICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICAgICAgdHlwZTogYW1iaWd1b3VzVHlwZXNbMF0KICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGFi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ICAgIDM0OiAiQXR0ZW1wdGVkIHRvIGFjY2VzcyBhIHN0b3JhZ2UgYnl0ZSBhcnJheSB0aGF0IGlzIGluY29ycmVjdGx5IGVuY29kZWQuIiwKICAgICAgICA0OTogIlBlcmZvcm1lZCBgLnBvcCgpYCBvbiBhbiBlbXB0eSBhcnJheSIsCiAgICAgICAgNTA6ICJBcnJheSBpbmRleCBpcyBvdXQgb2YgYm91bmRzLiIsCiAgICAgICAgNjU6ICJBbGxvY2F0ZWQgdG9vIG11Y2ggbWVtb3J5IG9yIGNyZWF0ZWQgYW4gYXJyYXkgd2hpY2ggaXMgdG9vIGxhcmdlLiIsCiAgICAgICAgODE6ICJBdHRlbXB0ZWQgdG8gY2FsbCBhIHplcm8taW5pdGlhbGl6ZWQgdmFyaWFibGUgb2YgaW50ZXJuYWwgZnVuY3Rpb24gdHlwZS4iCiAgICAgIH07CiAgICAgIHNvbGlkaXR5RXJyb3IgPSB7CiAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICB7CiAgICAgICAgICAgIG5hbWU6ICJtZXNzYWdlIiwKICAgICAgICAgICAgdHlwZTogInN0cmluZyIKICAgICAgICAgIH0KICAgICAgICBdLAogICAgICAgIG5hbWU6ICJFcnJvciIsCiAgICAgICAgdHlwZTogImVycm9yIgogICAgICB9OwogICAgICBzb2xpZGl0eVBhbmljID0gewogICAgICAgIGlucHV0czogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAicmVhc29uIiwKICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBuYW1lOiAiUGFuaWMiLAogICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2Vycm9ycy9jdXJzb3IuanMKICB2YXIgTmVnYXRpdmVPZmZzZXRFcnJvciw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gdGhpcy5wb3NpdGlvbiAtIG9mZnNldDsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24pOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiA9IHBvc2l0aW9uOwogICAgICAgIH0sCiAgICAgICAgZ2V0UmVhZENvdW50KHBvc2l0aW9uKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5wb3NpdGlvblJlYWRDb3VudC5nZXQocG9zaXRpb24gfHwgdGhpcy5wb3NpdGlvbikgfHwgMDsKICAgICAgICB9LAogICAgICAgIGluY3JlbWVudFBvc2l0aW9uKG9mZnNldCkgewogICAgICAgICAgaWYgKG9mZnNldCA8IDApCiAgICAgICAgICAgIHRocm93IG5ldyBOZWdhdGl2ZU9mZnNldEVycm9yKHsgb2Zmc2V0IH0pOwogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uICsgb2Zmc2V0OwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0Qnl0ZShwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzW3Bvc2l0aW9uXTsKICAgICAgICB9LAogICAgICAgIGluc3BlY3RCeXRlcyhsZW5ndGgsIHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyBsZW5ndGggLSAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLnN1YmFycmF5KHBvc2l0aW9uLCBwb3NpdGlvbiArIGxlbmd0aCk7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDgocG9zaXRpb25fKSB7CiAgICAgICAgICBjb25zdCBwb3NpdGlvbiA9IHBvc2l0aW9uXyA/PyB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICByZXR1cm4gdGhpcy5ieXRlc1twb3NpdGlvbl07CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDE2KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmRhdGFWaWV3LmdldFVpbnQxNihwb3NpdGlvbik7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDI0KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAyKTsKICAgICAgICAgIHJldHVybiAodGhpcy5kYXRhVmlldy5nZXRVaW50MTYocG9zaXRpb24pIDw8IDgpICsgdGhpcy5kYXRhVmlldy5nZXRVaW50OChwb3NpdGlvbiArIDIpOwogICAgICAgIH0sCiAgICAgICAgaW5zcGVjdFVpbnQzMihwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uICsgMyk7CiAgICAgICAgICByZXR1cm4gdGhpcy5kYXRhVmlldy5nZXRVaW50MzIocG9zaXRpb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ICAgICAgIHRoaXMuZGF0YVZpZXcuc2V0VWludDgodGhpcy5wb3NpdGlvbiArIDIsIHZhbHVlICYgfjQyOTQ5NjcwNDApOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAzOwogICAgICAgIH0sCiAgICAgICAgcHVzaFVpbnQzMih2YWx1ZSkgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9uICsgMyk7CiAgICAgICAgICB0aGlzLmRhdGFWaWV3LnNldFVpbnQzMih0aGlzLnBvc2l0aW9uLCB2YWx1ZSk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDQ7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZSgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RCeXRlKCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uKys7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZXMobGVuZ3RoLCBzaXplMykgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdEJ5dGVzKGxlbmd0aCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IHNpemUzID8/IGxlbmd0aDsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50OCgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50OCgpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAxOwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgcmVhZFVpbnQxNigpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50MTYoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb24gKz0gMjsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50MjQoKSB7CiAgICAgICAgICB0aGlzLmFzc2VydFJlYWRMaW1pdCgpOwogICAgICAgICAgdGhpcy5fdG91Y2goKTsKICAgICAgICAgIGNvbnN0IHZhbHVlID0gdGhpcy5pbnNwZWN0VWludDI0KCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDM7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkVWludDMyKCkgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdFVpbnQzMigpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSA0OwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgZ2V0IHJlbWFpbmluZygpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmxlbmd0aCAtIHRoaXMucG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBzZXRQb3NpdGlvbihwb3NpdGlvbikgewogICAgICAgICAgY29uc3Qgb2xkUG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgICByZXR1cm4gKCkgPT4gdGhpcy5wb3NpdGlvbiA9IG9sZFBvc2l0aW9uOwogICAgICAgIH0sCiAgICAgICAgX3RvdWNoKCkgewogICAgICAgICAgaWYgKHRoaXMucmVjdXJzaXZlUmVhZExpbWl0ID09PSBOdW1iZXIuUE9TSVRJVkVfSU5GSU5JVFkpCiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNvbnN0IGNvdW50ID0gdGhpcy5nZXRSZWFkQ291bnQoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb25SZWFkQ291bnQuc2V0KHRoaXMucG9zaXRpb24sIGNvdW50ICsgMSk7CiAgICAgICAgICBpZiAoY291bnQgPiAwKQogICAgICAgICAgICB0aGlzLnJlY3Vyc2l2ZVJlYWRDb3VudCsrOwogICAgICAgIH0KICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL2VuY29kaW5nL2Zyb21CeXRlcy5qcwogIGZ1bmN0aW9uIGZyb21CeXRlcyhieXRlczIsIHRvT3JPcHRzKSB7CiAgICBjb25zdCBvcHRzID0gdHlwZW9mIHRvT3JPcHRzID09PSAic3RyaW5nIiA/IHsgdG86IHRvT3JPcHRzIH0gOiB0b09yT3B0czsKICAgIGNvbnN0IHRvID0gb3B0cy50bzsKICAgIGlmICh0byA9PT0gIm51bWJlciIpCiAgICAgIHJldHVybiBieXRlc1RvTnVtYmVyKGJ5dGVzMiwgb3B0cyk7CiAgICBpZiAodG8gPT09ICJiaWdpbnQiKQogICAgICByZXR1cm4gYnl0ZXNUb0JpZ0ludChieXRlczIsIG9wdHMpOwogICAgaWYgKHRvID09PSAiYm9vbGVhbiIpCiAgICAgIHJldHVybiBieXRlc1RvQm9vbChieXRlczIsIG9wdHMpOwogICAgaWYgKHRvID09PSAic3RyaW5nIikKICAgICAgcmV0dXJuIGJ5dGVzVG9TdHJ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RydWN0b3IoeyBhZGRyZXNzIH0pIHsKICAgICAgICAgIHN1cGVyKGBTdGF0ZSBmb3IgYWNjb3VudCAiJHthZGRyZXNzfSIgaXMgc2V0IG11bHRpcGxlIHRpbWVzLmAsIHsKICAgICAgICAgICAgbmFtZTogIkFjY291bnRTdGF0ZUNvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoInN0YXRlIGFuZCBzdGF0ZURpZmYgYXJlIHNldCBvbiB0aGUgc2FtZSBhY2NvdW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIlN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9lcnJvcnMvdHJhbnNhY3Rpb24uanMKICBmdW5jdGlvbiBwcmV0dHlQcmludChhcmdzKSB7CiAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoYXJncykubWFwKChba2V5LCB2YWx1ZV0pID0+IHsKICAgICAgaWYgKHZhbHVlID09PSB2b2lkIDAgfHwgdmFsdWUgPT09IGZhbHNlKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gW2tleSwgdmFsdWVdOwogICAgfSkuZmlsdGVyKEJvb2xlYW4pOwogICAgY29uc3QgbWF4TGVuZ3RoID0gZW50cmllcy5yZWR1Y2UoKGFjYywgW2tleV0pID0+IE1hdGgubWF4KGFjYywga2V5Lmxlbmd0aCksIDApOwogICAgcmV0dXJuIGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV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YXNgIGZvciBFSVAtMTU1OSBjb21wYXRpYmxlIG5ldHdvcmtzLCBhbmQgYGdhc1ByaWNlYCBmb3Igb3RoZXJzLiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgeyBuYW1lOiAiRmVlQ29uZmxpY3RFcnJvciIgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkTGVnYWN5VkVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHYgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgXGB2XGAgdmFsdWUgIiR7dn0iLiBFeHBlY3RlZCAyNyBvciAyOC5gLCB7CiAgICAgICAgICAgIG5hbWU6ICJJbnZhbGlkTGVnYWN5VkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXphYmxlVHJhbnNhY3Rpb25FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0cmFuc2FjdGlvbiB9KSB7CiAgICAgICAgICBzdXBlcigiQ2Fubm90IGluZmVyIGEgdHJhbnNhY3Rpb24gdHlwZSBmcm9tIHByb3ZpZGVkIHRyYW5zYWN0aW9uLiIsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIlByb3ZpZGVkIFRyYW5zYWN0aW9uOiIsCiAgICAgICAgICAgICAgInsiLAogICAgICAgICAgICAgIHByZXR0eVByaW50KHRyYW5zYWN0aW9uKSwKICAgICAgICAgICAgICAifSIsCiAgICAgICAgICAgICAgIiIsCiAgICAgICAgICAgICAgIlRvIGluZmVyIHRoZSB0eXBlLCBlaXRoZXIgcHJvdmlkZToiLAogICAgICAgICAgICAgICItIGEgYHR5cGVgIHRvIHRoZSBUcmFuc2FjdGlvbiwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC0xNTU5IFRyYW5zYWN0aW9uIHdpdGggYG1heEZlZVBlckdhc2AsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtMjkzMCBUcmFuc2FjdGlvbiB3aXRoIGBnYXNQcmljZWAgJiBgYWNjZXNzTGlzdGAsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtNDg0NCBUcmFuc2FjdGlvbiB3aXRoIGBibG9ic2AsIGBibG9iVmVyc2lvbmVkSGFzaGVzYCwgYHNpZGVjYXJzYCwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC03NzAyIFRyYW5zYWN0aW9uIHdpdGggYGF1dGhvcml6YXRpb25MaXN0YCwgb3IiLAogICAgICAgICAgICAgICItIGEgTGVnYWN5IFRyYW5zYWN0aW9uIHdpdGggYGdhc1ByaWNlYCIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemFibGVUcmFuc2FjdGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uVHlwZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHNlcmlhbGl6ZWRUeXBlIH0pIHsKICAgICAgICAgIHN1cGVyKGBTZXJpYWxpemVkIHRyYW5zYWN0aW9uIHR5cGUgIiR7c2VyaWFsaXplZFR5cGV9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25UeXBlIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlcmlhbGl6ZWRUeXBlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmx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2VzOiBbCiAgICAgICAgICAgICAgLi4uY2F1c2UubWV0YU1lc3NhZ2VzID8gWy4uLmNhdXNlLm1ldGFNZXNzYWdlcywgIiAiXSA6IFtdLAogICAgICAgICAgICAgICJSZXF1ZXN0IEFyZ3VtZW50czoiLAogICAgICAgICAgICAgIHByZXR0eUFyZ3MKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJUcmFuc2FjdGlvbkV4ZWN1dGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuY2F1c2UgPSBjYXVzZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFRyYW5zYWN0aW9uTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBibG9ja0hhc2gsIGJsb2NrTnVtYmVyLCBibG9ja1RhZywgaGFzaDogaGFzaDMsIGluZGV4OiBpbmRleDIgfSkgewogICAgICAgICAgbGV0IGlkZW50aWZpZXIgPSAiVHJhbnNhY3Rpb24iOwogICAgICAgICAgaWYgKGJsb2NrVGFnICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIHRpbWUgIiR7YmxvY2tUYWd9IiBhdCBpbmRleCAiJHtpbmRleDJ9ImA7CiAgICAgICAgICBpZiAoYmxvY2tIYXNoICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gY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gICAgICAgbmFtZTogIkNhbGxFeGVjdXRpb25FcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjYXVzZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uRXhlY3V0aW9uRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlLCB7IGFiaTogYWJpMiwgYXJncywgY29udHJhY3RBZGRyZXNzLCBkb2NzUGF0aDogZG9jc1BhdGg5LCBmdW5jdGlvbk5hbWUsIHNlbmRlciB9KSB7CiAgICAgICAgICBjb25zdCBhYmlJdGVtID0gZ2V0QWJpSXRlbSh7IGFiaTogYWJpMiwgYXJncywgbmFtZTogZnVuY3Rpb25OYW1lIH0pOwogICAgICAgICAgY29uc3QgZm9ybWF0dGVkQXJncyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtV2l0aEFyZ3MoewogICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICBhcmdzLAogICAgICAgICAgICBpbmNsdWRlRnVuY3Rpb25OYW1lOiBmYWxzZSwKICAgICAgICAgICAgaW5jbHVkZU5hbWU6IGZhbHNlCiAgICAgICAgICB9KSA6IHZvaWQgMDsKICAgICAgICAgIGNvbnN0IGZ1bmN0aW9uV2l0aFBhcmFtcyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtMihhYmlJdGVtLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pIDogdm9pZCAwOwogICAgICAgICAgY29uc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hYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiYXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29udHJhY3RBZGRyZXNzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZm9ybWF0dGVkQXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImZ1bmN0aW9uTmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlbmRlciIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaSA9IGFiaTI7CiAgICAgICAgICB0aGlzLmFyZ3MgPSBhcmdzOwogICAgICAgICAgdGhpcy5jYXVzZSA9IGNhdXNlOwogICAgICAgICAgdGhpcy5jb250cmFjdEFkZHJlc3MgPSBjb250cmFjdEFkZHJlc3M7CiAgICAgICAgICB0aGlzLmZ1bmN0aW9uTmFtZSA9IGZ1bmN0aW9uTmFtZTsKICAgICAgICAgIHRoaXMuc2VuZGVyID0gc2VuZGVyOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYWJpOiBhYmkyLCBkYXRhLCBmdW5jdGlvbk5hbWUsIG1lc3NhZ2UgfSkgewogICAgICAgICAgbGV0IGNhdXNlOwogICAgICAgICAgbGV0IGRlY29kZWREYXRhID0gdm9pZCAwOwogICAgICAgICAgbGV0IG1ldGFNZXNzYWdlczsKICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICBpZiAoZGF0YSAmJiBkYXRhICE9PSAiMHgiKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZGVjb2RlZERhdGEgPSBkZWNvZGVFcnJvclJlc3VsdCh7IGFiaTogYWJpMiwgZGF0YSB9KTsKICAgICAgICAgICAgICBjb25zdCB7IGFiaUl0ZW0sIGVycm9yTmFtZSwgYXJnczogZXJyb3JBcmdzIH0gPSBkZWNvZGVkRGF0YTsKICAgICAgICAgICAgICBpZiAoZXJyb3JOYW1lID09PSAiRXJyb3IiKSB7CiAgICAgICAgICAgICAgICByZWFzb24gPSBlcnJvckFyZ3NbMF07CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnJvck5hbWUgPT09ICJQYW5pYyIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IFtmaXJzdEFyZ10gPSBlcnJvckFyZ3M7CiAgICAgICAgICAgICAgICByZWFzb24gPSBwYW5pY1JlYXNvbnNbZmlyc3RBcmddOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb25zdCBlcnJvcldpdGhQYXJhbXMgPSBhYmlJdGVtID8gZm9ybWF0QWJpSXRlbTIoYWJpSXRlbSwgeyBpbmNsdWRlTmFtZTogdHJ1ZSB9KSA6IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZEFyZ3MgPSBhYmlJdGVtICYmIGVycm9yQXJncyA/IGZvcm1hdEFiaUl0ZW1XaXRoQXJncyh7CiAgICAgICAgICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICAgICAgICAgIGFyZ3M6IGVycm9yQXJncywKICAgICAgICAgICAgICAgICAgaW5jbHVkZUZ1bmN0aW9uTmFtZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVOYW1lOiBmYWxzZQogICAgICAgICAgICAgICAgfSkgOiB2b2lkIDA7CiAgICAgICAgICAgICAgICBtZXRhTWVzc2FnZXMgPSBbCiAgICAgICAgICAgICAgICAgIGVycm9yV2l0aFBhcmFtcyA/IGBFcnJvcjogJHtlcnJvcldpdGhQYXJhbXN9YCA6ICIiLAogICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRBcmdzICYmIGZvcm1hdHRlZEFyZ3MgIT09ICIoKSIgPyBgICAgICAgICR7Wy4uLkFycmF5KGVycm9yTmFtZT8ubGVuZ3RoID8/IDApLmtleXMoKV0ubWFwKCgpID0+ICIgIikuam9pbigiIil9JHtmb3JtYXR0ZWRBcmdzfWAgOiAiIgogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIGNhdXNlID0gZXJyOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKG1lc3NhZ2UpCiAgICAgICAgICAgIHJlYXNvbiA9IG1lc3NhZ2U7CiAgICAgICAgICBsZXQgc2lnbmF0dXJlOwogICAgICAgICAgaWYgKGNhdXNlIGluc3RhbmNlb2YgQWJpRXJyb3JTaWduYXR1cmVOb3RGb3VuZEVycm9yKSB7CiAgICAgICAgICAgIHNpZ25hdHVyZSA9IGNhdXNlLnNpZ25hdHVyZTsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzID0gWwogICAgICAgICAgICAgIGBVbmFibGUgdG8gZGVjb2RlIHNpZ25hdHVyZSAiJHtzaWduYXR1cmV9IiBhcyBpdCB3YXMgbm90IGZvdW5kIG9uIHRoZSBwcm92aWRlZCBBQkkuYCwKICAgICAgICAgICAgICAiTWFrZSBzdXJlIHlvdSBhcmUgdXNpbmcgdGhlIGNvcnJlY3QgQUJJIGFuZCB0aGF0IHRoZSBlcnJvciBleGlzdHMgb24gaXQuIiwKICAgICAgICAgICAgICBgWW91IGNhbiBsb29rIHVwIHRoZSBkZWNvZGVkIHNpZ25hdHVyZSBoZXJlOiBodHRwczovL29wZW5jaGFpbi54eXovc2lnbmF0dXJlcz9xdWVyeT0ke3NpZ25hdHVyZX0uYAogICAgICAgICAgICBdOwogICAgICAgICAgfQogICAgICAgICAgc3VwZXIocmVhc29uICYmIHJlYXNvbiAhPT0gImV4ZWN1dGlvbiByZXZlcnRlZCIgfHwgc2lnbmF0dXJlID8gWwogICAgICAgICAgICBgVGhlIGNvbnRyYWN0IGZ1bmN0aW9uICIke2Z1bmN0aW9uTmFtZX0iIHJldmVydGVkIHdpdGggdGhlIGZvbGxvd2luZyAke3NpZ25hdHVyZSA/ICJzaWduYXR1cmUiIDogInJlYXNvbiJ9OmAsCiAgICAgICAgICAgIHJlYXNvbiB8fCBzaWduYXR1cmUKICAgICAgICAgIF0uam9pbigiXG4iKSA6IGBUaGUgY29udHJhY3QgZnVuY3Rpb24gIiR7ZnVuY3Rpb25OYW1lfSIgcmV2ZXJ0ZWQuYCwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzLAogICAgICAgICAgICBuYW1lOiAiQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZGF0YSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInJlYXNvbiIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hdHVyZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmRhdGEgPSBkZWNvZGVkRGF0YTsKICAgICAgICAgIHRoaXMucmVhc29uID0gcmVhc29uOwogICAgICAgICAgdGhpcy5zaWduYXR1cmUgPSBzaWduYXR1cmU7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uWmVyb0RhdGFFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBmdW5jdGlvbk5hbWUgfSkgewogICAgICAgICAgc3VwZXIoYFRoZSBjb250cmFjdCBmdW5jdGlvbiAiJHtmdW5jdGlvbk5hbWV9IiByZXR1cm5lZCBubyBkYXRhICgiMHgiKS5gLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgICJUaGlzIGNvdWxkIGJlIGR1ZSB0byBhbnkgb2YgdGhlIGZvbGxvd2luZzoiLAogICAgICAgICAgICAgIGAgIC0gVGhlIGNvbnRyYWN0IGRvZXMgbm90IGhhdmUgdGhlIGZ1bmN0aW9uICIke2Z1bmN0aW9uTmFtZX0iLGAsCiAgICAgICAgICAgICAgIiAgLSBUaGUgcGFyYW1ldGVycyBwYXNzZWQgdG8gdGhlIGNvbnRyYWN0IGZ1bmN0aW9uIG1heSBiZSBpbnZhbGlkLCBvciIsCiAgICAgICAgICAgICAgIiAgLSBUaGUgYWRkcmVzcyBpcyBub3QgYSBjb250cmFjdC4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb250cmFjdEZ1bmN0aW9uWmVyb0RhdGFFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ291bnRlcmZhY3R1YWxEZXBsb3ltZW50RmFpbGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgZmFjdG9yeSB9KSB7CiAgICAgICAgICBzdXBlcihgRGVwbG95bWVudCBmb3IgY291bnRlcmZhY3R1YWwgY29udHJhY3QgY2FsbCBmYWlsZWQke2ZhY3RvcnkgPyBgIGZvciBmYWN0b3J5ICIke2ZhY3Rvcnl9Ii5gIDogIiJ9YCwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAiUGxlYXNlIGVuc3VyZToiLAogICAgICAgICAgICAgICItIFRoZSBgZmFjdG9yeWAgaXMgYSB2YWxpZCBjb250cmFjdCBkZXBsb3ltZW50IGZhY3RvcnkgKGllLiBDcmVhdGUyIEZhY3RvcnksIEVSQy00MzM3IEZhY3RvcnksIGV0YykuIiwKICAgICAgICAgICAgICAiLSBUaGUgYGZhY3RvcnlEYXRhYCBpcyBhIHZhbGlkIGVuY29kZWQgZnVuY3Rpb24gY2FsbCBmb3IgY29udHJhY3QgZGVwbG95bWVudCBmdW5jdGlvbiBvbiB0aGUgZmFjdG9yeS4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb3VudGVyZmFjdHVhbERlcGxveW1lbnRGYWlsZWRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgUmF3Q29udHJhY3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBkYXRhLCBtZXNzYWdlIH0pIHsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UgfHwgIiIsIHsgbmFtZTogIlJhd0NvbnRyYWN0RXJyb3IiIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjb2RlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgI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gICBkZXRhaWxzLAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBzdGF0dXMgJiYgYFN0YXR1czogJHtzdGF0dXN9YCwKICAgICAgICAgICAgICBgVVJMOiAke2dldFVybCh1cmwpfWAsCiAgICAgICAgICAgICAgYm9keSAmJiBgUmVxdWVzdCBib2R5OiAke3N0cmluZ2lmeShib2R5KX1gCiAgICAgICAgICAgIF0uZmlsdGVyKEJvb2xlYW4pLAogICAgICAgICAgICBuYW1lOiAiSHR0cFJlcXVlc3RFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJib2R5IiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiaGVhZGVycyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInN0YXR1cyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInVybCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmJvZHkgPSBib2R5OwogICAgICAgICAgdGhpcy5oZWFkZXJzID0gaGVhZGVyczsKICAgICAgICAgIHRoaXMuc3RhdHVzID0gc3RhdHVzOwogICAgICAgICAgdGhpcy51cmwgPSB1cmw7CiAgICAgICAgfQogICAgICB9OwogICAgICBXZWJTb2NrZXRSZXF1ZXN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYm9keSwgY2F1c2UsIGRldGFpbHMsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiV2ViU29ja2V0IHJlcXVlc3QgZmFpbGVkLiIsIHsKICAgICAgICAgICAgY2F1c2UsCiAgICAgICAgICAgIGRldGFpbHMsCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBVUkw6ICR7Z2V0VXJsKHVybCl9YCwKICAgICAgICAgICAgICBib2R5ICYmIGBSZXF1ZXN0IGJvZHk6ICR7c3RyaW5naWZ5KGJvZHkpfWAKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJXZWJTb2NrZXRSZXF1ZXN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFJwY1JlcXVlc3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBib2R5LCBlcnJvciwgdXJsIH0pIHsKICAgICAgICAgIHN1cGVyKCJSUEMgUmVxdWVzdCBmYWlsZWQuIiwgewogICAgICAgICAgICBjYXVzZTogZXJyb3IsCiAgICAgICAgICAgIGRldGFpbHM6IGVycm9yLm1lc3NhZ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gICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTWV0aG9kTm90Rm91bmRScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMQogICAgICB9KTsKICAgICAgSW52YWxpZFBhcmFtc1JwY0Vycm9yID0gY2xhc3MgX0ludmFsaWRQYXJhbXNScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludmFsaWRQYXJhbXNScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiBbCiAgICAgICAgICAgICAgIkludmFsaWQgcGFyYW1ldGVycyB3ZXJlIHByb3ZpZGVkIHRvIHRoZSBSUEMgbWV0aG9kLiIsCiAgICAgICAgICAgICAgIkRvdWJsZSBjaGVjayB5b3UgaGF2ZSBwcm92aWRlZCB0aGUgY29ycmVjdCBwYXJhbWV0ZXJzLiIKICAgICAgICAgICAgXS5qb2luKCJcbiIpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnZhbGlkUGFyYW1zUnBjRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiAtMzI2MDIKICAgICAgfSk7CiAgICAgIEludGVybmFsUnBjRXJyb3IgPSBjbGFzcyBfSW50ZXJuYWxScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludGVybmFsUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkludGVybmFsUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBpbnRlcm5hbCBlcnJvciB3YXMgcmVjZWl2ZWQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoSW50ZXJuYWxScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMwogICAgICB9KTsKICAgICAgSW52YWxpZElucHV0UnBjRXJyb3IgPSBjbGFzcyBfSW52YWxpZElucHV0UnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9JbnZhbGlkSW5wdXRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZElucHV0UnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IFsKICAgICAgICAgICAgICAiTWlzc2luZyBvciBpbnZhbGlkIHBhcmFtZXRlcnMuIiwKICAgICAgICAgICAgICAiRG91YmxlIGNoZWNrIHlvdSBoYXZlIHByb3ZpZGVkIHRoZSBjb3JyZWN0IHBhcmFtZXRlcnMuIgogICAgICAgICAgICBdLmpvaW4oIlxuIikKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEludmFsaWRJbnB1dFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyZTMKICAgICAgfSk7CiAgICAgIFJlc291cmNlTm90Rm91bmRScGNFcnJvciA9IGNsYXNzIF9SZXNvdXJjZU5vdEZvdW5kUnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9SZXNvdXJjZU5vdEZvdW5kUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlJlc291cmNlTm90Rm91bmRScGNFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlJlcXVlc3RlZCByZXNvdXJjZSBub3QgZm91bmQuIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyMDAxCiAgICAgIH0pOwogICAgICBSZXNvdX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cihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0xpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiTGltaXRFeGNlZWRlZFJwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiAiUmVxdWVzdCBleGNlZWRzIGRlZmluZWQgbGltaXQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTGltaXRFeGNlZWRlZFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyMDA1CiAgICAgIH0pOwogICAgICBKc29uUnBjVmVyc2lvblVuc3VwcG9ydGVkRXJyb3IgPSBjbGFzcyBfSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yIGV4dGVuZHMgUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlKSB7CiAgICAgICAgICBzdXBlcihjYXVzZSwgewogICAgICAgICAgICBjb2RlOiBfSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGUsCiAgICAgICAgICAgIG5hbWU6ICJKc29uUnBjVmVyc2lvblVuc3VwcG9ydGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJWZXJzaW9uIG9mIEpTT04tUlBDIHByb3RvY29sIGlzIG5vdCBzdXBwb3J0ZWQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVl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25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IDQyMDAKICAgICAgfSk7CiAgICAgIFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IgPSBjbGFzcyBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciBleHRlbmRzIFByb3ZpZGVyUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlKSB7CiAgICAgICAgICBzdXBlcihjYXVzZSwgewogICAgICAgICAgICBjb2RlOiBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlRoZSBQcm92aWRlciBpcyBkaXNjb25uZWN0ZWQgZnJvbSBhbGwgY2hhaW5zLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAwCiAgICAgIH0pOwogICAgICBDaGFpbkRpc2Nvbm5lY3RlZEVycm9yID0gY2xhc3MgX0NoYWluRGlzY29ubmVjdGVkRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0NoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkNoYWluRGlzY29ubmVjdGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJUaGUgUHJvdmlkZXIgaXMgbm90IGNvbm5lY3RlZCB0byB0aGUgcmVxdWVzdGVkIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KENoYWluRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAxCiAgICAgIH0pOwogICAgICBTd2l0Y2hDaGFpbkVycm9yID0gY2xhc3MgX1N3aXRjaENoYWluRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX1N3aXRjaENoYWluRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlN3aXRjaENoYWluRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBlcnJvciBvY2N1cnJlZCB3aGVuIGF0dGVtcHRpbmcgdG8gc3dpdGNoIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFN3aXRjaENoYWluRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAyCiAgICAgIH0pOwogICAgICBVbmtub3duUnBjRXJyb3IgPSBjbGFzcyBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICA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MiKCkgewogICAgICBpbml0X2Fzc2VydCgpOwogICAgICBpbml0X3V0aWxzMigpOwogICAgICBDaGkgPSAoYSwgYiwgYykgPT4gYSAmIGIgXiB+YSAmIGM7CiAgICAgIE1haiA9IChhLCBiLCBjKSA9PiBhICYgYiBeIGEgJiBjIF4gYiAmIGM7CiAgICAgIEhhc2hNRCA9IGNsYXNzIGV4dGVuZHMgSGFzaCB7CiAgICAgICAgY29uc3RydWN0b3IoYmxvY2tMZW4sIG91dHB1dExlbiwgcGFkT2Zmc2V0LCBpc0xFMikgewogICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgIHRoaXMuYmxvY2tMZW4gPSBibG9ja0xlbjsKICAgICAgICAgIHRoaXMub3V0cHV0TGVuID0gb3V0cHV0TGVuOwogICAgICAgICAgdGhpcy5wYWRPZmZzZXQgPSBwYWRPZmZzZXQ7CiAgICAgICAgICB0aGlzLmlzTEUgPSBpc0xFMjsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSBmYWxzZTsKICAgICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICAgIHRoaXMucG9zID0gMDsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICB0aGlzLmJ1ZmZlciA9IG5ldyBVaW50OEFycmF5KGJsb2NrTGVuKTsKICAgICAgICAgIHRoaXMudmlldyA9IGNyZWF0ZVZpZXcodGhpcy5idWZmZXIpOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyB2aWV3LCBidWZmZXI6IGJ1ZmZlcjIsIGJsb2NrTGVuIH0gPSB0aGlzOwogICAgICAgICAgZGF0YSA9IHRvQnl0ZXMyKGRhdGEpOwogICAgICAgICAgY29uc3QgbGVuID0gZGF0YS5sZW5ndGg7CiAgICAgICAgICBmb3IgKGxldCBwb3MgPSAwOyBwb3MgPCBsZW47ICkgewogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvcywgbGVuIC0gcG9zKTsKICAgICAgICAgICAgaWYgKHRha2UgPT09IGJsb2NrTGVuKSB7CiAgICAgICAgICAgICAgY29uc3QgZGF0YVZpZXcgPSBjcmVhdGVWaWV3KGRhdGEpOwogICAgICAgICAgICAgIGZvciAoOyBibG9ja0xlbiA8PSBsZW4gLSBwb3M7IHBvcyArPSBibG9ja0xlbikKICAgICAgICAgICAgICAgIHRoaXMucHJvY2VzcyhkYXRhVmlldywgcG9zKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIyLnNldChkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgdGFrZSksIHRoaXMucG9zKTsKICAgICAgICAgICAgdGhpcy5wb3MgKz0gdGFrZTsKICAgICAgICAgICAgcG9zICs9IHRha2U7CiAgICAgICAgICAgIGlmICh0aGlzLnBvcyA9PT0gYmxvY2tMZW4pIHsKICAgICAgICAgICAgICB0aGlzLnByb2Nlc3ModmlldywgMCk7CiAgICAgICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmxlbmd0aCArPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIHRoaXMucm91bmRDbGVhbigpOwogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdEludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcyk7CiAgICAgICAgICBvdXRwdXQob3V0LCB0aGlzKTsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSB0cnVlOwogICAgICAgICAgY29uc3QgeyBidWZmZXI6IGJ1ZmZlcjIsIHZpZXcsIGJsb2NrTGVuLCBpc0xFOiBpc0xFMiB9ID0gdGhpczsKICAgICAgICAgIGxldCB7IHBvcyB9ID0gdGhpczsKICAgICAgICAgIGJ1ZmZlcjJbcG9zKytdID0gMTI4OwogICAgICAgICAgdGhpcy5idWZmZXIuc3ViYXJyYXkocG9zKS5maWxsKDApOwogICAgICAgICAgaWYgKHRoaXMucGFkT2Zmc2V0ID4gYmxvY2tMZW4gLSBwb3MpIHsKICAgICAgICAgICAgdGhpcy5wcm9jZXNzKHZpZXcsIDApOwogICAgICAgICAgICBwb3MgPSAwOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChsZXQgaSA9IHBvczsgaSA8IGJsb2NrTGVuOyBpKyspCiAgICAgICAgICAgIGJ1ZmZlcjJbaV0gPSAwOwogICAgICAgICAgc2V0QmlnVWludDY0KHZpZXcsIGJsb2NrTGVuIC0gOCwgQmlnSW50KHRoaXMubGVuZ3RoICogOCksIGlzTEUyKTsKICAgICAgICAgIHRoaXMucHJvY2Vzcyh2aWV3LCAwKTsKICAgICAgICAgIGNvbnN0IG92aWV3ID0gY3JlYXRlVmlldyhvdXQpOwogICAgICAgICAgY29uc3QgbGVuID0gdGhpcy5vdXRwdXRMZW47CiAgICAgICAgICBpZiAobGVuICUgNCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIHNob3VsZCBiZSBhbGlnbmVkIHRvIDMyYml0Iik7CiAgICAgICAgICBjb25zdCBvdXRMZW4gPSBsZW4gLyA0OwogICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLmdldCgpOwogICAgICAgICAgaWYgKG91dExlbiA+IHN0YXRlLmxlbmd0aCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIGJpZ2dlciB0aGFuIHN0YXRlIik7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG91dExlbjsgaSsrKQogICAgICAgICAgICBvdmlldy5zZXRVaW50MzIoNCAqIGksIHN0YXRlW2ldLCBpc0xFMik7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdCgpIHsKICAgICAgICAgIGNvbnN0IHsgY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9tb2R1bGVzL0Bub2JsZS9oYXNoZXMvZXNtL3NoYTI1Ni5qcyIoKSB7CiAgICAgIGluaXRfbWQoKTsKICAgICAgaW5pdF91dGlsczIoKTsKICAgICAgU0hBMjU2X0sgPSAvKiBAX19QVVJFX18gKi8gbmV3IFVpbnQzMkFycmF5KFsKICAgICAgICAxMTE2MzUyNDA4LAogICAgICAgIDE4OTk0NDc0NDEsCiAgICAgICAgMzA0OTMyMzQ3MSwKICAgICAgICAzOTIxMDA5NTczLAogICAgICAgIDk2MTk4NzE2MywKICAgICAgICAxNTA4OTcwOTkzLAogICAgICAgIDI0NTM2MzU3NDgsCiAgICAgICAgMjg3MDc2MzIyMSwKICAgICAgICAzNjI0MzgxMDgwLAogICAgICAgIDMxMDU5ODQwMSwKICAgICAgICA2MDcyMjUyNzgsCiAgICAgICAgMTQyNjg4MTk4NywKICAgICAgICAxOTI1MDc4Mzg4LAogICAgICAgIDIxNjIwNzgyMDYsCiAgICAgICAgMjYxNDg4ODEwMywKICAgICAgICAzMjQ4MjIyNTgwLAogICAgICAgIDM4MzUzOTA0MDEsCiAgICAgICAgNDAyMjIyNDc3NCwKICAgICAgICAyNjQzNDcwNzgsCiAgICAgICAgNjA0ODA3NjI4LAogICAgICAgIDc3MDI1NTk4MywKICAgICAgICAxMjQ5MTUwMTIyLAogICAgICAgIDE1NTUwODE2OTIsCiAgICAgICAgMTk5NjA2NDk4NiwKICAgICAgICAyNTU0MjIwODgyLAogICAgICAgIDI4MjE4MzQzNDksCiAgICAgICAgMjk1Mjk5NjgwOCwKICAgICAgICAzMjEwMzEzNjcxLAogICAgICAgIDMzMzY1NzE4OTEsCiAgICAgICAgMzU4NDUyODcxMSwKICAgICAgICAxMTM5MjY5OTMsCiAgICAgICAgMzM4MjQxODk1LAogICAgICAgIDY2NjMwNzIwNSwKICAgICAgICA3NzM1Mjk5MTIsCiAgICAgICAgMTI5NDc1NzM3MiwKICAgICAgICAxMzk2MTgyMjkxLAogICAgICAgIDE2OTUxODM3MDAsCiAgICAgICAgMTk4NjY2MTA1MSwKICAgICAgICAyMTc3MDI2MzUwLAogICAgICAgIDI0NTY5NTYwMzcsCiAgICAgICAgMjczMDQ4NTkyMSwKICAgICAgICAyODIwMzAyNDExLAogICAgICAgIDMyNTk3MzA4MDAsCiAgICAgICAgMzM0NTc2NDc3MSwKICAgICAgICAzNTE2MDY1ODE3LAogICAgICAgIDM2MDAzNTI4MDQsCiAgICAgICAgNDA5NDU3MTkwOSwKICAgICAgICAyNzU0MjMzNDQsCiAgICAgICAgNDMwMjI3NzM0LAogICAgICAgIDUwNjk0ODYxNiwKICAgICAgICA2NTkwNjA1NTYsCiAgICAgICAgODgzOTk3ODc3LAogICAgICAgIDk1ODEzOTU3MSwKICAgICAgICAxMzIyODIyMjE4LAogICAgICAgIDE1MzcwMDIwNjMsCiAgICAgICAgMTc0Nzg3Mzc3OSwKICAgICAgICAxOTU1NTYyMjIyLAogICAgICAgIDIwMjQxMDQ4MTUsCiAgICAgICAgMjIyNzczMDQ1MiwKICAgICAgICAyMzYxODUyNDI0LAogICAgICAgIDI0Mjg0MzY0NzQsCiAgICAgICAgMjc1NjczNDE4NywKICAgICAgICAzMjA0MDMxNDc5LAogICAgICAgIDMzMjkzMjUyOTgKICAgICAgXSk7CiAgICAgIFNIQTI1Nl9JViA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoWwogICAgICAgIDE3NzkwMzM3MDMsCiAgICAgICAgMzE0NDEzNDI3NywKICAgICAgICAxMDEzOTA0MjQyLAogICAgICAgIDI3NzM0ODA3NjIsCiAgICAgICAgMTM1OTg5MzExOSwKICAgICAgICAyNjAwODIyOTI0LAogICAgICAgIDUyODczNDYzNSwKICAgICAgICAxNTQxNDU5MjI1CiAgICAgIF0pOwogICAgICBTSEEyNTZfVyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoNjQpOwogICAgICBTSEEyNTYgPSBjbGFzcyBleHRlbmRzIEhhc2hNRCB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcig2NCwgMzIsIDgsIGZhbHNlKTsKICAgICAgICAgIHRoaXMuQSA9IFNIQTI1Nl9JVlswXSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBTSEEyNTZfSVZbMV0gfCAwOwogICAgICAgICAgdGhpcy5DID0gU0hBMjU2X0lWWzJdIHwgMDsKICAgICAgICAgIHRoaXMuRCA9IFNIQTI1Nl9JVlszXSB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBTSEEyNTZfSVZbNF0gfCAwOwogICAgICAgICAgdGhpcy5GID0gU0hBMjU2X0lWWzVdIHwgMDsKICAgICAgICAgIHRoaXMuRyA9IFNIQTI1Nl9JVls2XSB8IDA7CiAgICAgICAgICB0aGlzLkggPSBTSEEyNTZfSVZbN10gfCAwOwogICAgICAgIH0KICAgICAgICBnZXQoKSB7CiAgICAgICAgICBjb25zdCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICByZXR1cm4gW0EsIEIsIEMsIEQsIEUsIEYsIEcsIEhdOwogICAgICAgIH0KICAgICAgICAvLyBwcmV0dGllci1pZ25vcmUKICAgICAgICBzZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCkgewogICAgICAgICAgdGhpcy5BID0gQSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBCIHwgMDsKICAgICAgICAgIHRoaXMuQyA9IEMgfCAwOwogICAgICAgICAgdGhpcy5EID0gRCB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBFIHwgMDsKICAgICAgICAgIHRoaXMuRiA9IEYgfCAwOwogICAgICAgICAgdGhpcy5HID0gRyB8IDA7CiAgICAgICAgICB0aGlzLkggPSBIIHwgMDsKICAgICAgICB9CiAgICAgICAgcHJvY2Vzcyh2aWV3LCBvZmZzZXQpIHsKICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMTY7IGkrKywgb2Zmc2V0ICs9IDQpCiAgICAgICAgICAgIFNIQTI1Nl9XW2ldID0gdmlldy5nZXRVaW50MzIob2Zmc2V0LCBmYWxzZSk7CiAgICAgICAgICBmb3IgKGxldCBpID0gMTY7IGkgPCA2NDsgaSsrKSB7CiAgICAgICAgICAgIGNvbnN0IFcxNSA9IFNIQTI1Nl9XW2kgLSAxNV07CiAgICAgICAgICAgIGNvbnN0IFcyID0gU0hBMjU2X1dbaSAtIDJdOwogICAgICAgICAgICBjb25zdCBzMCA9IHJvdHIoVzE1LCA3KSBeIHJvdHIoVzE1LCAxOCkgXiBXMTUgPj4+IDM7CiAgICAgICAgICAgIGNvbnN0IHMxID0gcm90cihXMiwgMTcpIF4gcm90cihXMiwgMTkpIF4gVzIgPj4+IDEwOwogICAgICAgICAgICBTSEEyNTZfV1tpXSA9IHMxICsgU0hBMjU2X1dbaSAtIDddICsgczAgKyBTSEEyNTZfV1tpIC0gMTZdIHwgMDsKICAgICAgICAgIH0KICAgICAgICAgIGxldCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDY0OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc2lnbWExID0gcm90cihFLCA2KSBeIHJvdHIoRSwgMTEpIF4gcm90cihFLCAyNSk7CiAgICAgICAgICAgIGNvbnN0IFQxID0gSCArIHNpZ21hMSArIENoaShFLCBGLCBHKSArIFNIQTI1Nl9LW2ldICsgU0hBMjU2X1dbaV0gfCAwOwogICAgICAgICAgICBjb25zdCBzaWdtYTAgPSByb3RyKEEsIDIpIF4gcm90cihBLCAxMykgXiByb3RyKEEsIDIyKTsKICAgICAgICAgICAgY29uc3QgVDIgPSBzaWdtYTAgKyBNYWooQSwgQiwgQykgfCAwOwogICAgICAgICAgICBIID0gRzsKICAgICAgICAgICAgRyA9IEY7CiAgICAgICAgICAgIEYgPSBFOwogICAgICAgICAgICBFID0gRCArIFQxIHwgMDsKICAgICAgICAgICAgRCA9IEM7CiAgICAgICAgICAgIEMgPSBCOwogICAgICAgICAgICBCID0gQTsKICAgICAgICAgICAgQSA9IFQxICsgVDIgfCAwOwogICAgICAgICAgfQogICAgICAgICAgQSA9IEEgKyB0aGlzLkEgfCAwOwogICAgICAgICAgQiA9IEIgKyB0aGlzLkIgfCAwOwogICAgICAgICAgQyA9IEMgKyB0aGlzLkMgfCAwOwogICAgICAgICAgRCA9IEQgKyB0aGlzLkQgfCAwOwogICAgICAgICAgRSA9IEUgKyB0aGlzLkUgfCAwOwogICAgICAgICAgRiA9IEYgKyB0aGlzLkYgfCAwOwogICAgICAgICAgRyA9IEcgKyB0aGlzLkcgfCAwOwogICAgICAgICAgSCA9IEggKyB0aGlzLkggfCAwOwogICAgICAgICAgdGhpcy5zZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCk7CiAgICAgICAgfQogICAgICAgIHJvdW5kQ2xlYW4oKSB7CiAgICAgICAgICBTSEEyNTZfVy5maWxsKDApOwogICAgICAgIH0KICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgdGhpcy5zZXQoMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCk7CiAgICAgICAgICB0aGlzLmJ1ZmZlci5maWxsKDApOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2hhMjU2ID0gLyogQF9fUFVSRV9fICovIHdyYXBDb25zdHJ1Y3RvcigoKSA9PiBuZXcgU0hBMjU2KCkpOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2hhc2hlc0AxLjUuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2hhc2hlcy9lc20vaG1hYy5qcwogIHZhciBITUFDLCBobWFjOwogIHZhciBpbml0X2htYWMgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStoYXNoZXNAMS41LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9oYXNoZXMvZXNtL2htYWMuanMiKCk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ggPSBoYXNoMy5jcmVhdGUoKTsKICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGFkMi5sZW5ndGg7IGkrKykKICAgICAgICAgICAgcGFkMltpXSBePSA1NCBeIDkyOwogICAgICAgICAgdGhpcy5vSGFzaC51cGRhdGUocGFkMik7CiAgICAgICAgICBwYWQyLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIHVwZGF0ZShidWYpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIHRoaXMuaUhhc2gudXBkYXRlKGJ1Zik7CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIGJ5dGVzKG91dCwgdGhpcy5vdXRwdXRMZW4pOwogICAgICAgICAgdGhpcy5maW5pc2hlZCA9IHRydWU7CiAgICAgICAgICB0aGlzLmlIYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMub0hhc2gudXBkYXRlKG91dCk7CiAgICAgICAgICB0aGlzLm9IYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMuZGVzdHJveSgpOwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICBjb25zdCBvdXQgPSBuZXcgVWludDhBcnJheSh0aGlzLm9IYXNoLm91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHJldHVybiBvdXQ7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIHRvIHx8ICh0byA9IE9iamVjdC5jcmVhdGUoT2JqZWN0LmdldFByb3RvdHlwZU9mKHRoaXMpLCB7fSkpOwogICAgICAgICAgY29uc3QgeyBvSGFzaCwgaUhhc2gsIGZpbmlzaGVkLCBkZXN0cm95ZWQsIGJsb2NrTGVuLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0byA9IHRvOwogICAgICAgICAgdG8uZmluaXNoZWQgPSBmaW5pc2hlZDsKICAgICAgICAgIHRvLmRlc3Ryb3llZCA9IGRlc3Ryb3llZDsKICAgICAgICAgIHRvLmJsb2NrTGVuID0gYmxvY2tMZW47CiAgICAgICAgICB0by5vdXRwdXRMZW4gPSBvdXRwdXRMZW47CiAgICAgICAgICB0by5vSGFzaCA9IG9IYXNoLl9jbG9uZUludG8odG8ub0hhc2gpOwogICAgICAgICAgdG8uaUhhc2ggPSBpSGFzaC5fY2xvbmVJbnRvKHRvLmlIYXNoKTsKICAgICAgICAgIHJldHVybiB0bzsKICAgICAgICB9CiAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgIHRoaXMub0hhc2guZGVzdHJveSgpOwogICAgICAgICAgdGhpcy5pSGFzaC5kZXN0cm95KCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBobWFjID0gKGhhc2gzLCBrZXksIG1lc3NhZ2UpID0+IG5ldyBITUFDKGhhc2gzLCBrZXkpLnVwZGF0ZShtZXNzYWdlKS5kaWdlc3QoKTsKICAgICAgaG1hYy5jcmVhdGUgPSAoaGFzaDMsIGtleSkgPT4gbmV3IEhNQUMoaGFzaDMsIGtleSk7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby9Abm9ibGUrY3VydmVzQDEuNi4wL25vZGVfbW9kdWxlcy9Abm9ibGUvY3VydmVzL2VzbS9hYnN0cmFjdC91dGlscy5qcwogIHZhciB1dGlsc19leHBvcnRzID0ge307CiAgX19leHBvcnQodXRpbHNfZXhwb3J0cywgewogICAgYUluUmFuZ2U6ICgpID0+IGFJblJhbmdlLAogICAgYWJvb2w6ICgpID0+IGFib29sLAogICAgYWJ5dGVzOiAoKSA9PiBhYnl0ZXMsCiAgICBiaXRHZXQ6ICgpID0+IGJpdEdldCwKICAg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AgICB2ID0gaCgpOwogICAgICBpZiAoc2VlZC5sZW5ndGggPT09IDApCiAgICAgICAgcmV0dXJuOwogICAgICBrID0gaCh1OGZyKFsxXSksIHNlZWQpOwogICAgICB2ID0gaCgpOwogICAgfTsKICAgIGNvbnN0IGdlbjIgPSAoKSA9PiB7CiAgICAgIGlmIChpKysgPj0gMWUzKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiZHJiZzogdHJpZWQgMTAwMCB2YWx1ZXMiKTsKICAgICAgbGV0IGxlbiA9IDA7CiAgICAgIGNvbnN0IG91dCA9IFtdOwogICAgICB3aGlsZSAobGVuIDwgcUJ5dGVMZW4pIHsKICAgICAgICB2ID0gaCgpOwogICAgICAgIGNvbnN0IHNsID0gdi5zbGljZSgpOwogICAgICAgIG91dC5wdXNoKHNsKTsKICAgICAgICBsZW4gKz0gdi5sZW5ndGg7CiAgICAgIH0KICAgICAgcmV0dXJuIGNvbmNhdEJ5dGVzMyguLi5vdXQpOwogICAgfTsKICAgIGNvbnN0IGdlblVudGlsID0gKHNlZWQsIHByZWQpID0+IHsKICAgICAgcmVzZXQyKCk7CiAgICAgIHJlc2VlZChzZWVkKTsKICAgICAgbGV0IHJlcyA9IHZvaWQgMDsKICAgICAgd2hpbGUgKCEocmVzID0gcHJlZChnZW4yKCkpKSkKICAgICAgICByZXNlZWQoKTsKICAgICAgcmVzZXQyKCk7CiAgICAgIHJldHVybiByZXM7CiAgICB9OwogICAgcmV0dXJuIGdlblVudGlsOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZU9iamVjdChvYmplY3QsIHZhbGlkYXRvcnMsIG9wdFZhbGlkYXRvcnMgPSB7fSkgewogICAgY29uc3QgY2hlY2tGaWVsZCA9IChmaWVsZE5hbWUsIHR5cGUsIGlzT3B0aW9uYWwpID0+IHsKICAgICAgY29uc3QgY2hlY2tWYWwgPSB2YWxpZGF0b3JGbnNbdHlwZV07CiAgICAgIGlmICh0eXBlb2YgY2hlY2tWYWwgIT09ICJmdW5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lZyhGcDIuT05FKSkKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgIGxldCByID0gUzsKICAgICAgbGV0IGcgPSBGcDIucG93KEZwMi5tdWwoRnAyLk9ORSwgWiksIFEpOwogICAgICBsZXQgeCA9IEZwMi5wb3cobiwgUTFkaXYyKTsKICAgICAgbGV0IGIgPSBGcDIucG93KG4sIFEpOwogICAgICB3aGlsZSAoIUZwMi5lcWwoYiwgRnAyLk9ORSkpIHsKICAgICAgICBpZiAoRnAyLmVxbChiLCBGcDIuWkVSTykpCiAgICAgICAgICByZXR1cm4gRnAyLlpFUk87CiAgICAgICAgbGV0IG0gPSAxOwogICAgICAgIGZvciAobGV0IHQyID0gRnAyLnNxcihiKTsgbSA8IHI7IG0rKykgewogICAgICAgICAgaWYgKEZwMi5lcWwodDIsIEZwMi5PTkUpKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIHQyID0gRnAyLnNxcih0Mik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGdlID0gRnAyLnBvdyhnLCBfMW4zIDw8IEJpZ0ludChyIC0gbSAtIDEpKTsKICAgICAgICBnID0gRnAyLnNxcihnZSk7CiAgICAgICAgeCA9IEZwMi5tdWwoeCwgZ2UpOwogICAgICAgIGIgPSBGcDIubXVsKGIsIGcpOwogICAgICAgIHIgPSBtOwogICAgICB9CiAgICAgIHJldHVybiB4OwogICAgfTsKICB9CiAgZnVuY3Rpb24gRnBTcXJ0KFApIHsKICAgIGlmIChQICUgXzRuID09PSBfM24pIHsKICAgICAgY29uc3QgcDFkaXY0ID0gKFAgKyBfMW4zKSAvIF80bjsKICAgICAgcmV0dXJuIGZ1bmN0aW9uIHNxcnQzbW9kNChGcDIsIG4pIHsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5wb3cobiwgcDFkaXY0KTsKICAgICAgICBpZiAoIUZwMi5lcWwoRnAyLnNxcihyb290MiksIG4pKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgZmluZCBzcXVhcmUgcm9vdCIpOwogICAgICAgIHJldHVybiByb290MjsKICAgICAgfTsKICAgIH0KICAgIGlmIChQICUgXzhuID09PSBfNW4pIHsKICAgICAgY29uc3QgYzEgPSAoUCAtIF81bikgLyBfOG47CiAgICAgIHJldHVybiBmdW5jdGlvbiBzcXJ0NW1vZDgoRnAyLCBuKSB7CiAgICAgICAgY29uc3QgbjIgPSBGcDIubXVsKG4sIF8ybjMpOwogICAgICAgIGNvbnN0IHYgPSBGcDIucG93KG4yLCBjMSk7CiAgICAgICAgY29uc3QgbnYgPSBGcDIubXVsKG4sIHYpOwogICAgICAgIGNvbnN0IGkgPSBGcDIubXVsKEZwMi5tdWwobnYsIF8ybjMpLCB2KTsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5tdWwobnYsIEZwMi5zdWIoaSwgRnAyLk9ORSkpOwogICAgICAgIGlmICghRnAyLmVxbChGcDIuc3FyKHJvb3QyKSwgbikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgICAgcmV0dXJuIHJvb3QyOwogICAgICB9OwogICAgfQogICAgaWYgKFAgJSBfMTZuID09PSBfOW4pIHsKICAgIH0KICAgIHJldHVybiB0b25lbGxpU2hhbmtzKFApOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZUZpZWxkKGZpZWxkKSB7CiAgICBjb25zdCBpbml0aWFsID0gewogICAgICBPUkRFUjogImJpZ2ludCIsCiAgICAgIE1BU0s6ICJiaWdpbnQiLAogICAgICBCWVRFUzogImlzU2FmZUludGVnZXIiLAogICAgICBCSVRTOiAiaXNTYWZlSW50ZWdlciIKICAgIH07CiAgICBjb25zdCBvcHRzID0gRklFTERfRklFTERTLnJlZHVjZSgobWFwLCB2YWwpID0+IHsKICAgICAgbWFwW3ZhbF0gPSAiZnVuY3Rpb24iOwogICAgICByZXR1cm4gbWFwOwogICAgfSwgaW5pdGlhbCk7CiAgICByZXR1cm4gdmFsaWRhdGVPYmplY3QoZmllbGQsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBGcFBvdyhmMiwgbnVtMiwgcG93ZXIpIHsKICAgIGlmIChwb3dlciA8IF8wbjMpCiAgICAgIHRocm93IG5ldyBFcnJvcigiRXhwZWN0ZWQgcG93ZXIgPiAwIik7CiAgICBpZiAocG93ZXIgPT09IF8wbjMpCiAgICAgIHJldHVybiBmMi5PTkU7CiAgICBpZiAocG93ZXIgPT09IF8xbjMpCiAgICAgIHJldHVybiBudW0yOwogICAgbGV0IHAgPSBmMi5PTkU7CiAgICBsZXQgZCA9IG51bTI7CiAgICB3aGlsZSAocG93ZXIgPiBfMG4zKSB7CiAgICAgIGlmIChwb3dlciAmIF8xbjMpCiAgICAgICAgcCA9IGYyLm11bChwLCBkKTsKICAgICAgZCA9IGYyLnNxcihkKTsKICAgICAgcG93ZXIgPj49IF8xbjM7CiAgICB9CiAgICByZXR1cm4gcDsKICB9CiAgZnVuY3Rpb24gRnBJbnZlcnRCYXRjaChmMiwgbnVtcykgewogICAgY29uc3QgdG1wID0gbmV3IEFycmF5KG51bXMubGVuZ3RoKTsKICAgIGNvbnN0IGxhc3RNdWx0aXBsaWVkID0gbnVtcy5yZWR1Y2UoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGFjYzsKICAgICAgcmV0dXJuIGYyLm11bChhY2MsIG51bTIpOwogICAgfSwgZjIuT05FKTsKICAgIGNvbnN0IGludmVydGVkID0gZjIuaW52KGxhc3RNdWx0aXBsaWVkKTsKICAgIG51bXMucmVkdWNlUmlnaHQoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGYyLm11bChhY2MsIHRtcFtpX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gIGlzVmFsaWQ6IChudW0yKSA9PiB7CiAgICAgICAgaWYgKHR5cGVvZiBudW0yICE9PSAiYmlnaW50IikKICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgSW52YWxpZCBmaWVsZCBlbGVtZW50OiBleHBlY3RlZCBiaWdpbnQsIGdvdCAke3R5cGVvZiBudW0yfWApOwogICAgICAgIHJldHVybiBfMG4zIDw9IG51bTIgJiYgbnVtMiA8IE9SREVSOwogICAgICB9LAogICAgICBpczA6IChudW0yKSA9PiBudW0yID09PSBfMG4zLAogICAgICBpc09kZDogKG51bTIpID0+IChudW0yICYgXzFuMykgPT09IF8xbjMsCiAgICAgIG5lZzogKG51bTIpID0+IG1vZCgtbnVtMiwgT1JERVIpLAogICAgICBlcWw6IChsaHMsIHJocykgPT4gbGhzID09PSByaHMsCiAgICAgIHNxcjogKG51bTIpID0+IG1vZChudW0yICogbnVtMiwgT1JERVIpLAogICAgICBhZGQ6IChsaHMsIHJocykgPT4gbW9kKGxocyArIHJocywgT1JERVIpLAogICAgICBzdWI6IChsaHMsIHJocykgPT4gbW9kKGxocyAtIHJocywgT1JERVIpLAogICAgICBtdWw6IChsaHMsIHJocykgPT4gbW9kKGxocyAqIHJocywgT1JERVIpLAogICAgICBwb3c6IChudW0yLCBwb3dlcikgPT4gRnBQb3coZjIsIG51bTIsIHBvd2VyKSwKICAgICAgZGl2OiAobGhzLCByaHMpID0+IG1vZChsaHMgKiBpbnZlcnQocmhzLCBPUkRFUiksIE9SREVSKSwKICAgICAgLy8gU2FtZSBhcyBhYm92ZSwgYnV0IGRvZXNuJ3Qgbm9ybWFsaXplCiAgICAgIHNxck46IChudW0yKSA9PiBudW0yICogbnVtMiwKICAgICAgYWRkTjogKGxocywgcmhzKSA9PiBsaHMgKyByaHMsCiAgICAgIHN1Yk46IChsaHMsIHJocykgPT4gbGhzIC0gcmhzLAogICAgICBtdWxOOiAobGhzLCByaHMpID0+IGxocyAqIHJocywKICAgICAgaW52OiAobnVtMikgPT4g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0X21vZHVsYXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStjdXJ2ZXNAMS42LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9jdXJ2ZXMvZXNtL2Fic3RyYWN0L21vZHVsYXIuanMiKCkgewogICAgICBpbml0X3V0aWxzNCgpOwogICAgICBfMG4zID0gQmlnSW50KDApOwogICAgICBfMW4zID0gQmlnSW50KDEpOwogICAgICBfMm4zID0gQmlnSW50KDIpOwogICAgICBfM24gPSBCaWdJbnQoMyk7CiAgICAgIF80biA9IEJpZ0ludCg0KTsKICAgICAgXzVuID0gQmlnSW50KDUpOwogICAgICBfOG4gPSBCaWdJbnQoOCk7CiAgICAgIF85biA9IEJpZ0ludCg5KTsKICAgICAgXzE2biA9IEJpZ0ludCgxNik7CiAgICAgIEZJRUxEX0ZJRUxEUyA9IFsKICAgICAgICAiY3JlYXRlIiwKICAgICAgICAiaXNWYWxpZCIsCiAgICAgICAgImlzMCIsCiAgICAgICAgIm5lZyIsCiAgICAgICAgImludiIsCiAgICAgICAgInNxcnQiLAogICAgICAgICJzcXIiLAogICAgICAgICJlcWwiLAogICAgICAgICJhZGQiLAogICAgICAgICJzdWIiLAogICAgICAgICJtdWwiLAogICAgICAgICJwb3ciLAogICAgICAgICJkaXYiLAogICAgICAgICJhZGROIiwKICAgICAgICAic3ViTiIsCiAgICAgICAgIm11bE4iLAogICAgICAgICJzcXJOIgogICAgICBdOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2N1cnZlc0AxLjYuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2N1cnZlcy9lc20vYWJzdHJhY3QvY3VydmUuanMKICBmdW5jdGlvbiB3TkFGKGMsIGJpdHMpIHsKICAgIGNvbnN0IGNvbnN0VGltZU5lZ2F0ZSA9IChjb25kaXRpb24sIGl0ZW0pID0+IHsKICAgICAgY29uc3QgbmVnID0gaXRlbS5uZWdhdGUoKTsKICAgICAgcmV0dXJuIGNvbmRpdGlvbiA/IG5lZyA6IGl0ZW07CiAgICB9OwogICAgY29uc3QgdmFsaWRhdGVXID0gKFcpID0+IHsKICAgICAgaWYgKCFOdW1iZXIuaXNTYWZlSW50ZWdlcihXKSB8fCBXIDw9IDAgfHwgVyA+IGJpdHMpCiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBXcm9uZyB3aW5kb3cgc2l6ZT0ke1d9LCBzaG91bGQgYmUgWzEuLiR7Yml0c31dYCk7CiAgICB9OwogICAgY29uc3Qgb3B0cyA9IChXKSA9PiB7CiAgICAgIHZhbGlkYXRlVyhXKTsKICAgICAgY29uc3Qgd2luZG93cyA9IE1hdGguY2VpbChiaXRzIC8gVykgKyAxOwogICAgICBjb25zdCB3aW5kb3dTaXplID0gMiAqKiAoVyAtIDEpOwogICAgICByZXR1cm4geyB3aW5kb3dzLCB3aW5kb3dTaXplIH07CiAgICB9OwogICAgcmV0dXJuIHsKICAgICAgY29uc3RUaW1lTmVnYXRlLAogICAgICAvLyBub24tY29uc3QgdGltZSBtdWx0aXBsaWNhdGlvbiBsYWRkZXIKICAgICAgdW5zYWZlTGFkZGVyKGVsbSwgbikgewogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBkID0gZWxtOwogICAgICAgIHdoaWxlIChuID4gXzBuNCkgewogICAgICAgICAgaWYgKG4gJiBfMW40KQogICAgICAgICAgICBwID0gcC5hZGQoZCk7CiAgICAgICAgICBkID0gZC5kb3VibGUoKTsKICAgICAgICAgIG4gPj49IF8xbjQ7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwOwogICAgICB9LAogICAgICAvKioKICAgICAgICogQ3JlYXRlcyBhIHdOQUYgcHJlY29tcHV0YXRpb24gd2luZG93LiBVc2VkIGZvciBjYWNoaW5nLgogICAgICAgKiBEZWZhdWx0IHdpbmRvdyBzaXplIGlzIHNldCBieSBgdXRpbHMucHJlY29tcHV0ZSgpYCBhbmQgaXMgZXF1Y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ICAgcmV0dXJuIHBvaW50czsKICAgICAgfSwKICAgICAgLyoqCiAgICAgICAqIEltcGxlbWVudHMgZWMgbXVsdGlwbGljYXRpb24gdXNpbmcgcHJlY29tcHV0ZWQgdGFibGVzIGFuZCB3LWFyeSBub24tYWRqYWNlbnQgZm9ybS4KICAgICAgICogQHBhcmFtIFcgd2luZG93IHNpemUKICAgICAgICogQHBhcmFtIHByZWNvbXB1dGVzIHByZWNvbXB1dGVkIHRhYmxlcwogICAgICAgKiBAcGFyYW0gbiBzY2FsYXIgKHdlIGRvbid0IGNoZWNrIGhlcmUsIGJ1dCBzaG91bGQgYmUgbGVzcyB0aGFuIGN1cnZlIG9yZGVyKQogICAgICAgKiBAcmV0dXJucyByZWFsIGFuZCBmYWtlIChmb3IgY29uc3QtdGltZSkgcG9pbnRzCiAgICAgICAqLwogICAgICB3TkFGKFcsIHByZWNvbXB1dGVzLCBuKSB7CiAgICAgICAgY29uc3QgeyB3aW5kb3dzLCB3aW5kb3dTaXplIH0gPSBvcHRzKFcpOwogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBmMiA9IGMuQkFTRTsKICAgICAgICBjb25zdCBtYXNrID0gQmlnSW50KDIgKiogVyAtIDEpOwogICAgICAgIGNvbnN0IG1heE51bWJlciA9IDIgKiogVzsKICAgICAgICBjb25zdCBzaGlmdEJ5ID0gQmlnSW50KFcpOwogICAgICAgIGZvciAobGV0IHdpbmRvdzIgPSAwOyB3aW5kb3cyIDwgd2luZG93czsgd2luZG93MisrKSB7CiAgICAgICAgICBjb25zdCBvZmZzZXQgPSB3aW5kb3cyICogd2luZG93U2l6ZTsKICAgICAgICAgIGxldCB3Yml0cyA9IE51bWJlcihuICYgbWFzayk7CiAgICAgICAgICBuID4+PSBzaGlmdEJ5OwogICAgICAgICAgaWYgKHdiaXRzID4gd2luZG93U2l6ZSkgewogICAgICAgICAgICB3Yml0cyAtPSBtYXhOdW1iZXI7CiAgICAgICAgICAgIG4gKz0gXzFuNDsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG9mZnNldDEgPSBvZmZzZXQ7CiAgICAgICAgICBjb25zdCBvZmZzZXQyID0gb2Zmc2V0ICsgTWF0aC5hYnMod2JpdHMpIC0gMTsKICAgICAgICAgIGNvbnN0IGNvbmQxID0gd2luZG93MiAlIDIgIT09IDA7CiAgICAgICAgICBjb25zdCBjb25kMiA9IHdiaXRzIDwgMDsKICAgICAgICAgIGlmICh3Yml0cyA9PT0gMCkgewogICAgICAgICAgICBmMiA9IGYyLmFkZChjb25zdFRpbWVOZWdhdGUoY29uZDEsIHByZWNvbXB1dGVzW29mZnNldDFdKSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwID0gcC5hZGQoY29uc3RUaW1lTmVnYXRlKGNvbmQyLCBwcmVjb21wdXRlc1tvZmZzZXQyXSkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4geyBwLCBmOiBmMiB9OwogICAgICB9LAogICAgICB3TkFGQ2FjaGVkKFAsIG4sIHRyYW5zZm9ybSkgewogICAgICAgIGNvbnN0IFcgPSBwb2ludFdpbmRvd1NpemVzLmdldChQKSB8fCAxOwogICAgICAgIGxldCBjb21wID0gcG9pbnRQcmVjb21wdXRlcy5nZXQoUCk7CiAgICAgICAgaWYgKCFjb21wKSB7CiAgICAgICAgICBjb21wID0gdGhpcy5wcmVjb21wdXRlV2luZG93KFAsIFcpOwogICAgICAgICAgaWYgKFcgIT09IDEpCiAgICAgICAgICAgIHBvaW50UHJlY29tcHV0ZXMuc2V0KFAsIHRyYW5zZm9ybShjb21wKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLndOQUYoVywgY29tcCwgbik7CiAgICAgIH0sCiAgICAgIC8vIFdlIGNhbGN1bGF0ZSBwcmVjb21wdXRlcyBmb3IgZWxsaXB0aWMgY3VydmUgcG9pbnQgbXVsdGlwbGljYXRpb24KICAgICAgLy8gdXNpbmcgd2luZG93ZWQgbWV0aG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ga2V5Iik7CiAgICAgICAga2V5ID0ga2V5LnBhZFN0YXJ0KG5CeXRlTGVuZ3RoICogMiwgIjAiKTsKICAgICAgfQogICAgICBsZXQgbnVtMjsKICAgICAgdHJ5IHsKICAgICAgICBudW0yID0gdHlwZW9mIGtleSA9PT0gImJpZ2ludCIgPyBrZXkgOiBieXRlc1RvTnVtYmVyQkUoZW5zdXJlQnl0ZXMoInByaXZhdGUga2V5Iiwga2V5LCBuQnl0ZUxlbmd0aCkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIHRocm93IG5ldyBFcnJvcihgcHJpdmF0ZSBrZXkgbXVzdCBiZSAke25CeXRlTGVuZ3RofSBieXRlcywgaGV4IG9yIGJpZ2ludCwgbm90ICR7dHlwZW9mIGtleX1gKTsKICAgICAgfQogICAgICBpZiAod3JhcFByaXZhdGVLZXkpCiAgICAgICAgbnVtMiA9IG1vZChudW0yLCBOKTsKICAgICAgYUluUmFuZ2UoInByaXZhdGUga2V5IiwgbnVtMiwgXzFuNSwgTik7CiAgICAgIHJldHVybiBudW0yOwogICAgfQogICAgZnVuY3Rpb24gYXNzZXJ0UHJqUG9pbnQob3RoZXIpIHsKICAgICAgaWYgKCEob3RoZXIgaW5zdGFuY2VvZiBQb2ludDIpKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiUHJvamVjdGl2ZVBvaW50IGV4cGVjdGVkIik7CiAgICB9CiAgICBjb25zdCB0b0FmZmluZU1lbW8gPSBtZW1vaXplZCgocCwgaXopID0+IHsKICAgICAgY29uc3QgeyBweDogeCwgcHk6IHksIHB6OiB6IH0gPSBwOwogICAgICBpZiAoRnAyLmVxbCh6LCBGcDIuT05FKSkKICAgICAgICByZXR1cm4geyB4LCB5IH07CiAgICAgIGNvbnN0IGlzMCA9IHAuaXMwKCk7CiAgICAgIGlmIChpeiA9PSBudWxsKQogICAgICAgIGl6ID0gaXMwID8gRnAyLk9ORSA6IEZwMi5pbnYoeik7CiAgICAgIGNvbnN0IGF4ID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b3JkZXIgc3ViZ3JvdXAiKTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9KTsKICAgIGNsYXNzIFBvaW50MiB7CiAgICAgIGNvbnN0cnVjdG9yKHB4LCBweSwgcHopIHsKICAgICAgICB0aGlzLnB4ID0gcHg7CiAgICAgICAgdGhpcy5weSA9IHB5OwogICAgICAgIHRoaXMucHogPSBwejsKICAgICAgICBpZiAocHggPT0gbnVsbCB8fCAhRnAyLmlzVmFsaWQocHgpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJ4IHJlcXVpcmVkIik7CiAgICAgICAgaWYgKHB5ID09IG51bGwgfHwgIUZwMi5pc1ZhbGlkKHB5KSkKICAgICAgICAgIHRocm93IG5ldyBFcnJvcigieSByZXF1aXJlZCIpOwogICAgICAgIGlmIChweiA9PSBudWxsIHx8ICFGcDIuaXNWYWxpZChweikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInogcmVxdWlyZWQiKTsKICAgICAgICBPYmplY3QuZnJlZXplKHRoaXMpOwogICAgICB9CiAgICAgIC8vIERvZXMgbm90IHZhbGlkYXRlIGlmIHRoZSBwb2ludCBpcyBvbi1jdXJ2ZS4KICAgICAgLy8gVXNlIGZyb21IZXggaW5zdGVhZCwgb3IgY2FsbCBhc3NlcnRWYWxpZGl0eSgpIGxhdGVyLgogICAgICBzdGF0aWMgZnJvbUFmZmluZShwKSB7CiAgICAgICAgY29uc3QgeyB4LCB5IH0gPSBwIHx8IHt9OwogICAgICAgIGlmICghcCB8fCAhRnAyLmlzVmFsaWQoeCkgfHwgIUZwMi5pc1ZhbGlkKHkpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJpbnZhbGlkIGFmZmluZSBwb2ludCIpOwogICAgICAgIGlmIChwIGluc3RhbmNlb2YgUG9pbnQyKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJwcm9qZWN0aXZlIHBvaW50IG5vdCBhbGxvd2VkIik7CiAgICAgICAgY29uc3QgaXMw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AgICAgLy8gQ29zdDogOE0gKyAzUyArIDMqYSArIDIqYjMgKyAxNWFkZC4KICAgICAgZG91YmxlKCkgewogICAgICAgIGNvbnN0IHsgYSwgYiB9ID0gQ1VSVkU7CiAgICAgICAgY29uc3QgYjMyID0gRnAyLm11bChiLCBfM24yKTsKICAgICAgICBjb25zdCB7IHB4OiBYMSwgcHk6IFkxLCBwejogWjEgfSA9IHRoaXM7CiAgICAgICAgbGV0IFgzID0gRnAyLlpFUk8sIFkzID0gRnAyLlpFUk8sIFozID0gRnAyLlpFUk87CiAgICAgICAgbGV0IHQwID0gRnAyLm11bChYMSwgWDEpOwogICAgICAgIGxldCB0MSA9IEZwMi5tdWwoWTEsIFkxKTsKICAgICAgICBsZXQgdDIgPSBGcDIubXVsKFoxLCBaMSk7CiAgICAgICAgbGV0IHQzID0gRnAyLm11bChYMSwgWTEpOwogICAgICAgIHQzID0gRnAyLmFkZCh0MywgdDMpOwogICAgICAgIFozID0gRnAyLm11bChYMSwgWjEpOwogICAgICAgIFozID0gRnAyLmFkZChaMywgWjMpOwogICAgICAgIFgzID0gRnAyLm11bChhLCBaMyk7CiAgICAgICAgWTMgPSBGcDIubXVsKGIzMiwgdDIpOwogICAgICAgIFkzID0gRnAyLmFkZChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLnN1Yih0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLmFkZCh0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLm11bChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLm11bCh0MywgWDMpOwogICAgICAgIFozID0gRnAyLm11bChiMzIsIFozKTsKICAgICAgICB0MiA9IEZwMi5tdWwoYSwgdDIpOwogICAgICAgIHQzID0gRnAyLnN1Yih0MCwgdDIpOwogICAgICAgIHQzID0gRnAyLm11bChhLCB0Myk7CiAgICAgICAgdDMgPSBGcDIuYWRkKHQzLCBaMyk7CiAgICAgICAgWjMgPSBGcDIuYWRkKHQwLCB0MCk7CiAgICAgICAgdDAgPSBG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kKHQwLCB0MCk7CiAgICAgICAgdDEgPSBGcDIuYWRkKHQxLCB0MCk7CiAgICAgICAgdDIgPSBGcDIubXVsKGEsIHQyKTsKICAgICAgICB0NCA9IEZwMi5tdWwoYjMyLCB0NCk7CiAgICAgICAgdDEgPSBGcDIuYWRkKHQxLCB0Mik7CiAgICAgICAgdDIgPSBGcDIuc3ViKHQwLCB0Mik7CiAgICAgICAgdDIgPSBGcDIubXVsKGEsIHQyKTsKICAgICAgICB0NCA9IEZwMi5hZGQodDQsIHQyKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDEsIHQ0KTsKICAgICAgICBZMyA9IEZwMi5hZGQoWTMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDUsIHQ0KTsKICAgICAgICBYMyA9IEZwMi5tdWwodDMsIFgzKTsKICAgICAgICBYMyA9IEZwMi5zdWIoWDMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDMsIHQxKTsKICAgICAgICBaMyA9IEZwMi5tdWwodDUsIFozKTsKICAgICAgICBaMyA9IEZwMi5hZGQoWjMsIHQwKTsKICAgICAgICByZXR1cm4gbmV3IFBvaW50MihYMywgWTMsIFozKTsKICAgICAgfQogICAgICBzdWJ0cmFjdChvdGhlcikgewogICAgICAgIHJldHVybiB0aGlzLmFkZChvdGhlci5uZWdhdGUoKSk7CiAgICAgIH0KICAgICAgaXMwKCkgewogICAgICAgIHJldHVybiB0aGlzLmVxdWFscyhQb2ludDIuWkVSTyk7CiAgICAgIH0KICAgICAgd05BRihuKSB7CiAgICAgICAgcmV0dXJuIHduYWYud05BRkNhY2hlZCh0aGlzLCBuLCBQb2ludDIubm9ybWFsaXplWik7CiAgICAgIH0KICAgICAgLyoqCiAgICAgICAqIE5vbi1jb25zdGFudC10aW1lIG11bHRpcGxpY2F0aW9uLiBVc2VzIGRvdWJsZS1hbmQtYWRkIGFsZ29yaXRobS4KICAgICAgICogSXQncyBmYXN0ZXIsIGJ1dCBzaG91bGQgb25seSBiZSB1c2VkIHdoZW4geW91IGRvbid0IGNhcmUgYWJvdXQKICAgICAgICogYW4gZXhwb3NlZCBwcml2YXRlIGtleSBlLmcuIHNpZyB2ZXJpZmljYXRpb24sIHdoaWNoIHdvcmtzIG92ZXIgKnB1YmxpYyoga2V5cy4KICAgICAgICovCiAgICAgIG11bHRpcGx5VW5zYWZlKHNjKSB7CiAgICAgICAgYUluUmFuZ2UoInNjYWxhciIsIHNjLCBfMG41LCBDVVJWRS5uKTsKICAgICAgICBjb25zdCBJID0gUG9pbnQyLlpFUk87CiAgICAgICAgaWYgKHNjID09PSBfMG41KQogICAgICAgICAgcmV0dXJuIEk7CiAgICAgICAgaWYgKHNjID09PSBfMW41KQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgY29uc3QgeyBlbmRvIH0gPSBDVVJWRTsKICAgICAgICBpZiAoIWVuZG8pCiAgICAgICAgICByZXR1cm4gd25hZi51bnNhZmVMYWRkZXIodGhpcywgc2MpOwogICAgICAgIGxldCB7IGsxbmVnLCBrMSwgazJuZWcsIGsyIH0gPSBlbmRvLnNwbGl0U2NhbGFyKHNjKTsKICAgICAgICBsZXQgazFwID0gSTsKICAgICAgICBsZXQgazJwID0gSTsKICAgICAgICBsZXQgZCA9IHRoaXM7CiAgICAgICAgd2hpbGUgKGsxID4gXzBuNSB8fCBrMiA+IF8wbjUpIHsKICAgICAgICAgIGlmIChrMSAmIF8xbjUpCiAgICAgICAgICAgIGsxcCA9IGsxcC5hZGQoZCk7CiAgICAgICAgICBpZiAoazIgJiBfMW41KQogICAgICAgICAgICBrMnAgPSBrMnAuYWRkKGQpOwogICAgICAgICAgZCA9IGQuZG91YmxlKCk7CiAgICAgICAgICBrMSA+Pj0gXzFuNTsKICAgICAgICAgIGsyID4+PSBfMW41OwogICAgICAgIH0KICAgICAgICBpZiAoazFuZWcpCiAgICAgICAgICBrMXAgPSBrMXAubmVnYXRlKCk7CiAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgazJwID0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lZ2F0ZShrMW5lZywgazFwKTsKICAgICAgICAgIGsycCA9IHduYWYuY29uc3RUaW1lTmVnYXRlKGsybmVnLCBrMnApOwogICAgICAgICAgazJwID0gbmV3IFBvaW50MihGcDIubXVsKGsycC5weCwgZW5kby5iZXRhKSwgazJwLnB5LCBrMnAucHopOwogICAgICAgICAgcG9pbnQgPSBrMXAuYWRkKGsycCk7CiAgICAgICAgICBmYWtlID0gZjFwLmFkZChmMnApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCB7IHAsIGY6IGYyIH0gPSB0aGlzLndOQUYoc2NhbGFyKTsKICAgICAgICAgIHBvaW50ID0gcDsKICAgICAgICAgIGZha2UgPSBmMjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIFBvaW50Mi5ub3JtYWxpemVaKFtwb2ludCwgZmFrZV0pWzBdOwogICAgICB9CiAgICAgIC8qKgogICAgICAgKiBFZmZpY2llbnRseSBjYWxjdWxhdGUgYGFQICsgYlFgLiBVbnNhZmUsIGNhbiBleHBvc2UgcHJpdmF0ZSBrZXksIGlmIHVzZWQgaW5jb3JyZWN0bHkuCiAgICAgICAqIE5vdCB1c2luZyBTdHJhdXNzLVNoYW1pciB0cmljazogcHJlY29tcHV0YXRpb24gdGFibGVzIGFyZSBmYXN0ZXIuCiAgICAgICAqIFRoZSB0cmljayBjb3VsZCBiZSB1c2VmdWwgaWYgYm90aCBQIGFuZCBRIGFyZSBub3QgRyAobm90IGluIG91ciBjYXNlKS4KICAgICAgICogQHJldHVybnMgbm9uLXplcm8gYWZmaW5lIHBvaW50CiAgICAgICAqLwogICAgICBtdWx0aXBseUFuZEFkZFVuc2FmZShRLCBhLCBiKSB7CiAgICAgICAgY29uc3QgRyA9IFBvaW50Mi5CQVNFOwogICAgICAgIGNvbnN0IG11bCA9IChQLCBhMikgPT4gYTIgPT09IF8wbjUgfHwgYTIgPT09IF8xbjUgfHwgIVAuZXF1YWxzKEcpID8gUC5tdWx0aXBseVVuc2FmZShh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ludC50b0FmZmluZSgpOwogICAgICAgIGNvbnN0IHggPSBGcDIudG9CeXRlcyhhLngpOwogICAgICAgIGNvbnN0IGNhdCA9IGNvbmNhdEJ5dGVzMzsKICAgICAgICBhYm9vbCgiaXNDb21wcmVzc2VkIiwgaXNDb21wcmVzc2VkKTsKICAgICAgICBpZiAoaXNDb21wcmVzc2VkKSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbcG9pbnQuaGFzRXZlblkoKSA/IDIgOiAzXSksIHgpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbNF0pLCB4LCBGcDIudG9CeXRlcyhhLnkpKTsKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGZyb21CeXRlcyhieXRlczIpIHsKICAgICAgICBjb25zdCBsZW4gPSBieXRlczIubGVuZ3RoOwogICAgICAgIGNvbnN0IGhlYWQgPSBieXRlczJbMF07CiAgICAgICAgY29uc3QgdGFpbCA9IGJ5dGVzMi5zdWJhcnJheSgxKTsKICAgICAgICBpZiAobGVuID09PSBjb21wcmVzc2VkTGVuICYmIChoZWFkID09PSAyIHx8IGhlYWQgPT09IDMpKSB7CiAgICAgICAgICBjb25zdCB4ID0gYnl0ZXNUb051bWJlckJFKHRhaWwpOwogICAgICAgICAgaWYgKCFpblJhbmdlKHgsIF8xbjUsIEZwMi5PUkRFUikpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiUG9pbnQgaXMgbm90IG9uIGN1cnZlIik7CiAgICAgICAgICBjb25zdCB5MiA9IHdlaWVyc3RyYXNzRXF1YXRpb24oeCk7CiAgICAgICAgICBsZXQgeTsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHkgPSBGcDIuc3FydCh5Mik7CiAgICAgICAgICB9IGNhdGNoIChzcXJ0RXJyb3IpIHsKICAgICAgICAgICAgY29uc3Qgc3VmZml4ID0gc3FydEVycm9yIGluc3Rhbm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hbGFyKHByaXZhdGVLZXkpOwogICAgICBjb25zdCBzZWVkQXJncyA9IFtpbnQyb2N0ZXRzKGQpLCBpbnQyb2N0ZXRzKGgxaW50KV07CiAgICAgIGlmIChlbnQgIT0gbnVsbCAmJiBlbnQgIT09IGZhbHNlKSB7CiAgICAgICAgY29uc3QgZSA9IGVudCA9PT0gdHJ1ZSA/IHJhbmRvbUJ5dGVzMihGcDIuQllURVMpIDogZW50OwogICAgICAgIHNlZWRBcmdzLnB1c2goZW5zdXJlQnl0ZXMoImV4dHJhRW50cm9weSIsIGUpKTsKICAgICAgfQogICAgICBjb25zdCBzZWVkID0gY29uY2F0Qnl0ZXMzKC4uLnNlZWRBcmdzKTsKICAgICAgY29uc3QgbSA9IGgxaW50OwogICAgICBmdW5jdGlvbiBrMnNpZyhrQnl0ZXMpIHsKICAgICAgICBjb25zdCBrID0gYml0czJpbnQoa0J5dGVzKTsKICAgICAgICBpZiAoIWlzV2l0aGluQ3VydmVPcmRlcihrKSkKICAgICAgICAgIHJldHVybjsKICAgICAgICBjb25zdCBpayA9IGludk4oayk7CiAgICAgICAgY29uc3QgcSA9IFBvaW50Mi5CQVNFLm11bHRpcGx5KGspLnRvQWZmaW5lKCk7CiAgICAgICAgY29uc3QgciA9IG1vZE4yKHEueCk7CiAgICAgICAgaWYgKHIgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgY29uc3QgcyA9IG1vZE4yKGlrICogbW9kTjIobSArIHIgKiBkKSk7CiAgICAgICAgaWYgKHMgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgbGV0IHJlY292ZXJ5ID0gKHEueCA9PT0gciA/IDAgOiAyKSB8IE51bWJlcihxLnkgJiBfMW41KTsKICAgICAgICBsZXQgbm9ybVMgPSBzOwogICAgICAgIGlmIChsb3dTICYmIGlzQmlnZ2VyVGhhbkhhbGZPcmRlcihzKSkgewogICAgICAgICAgbm9ybVMgPSBub3JtYWxpemVTKHMpOwogICAgICA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3Qgd2FzIHJlbmFtZWQgdG8gbG93UyIpOwogICAgICB2YWxpZGF0ZVNpZ1Zlck9wdHMob3B0cyk7CiAgICAgIGNvbnN0IHsgbG93UywgcHJlaGFzaCB9ID0gb3B0czsKICAgICAgbGV0IF9zaWcgPSB2b2lkIDA7CiAgICAgIGxldCBQOwogICAgICB0cnkgewogICAgICAgIGlmICh0eXBlb2Ygc2cgPT09ICJzdHJpbmciIHx8IGlzQnl0ZXMyKHNnKSkgewogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgX3NpZyA9IFNpZ25hdHVyZS5mcm9tREVSKHNnKTsKICAgICAgICAgIH0gY2F0Y2ggKGRlckVycm9yKSB7CiAgICAgICAgICAgIGlmICghKGRlckVycm9yIGluc3RhbmNlb2YgREVSLkVycikpCiAgICAgICAgICAgICAgdGhyb3cgZGVyRXJyb3I7CiAgICAgICAgICAgIF9zaWcgPSBTaWduYXR1cmUuZnJvbUNvbXBhY3Qoc2cpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNnID09PSAib2JqZWN0IiAmJiB0eXBlb2Ygc2cuciA9PT0gImJpZ2ludCIgJiYgdHlwZW9mIHNnLnMgPT09ICJiaWdpbnQiKSB7CiAgICAgICAgICBjb25zdCB7IHI6IHIyLCBzOiBzMiB9ID0gc2c7CiAgICAgICAgICBfc2lnID0gbmV3IFNpZ25hdHVyZShyMiwgczIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBBUlNFIik7CiAgICAgICAgfQogICAgICAgIFAgPSBQb2ludDIuZnJvbUhleChwdWJsaWNLZXkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChlcnJvci5tZXNzYWdlID09PSAiUEFSU0UiKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzaWduYXR1cmUgbXVzdCBiZSBTaWduYXR1cmUgaW5zdGFuY2UsIFVpbnQ4QXJyYXkgb3IgaGV4IHN0cmluZ2ApOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobG93UyAmJiBfc2lnLmhhc0hpZ2hTKCkpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAocHJlaGFzaCkKICAgICAgICBtc2dIYXNoID0gQ1VSVkUuaGFzaChtc2dIYXNoKTsKICAgICAgY29uc3QgeyByLCBzIH0gPSBfc2lnOwogICAgICBjb25zdCBoID0gYml0czJpbnRfbW9kTihtc2dIYXNoKTsKICAgICAgY29uc3QgaXMgPSBpbnZOKHMpOwogICAgICBjb25zdCB1MSA9IG1vZE4yKGggKiBpcyk7CiAgICAgIGNvbnN0IHUyID0gbW9kTjIociAqIGlzKTsKICAgICAgY29uc3QgUiA9IFBvaW50Mi5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFAsIHUxLCB1Mik/LnRvQWZmaW5lKCk7CiAgICAgIGlmICghUikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGNvbnN0IHYgPSBtb2ROMihSLngpOwogICAgICByZXR1cm4gdiA9PT0gcjsKICAgIH0KICAgIHJldHVybiB7CiAgICAgIENVUlZFLAogICAgICBnZXRQdWJsaWNLZXksCiAgICAgIGdldFNoYXJlZFNlY3JldCwKICAgICAgc2lnbjogc2lnbjIsCiAgICAgIHZlcmlmeSwKICAgICAgUHJvamVjdGl2ZVBvaW50OiBQb2ludDIsCiAgICAgIFNpZ25hdHVyZSwKICAgICAgdXRpbHMKICAgIH07CiAgfQogIGZ1bmN0aW9uIFNXVUZwU3FydFJhdGlvKEZwMiwgWikgewogICAgY29uc3QgcSA9IEZwMi5PUkRFUjsKICAgIGxldCBsID0gXzBuNTsKICAgIGZvciAobGV0IG8gPSBxIC0gXzFuNTsgbyAlIF8ybjQgPT09IF8wbjU7IG8gLz0gXzJuNCkKICAgICAgbCArPSBfMW41OwogICAgY29uc3QgYzEgPSBsOwogICAgY29uc3QgXzJuX3Bvd19jMV8xID0gX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MTsgaSA+IF8xbjU7IGktLSkgewogICAgICAgIGxldCB0djUyID0gaSAtIF8ybjQ7CiAgICAgICAgdHY1MiA9IF8ybjQgPDwgdHY1MiAtIF8xbjU7CiAgICAgICAgbGV0IHR2djUgPSBGcDIucG93KHR2NCwgdHY1Mik7CiAgICAgICAgY29uc3QgZTEgPSBGcDIuZXFsKHR2djUsIEZwMi5PTkUpOwogICAgICAgIHR2MiA9IEZwMi5tdWwodHYzLCB0djEpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djEpOwogICAgICAgIHR2djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgICB0djMgPSBGcDIuY21vdih0djIsIHR2MywgZTEpOwogICAgICAgIHR2NCA9IEZwMi5jbW92KHR2djUsIHR2NCwgZTEpOwogICAgICB9CiAgICAgIHJldHVybiB7IGlzVmFsaWQ6IGlzUVIsIHZhbHVlOiB0djMgfTsKICAgIH07CiAgICBpZiAoRnAyLk9SREVSICUgXzRuMiA9PT0gXzNuMikgewogICAgICBjb25zdCBjMTIgPSAoRnAyLk9SREVSIC0gXzNuMikgLyBfNG4yOwogICAgICBjb25zdCBjMjIgPSBGcDIuc3FydChGcDIubmVnKFopKTsKICAgICAgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgICBsZXQgdHYxID0gRnAyLnNxcih2KTsKICAgICAgICBjb25zdCB0djIgPSBGcDIubXVsKHUsIHYpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djIpOwogICAgICAgIGxldCB5MSA9IEZwMi5wb3codHYxLCBjMTIpOwogICAgICAgIHkxID0gRnAyLm11bCh5MSwgdHYyKTsKICAgICAgICBjb25zdCB5MiA9IEZwMi5tdWwoeTEsIGMyMik7CiAgICAgICAgY29uc3QgdHYzID0gRnAyLm11bChGcDIuc3FyKHkxKSwgdik7CiAgICAgICAgY29uc3QgaXNRUiA9IEZwMi5lcWwodHYzLCB1KTsKICAgICAgICBsZXQgeSA9IEZwMi5j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KICAgICAgaW5pdF91dGlsczQoKTsKICAgICAgKHsgYnl0ZXNUb051bWJlckJFOiBiMm4sIGhleFRvQnl0ZXM6IGgyYiB9ID0gdXRpbHNfZXhwb3J0cyk7CiAgICAgIERFUiA9IHsKICAgICAgICAvLyBhc24uMSBERVIgZW5jb2RpbmcgdXRpbHMKICAgICAgICBFcnI6IGNsYXNzIERFUkVyciBleHRlbmRzIEVycm9yIHsKICAgICAgICAgIGNvbnN0cnVjdG9yKG0gPSAiIikgewogICAgICAgICAgICBzdXBlcihtKTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIEJhc2ljIGJ1aWxkaW5nIGJsb2NrIGlzIFRMViAoVGFnLUxlbmd0aC1WYWx1ZSkKICAgICAgICBfdGx2OiB7CiAgICAgICAgICBlbmNvZGU6ICh0YWcsIGRhdGEpID0+IHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgaWYgKHRhZyA8IDAgfHwgdGFnID4gMjU2KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZW5jb2RlOiB3cm9uZyB0YWciKTsKICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoICYgMSkKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogdW5wYWRkZWQgZGF0YSIpOwogICAgICAgICAgICBjb25zdCBkYXRhTGVuID0gZGF0YS5sZW5ndGggLyAyOwogICAgICAgICAgICBjb25zdCBsZW4gPSBudW1iZXJUb0hleFVucGFkZGVkKGRhdGFMZW4pOwogICAgICAgICAgICBpZiAobGVuLmxlbmd0aCAvIDIgJiAxMjgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5lbmNvZGU6IGxvbmcgZm9ybSBsZW5ndGggdG9vIGJpZyIpOwogICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBkYXRhTGVuID4gMTI3ID8gbnVtYmVyVG9IZXhVbnBhZGRlZChsZW4ubGVuZ3RoIC8gMiB8IDEyOCkgOiAiIjsKICAgICAgICAgICAgcmV0dXJuIGAke251bWJlclRvSGV4VW5wYWRkZWQodGFnKX0ke2xlbkxlbn0ke2xlbn0ke2RhdGF9YDsKICAgICAgICAgIH0sCiAgICAgICAgICAvLyB2IC0gdmFsdWUsIGwgLSBsZWZ0IGJ5dGVzICh1bnBhcnNlZCkKICAgICAgICAgIGRlY29kZSh0YWcsIGRhdGEpIHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgIGlmICh0YWcgPCAwIHx8IHRhZyA+IDI1NikKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogd3JvbmcgdGFnIik7CiAgICAgICAgICAgIGlmIChkYXRhLmxlbmd0aCA8IDIgfHwgZGF0YVtwb3MrK10gIT09IHRhZykKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZTogd3JvbmcgdGx2Iik7CiAgICAgICAgICAgIGNvbnN0IGZpcnN0ID0gZGF0YVtwb3MrK107CiAgICAgICAgICAgIGNvbnN0IGlzTG9uZyA9ICEhKGZpcnN0ICYgMTI4KTsKICAgICAgICAgICAgbGV0IGxlbmd0aCA9IDA7CiAgICAgICAgICAgIGlmICghaXNMb25nKQogICAgICAgICAgICAgIGxlbmd0aCA9IGZpcnN0OwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBmaXJzdCAmIDEyNzsKICAgICAgICAgICAgICBpZiAoIWxlbkxlbikKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBpbmRlZmluaXRlIGxlbmd0aCBub3Qgc3VwcG9ydGVkIik7CiAgICAgICAgICAgICAgaWYgKGxlbkxlbiA+IDQpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogYnl0ZSBsZW5ndGggaXMgdG9vIGJpZyIpOwogICAgICAgICAgICAgIGNvbnN0IGxlbmd0aEJ5dGVzID0gZGF0YS5zdWJhcnJheShwb3MsIHBvcyArIGxlbkxlbik7CiAgICAgICAgICAgICAgaWYgKGxlbmd0aEJ5dGVzLmxlbmd0aCAhPT0gbGVuTGVuKQogICAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5kZWNvZGU6IGxlbmd0aCBieXRlcyBub3QgY29tcGxldGUiKTsKICAgICAgICAgICAgICBpZiAobGVuZ3RoQnl0ZXNbMF0gPT09IDApCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogemVybyBsZWZ0bW9zdCBieXRlIik7CiAgICAgICAgICAgICAgZm9yIChjb25zdCBiIG9mIGxlbmd0aEJ5dGVzKQogICAgICAgICAgICAgICAgbGVuZ3RoID0gbGVuZ3RoIDw8IDggfCBiOwogICAgICAgICAgICAgIHBvcyArPSBsZW5MZW47CiAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IDEyOCkKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBub3QgbWluaW1hbCBlbmNvZGluZyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgbGVuZ3RoKTsKICAgICAgICAgICAgaWYgKHYubGVuZ3RoICE9PSBsZW5ndGgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5kZWNvZGU6IHdyb25nIHZhbHVlIGxlbmd0aCIpOwogICAgICAgICAgICByZXR1cm4geyB2LCBsOiBkYXRhLnN1YmFycmF5KHBvcyArIGxlbmd0aCkgfTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIGh0dHBzOi8vY3J5cHRvLnN0YWNrZXhjaGFuZ2UuY29tL2EvNTc3MzQgTGVmdG1vc3QgYml0IG9mIGZpcnN0IGJ5dGUgaXMgJ25lZ2F0aXZlJyBmbGFnLAogICAgICAgIC8vIHNpbmNlIHdlIGFsd2F5cyB1c2UgcG9zaXRpdmUgaW50ZWdlcnMgaGVyZS4gSXQgbXVzdCBhbHdheXMgYmUgZW1wdHk6CiAgICAgICAgLy8gLSBhZGQgemVybyBieXRlIGlmIGV4aXN0cwogICAgICAgIC8vIC0gaWYgbmV4dCBieXRlIGRvZXNuJ3QgaGF2ZSBhIGZsYWcsIGxlYWRpbmcgemVybyBpcyBub3QgYWxsb3dlZCAobWluaW1hbCBlbmNvZGluZykKICAgICAgICBfaW50OiB7CiAgICAgICAgICBlbmNvZGUobnVtMikgewogICAgICAgICAgICBjb25zdCB7IEVycjogRSB9ID0gREVSOwogICAgICAgICAgICBpZiAobnVtMiA8IF8wbjUpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoImludGVnZXI6IG5lZ2F0aXZlIGludGVnZXJzIGFyZSBub3QgYWxsb3dlZCIpOwogICAgICAgICAgICBsZXQgaGV4ID0gbnVtYmVyVG9IZXhVbnBhZGRlZChudW0yKTsKICAgICAgICAgICAgaWYgKE51bWJlci5wYXJzZUludChoZXhbMF0sIDE2KSAmIDgpCiAgICAgICAgICAgICAgaGV4ID0gIjAwIiArIGhleDsKICAgICAgICAgICAgaWYgKGhleC5sZW5ndGggJiAxKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ1bmV4cGVjdGVkIGFzc2VydGlvbiIpOwogICAgICAgICAgICByZXR1cm4gaGV4OwogICAgICAgICAgfSwKICAgICAgICAgIGRlY29kZShkYXRhKSB7CiAgICAgICAgICAgIGNvbnN0IHsgRXJyOiBFIH0gPSBERVI7CiAgICAgICAgICAgIGlmIChkYXRhWzBdICYgMTI4KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJJbnZhbGlkIHNpZ25hdHVyZSBpbnRlZ2VyOiBuZWdhdGl2ZSIpOwogICAgICAgICAgICBpZiAoZGF0YVswXS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dfMl8xMjggfHwgazIgPiBQT1dfMl8xMjgpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInNwbGl0U2NhbGFyOiBFbmRvbW9ycGhpc20gZmFpbGVkLCBrPSIgKyBrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4geyBrMW5lZywgazEsIGsybmVnLCBrMiB9OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSwgc2hhMjU2KTsKICAgICAgXzBuNiA9IEJpZ0ludCgwKTsKICAgICAgVEFHR0VEX0hBU0hfUFJFRklYRVMgPSB7fTsKICAgICAgcG9pbnRUb0J5dGVzID0gKHBvaW50KSA9PiBwb2ludC50b1Jhd0J5dGVzKHRydWUpLnNsaWNlKDEpOwogICAgICBudW1UbzMyYiA9IChuKSA9PiBudW1iZXJUb0J5dGVzQkUobiwgMzIpOwogICAgICBtb2RQID0gKHgpID0+IG1vZCh4LCBzZWNwMjU2azFQKTsKICAgICAgbW9kTiA9ICh4KSA9PiBtb2QoeCwgc2VjcDI1NmsxTik7CiAgICAgIFBvaW50ID0gc2VjcDI1NmsxLlByb2plY3RpdmVQb2ludDsKICAgICAgR211bEFkZCA9IChRLCBhLCBiKSA9PiBQb2ludC5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFEsIGEsIGIpOwogICAgICBudW0gPSBieXRlc1RvTnVtYmVyQkU7CiAgICAgIHNjaG5vcnIgPSAvKiBAX19QVVJFX18gKi8gKCgpID0+ICh7CiAgICAgICAgZ2V0UHVibGljS2V5OiBzY2hub3JyR2V0UHVibGljS2V5LAogICAgICAgIHNpZ246IHNjaG5vcnJTaWduLAogICAgICAgIHZlcmlmeTogc2Nobm9yclZlcmlmeSwKICAgICAgICB1dGlsczogewogICAgICAgICAgcmFuZG9tUHJpdmF0ZUtleTogc2VjcDI1NmsxLnV0aWxzLnJhbmRvbVByaXZhdGVLZXksCiAgICAgICAgICBsaWZ0X3gsCiAgICAgICAgICBwb2ludFRvQnl0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kgYCA6ICIifXByb3ZpZGVkIGZvciB0aGUgdHJhbnNhY3Rpb24gaXMgdG9vIGxvdy5gLCB7CiAgICAgICAgICAgIGNhdXNlLAogICAgICAgICAgICBuYW1lOiAiSW50cmluc2ljR2FzVG9vTG93RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnRyaW5zaWNHYXNUb29Mb3dFcnJvciwgIm5vZGVNZXNzYWdlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiAvaW50cmluc2ljIGdhcyB0b28gbG93LwogICAgICB9KTsKICAgICAgVHJhbnNhY3Rpb25UeXBlTm90U3VwcG9ydGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgY2F1c2UgfSkgewogICAgICAgICAgc3VwZXIoIlRoZSB0cmFuc2FjdGlvbiB0eXBlIGlzIG5vdCBzdXBwb3J0ZWQgZm9yIHRoaXMgY2hhaW4uIiwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgbmFtZTogIlRyYW5zYWN0aW9uVHlwZU5vdFN1cHBvcnRlZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoVHJhbnNhY3Rpb25UeXBlTm90U3VwcG9ydGVkRXJyb3IsICJub2RlTWVzc2FnZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogL3RyYW5zYWN0aW9uIHR5cGUgbm90IHZhbGlkLwogICAgICB9KTsKICAgICAgVGl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MTYsIG1heFVpbnQyNCwgbWF4VWludDMyLCBtYXhVaW50NDAsIG1heFVpbnQ0OCwgbWF4VWludDU2LCBtYXhVaW50NjQsIG1heFVpbnQ3MiwgbWF4VWludDgwLCBtYXhVaW50ODgsIG1heFVpbnQ5NiwgbWF4VWludDEwNCwgbWF4VWludDExMiwgbWF4VWludDEyMCwgbWF4VWludDEyOCwgbWF4VWludDEzNiwgbWF4VWludDE0NCwgbWF4VWludDE1MiwgbWF4VWludDE2MCwgbWF4VWludDE2OCwgbWF4VWludDE3NiwgbWF4VWludDE4NCwgbWF4VWludDE5MiwgbWF4VWludDIwMCwgbWF4VWludDIwOCwgbWF4VWludDIxNiwgbWF4VWludDIyNCwgbWF4VWludDIzMiwgbWF4VWludDI0MCwgbWF4VWludDI0OCwgbWF4VWludDI1NjsKICB2YXIgaW5pdF9udW1iZXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NvbnN0YW50cy9udW1iZXIuanMiKCkgewogICAgICBtYXhJbnQ4ID0gMm4gKiogKDhuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDE2ID0gMm4gKiogKDE2biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQyNCA9IDJuICoqICgyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MzIgPSAybiAqKiAoMzJuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDQwID0gMm4gKiogKDQwbiAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ0OCA9IDJuICoqICg0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50NTYgPSAybiAqKiAoNTZuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDY0ID0gMm4gKiogKDY0biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ3MiA9IDJuICoqICg3Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50ODAgPSAybiAqKiAoODBuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDg4ID0gMm4gKiogKDg4biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ5NiA9IDJuICoqICg5Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTA0ID0gMm4gKiogKDEwNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTEyID0gMm4gKiogKDExMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTIwID0gMm4gKiogKDEyMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTI4ID0gMm4gKiogKDEyOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTM2ID0gMm4gKiogKDEzNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTQ0ID0gMm4gKiogKDE0NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTUyID0gMm4gKiogKDE1Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTYwID0gMm4gKiogKDE2MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTY4ID0gMm4gKiogKDE2OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTc2ID0gMm4gKiogKDE3Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTg0ID0gMm4gKiogKDE4NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTkyID0gMm4gKiogKDE5Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjAwID0gMm4gKiogKDIwMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjA4ID0gMm4gKiogKDIwOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjE2ID0gMm4gKiogKDIxNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjI0ID0gMm4gKiogKDIyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjMyID0gMm4gKiogKDIzMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQwID0gMm4gKiogKDI0MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQ4ID0gMm4gKiogKDI0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjU2ID0gMm4gKiogKDI1Nm4gLSAxbikgLSAxbjsKICAgICAgbWluSW50OCA9IC0oMm4gKiogKDhuIC0gMW4pKTsKICAgICAgbWluSW50MTYgPSAtKDJuICoqICgxNm4gLSAxbikpOwogICAgICBtaW5JbnQyNCA9IC0oMm4gKiogKDI0biAtIDFuKSk7CiAgICAgIG1pbkludDMyID0gLSgybiAqKiAoMzJuIC0gMW4pKTsKICAgICAgbWluSW50NDAgPSAtKDJuICoqICg0MG4gLSAxbikpOwogICAgICBtaW5JbnQ0OCA9IC0oMm4gKiogKDQ4biAtIDFuKSk7CiAgICAgIG1pbkludDU2ID0gLSgybiAqKiAoNTZuIC0gMW4pKTsKICAgICAgbWluSW50NjQgPSAtKDJuICoqICg2NG4gLSAxbikpOwogICAgICBtaW5JbnQ3MiA9IC0oMm4gKiogKDcybiAtIDFuKSk7CiAgICAgIG1pbkludDgwID0gLSgybiAqKiAoODBuIC0gMW4pKTsKICAgICAgbWluSW50ODggPSAtKDJuICoqICg4OG4gLSAxbikpOwogICAgICBtaW5JbnQ5NiA9IC0oMm4gKiogKDk2biAtIDFuKSk7CiAgICAgIG1pbkludDEwNCA9IC0oMm4gKiogKDEwNG4gLSAxbikpOwogICAgICBtaW5JbnQxMTIgPSAtKDJuICoqICgxMTJuIC0gMW4pKTsKICAgICAgbWluSW50MTIwID0gLSgybiAqKiAoMTIwbiAtIDFuKSk7CiAgICAgIG1pbkludDEyOCA9IC0oMm4gKiogKDEyOG4gLSAxbikpOwogICAgICBtaW5JbnQxMzYgPSAtKDJuICoqICgxMzZuIC0gMW4pKTsKICAgICAgbWluSW50MTQ0ID0gLSgybiAqKiAoMTQ0biAtIDFuKSk7CiAgICAgIG1pbkludDE1MiA9IC0oMm4gKiogKDE1Mm4gLSAxbikpOwogICAgICBtaW5JbnQxNjAgPSAtKDJuICoqICgxNjBuIC0gMW4pKTsKICAgICAgbWluSW50MTY4ID0gLSgybiAqKiAoMTY4biAtIDFuKSk7CiAgICAgIG1pbkludDE3NiA9IC0oMm4gKiogKDE3Nm4gLSAxbikpOwogICAgICBtaW5JbnQxODQgPSAtKDJuICoqICgxODRuIC0gMW4pKTsKICAgICAgbWluSW50MTkyID0gLSgybiAqKiAoMTkybiAtIDFuKSk7CiAgICAgIG1pbkludDIwMCA9IC0oMm4gKiogKDIwMG4gLSAxbikpOwogICAgICBtaW5JbnQyMDggPSAtKDJuICoqICgyMDhuIC0gMW4pKTsKICAgICAgbWluSW50MjE2ID0gLSgybiAqKiAoMjE2biAtIDFuKSk7CiAgICAgIG1pbkludDIyNCA9IC0oMm4gKiogKDIyNG4gLSAxbikpOwogICAgICBtaW5JbnQyMzIgPSAtKDJuICoqICgyMzJuIC0gMW4pKTsKICAgICAgbWluSW50MjQwID0gLSgybiAqKiAoMjQwbiAtIDFuKSk7CiAgICAgIG1pbkludDI0OCA9IC0oMm4gKiogKDI0OG4gLSAxbikpOwogICAgICBtaW5JbnQyNTYgPSAtKDJuICoqICgyNTZuIC0gMW4pKTsKICAgICAgbWF4VWludDggPSAybiAqKiA4biAtIDFuOwogICAgICBtYXhVaW50MTYgPSAybiAqKiAxNm4gLSAxbjsKICAgICAgbWF4VWludDI0ID0gMm4gKiogMjRuIC0gMW47CiAgICAgIG1heFVpbnQzMiA9IDJuICoqIDMybiAtIDFuOwogICAgICBtYXhVaW50NDAgPSAybiAqKiA0MG4gLSAxbjsKICAgICAgbWF4VWludDQ4ID0gMm4gKiogNDhuIC0gMW47CiAgICAgIG1heFVpbnQ1NiA9IDJuICoqIDU2biAtIDFuOwogICAgICBtYXhVaW50NjQgPSAybiAqKiA2NG4gLSAxbjsKICAgICAgbWF4VWludDcyID0gMm4gKiogNzJuIC0gMW47CiAgICAgIG1heFVpbnQ4MCA9IDJuICoqIDgwbiAtIDFuOwogICAgICBtYXhVaW50ODggPSAybiAqKiA4OG4gLSAxbjsKIC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GVzL3ZpZW0vX2VzbS9jb25zdGFudHMvYWJpcy5qcyIoKSB7CiAgICAgIG11bHRpY2FsbDNBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJ0YXJnZXQiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJhbGxvd0ZhaWx1cmUiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJjYWxsRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJjYWxscyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiYWdncmVnYXRlMyIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdWNjZXNzIiwKICAgICAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJyZXR1cm5EYXRhIiwKICAgICAgICAgICAgICB0eXBlOiAidHVwbGVbXSIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0KICAgICAgXTsKICAgICAgdW5pdmVyc2FsUmVzb2x2ZXJFcnJvcnMgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG5hbWU6ICJSZXNvbHZlck5vdEZvdW5kIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBuYW1lOiAiUmVzb2x2ZXJXaWxkY2FyZE5vdFN1cHBvcnRlZCIsCiAgICAgICAgICB0eXBlOiAiZXJyb3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyTm90Q29udHJhY3QiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyRXJyb3IiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdGF0dXMiLAogICAgICAgICAgICAgICAgICB0eXBlOiAidWludDE2IgogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgbmFtZTogIm1lc3NhZ2UiLAogICAgICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgbmFtZTogImVycm9ycyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiSHR0cEVycm9yIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmVzb2x2ZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmVzb2x2ZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlcyIgfSwKICAgICAgICAgICAgeyBuYW1lOiAiZGF0YSIsIHR5cGU6ICJieXRlcyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJyZXNvbHZlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7IG5hbWU6ICJuYW1lIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJkYXRhIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJnYXRld2F5cyIsIHR5cGU6ICJzdHJpbmdbXSIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmV2ZXJzZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmV2ZXJzZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFt7IHR5cGU6ICJieXRlcyIsIG5hbWU6ICJyZXZlcnNlTmFtZSIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogInN0cmluZyIsIG5hbWU6ICJyZXNvbHZlZE5hbWUiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmVzb2x2ZWRBZGRyZXNzIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJldmVyc2VSZXNvbHZlciIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlciIgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgbmFtZTogInJldmVyc2UiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogImJ5dGVzIiwgbmFtZTogInJldmVyc2VOYW1lIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJzdHJpbmdbXSIsIG5hbWU6ICJnYXRld2F5cyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyB0eXBlOiAic3RyaW5nIiwgbmFtZTogInJlc29sdmVkTmFtZSIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlZEFkZHJlc3MiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmV2ZXJzZVJlc29sdmVyIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJlc29sdmVyIiB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICB0ZXh0UmVzb2x2ZXJBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgbmFtZTogInRleHQiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfSwKICAgICAgICAgICAgeyBuYW1lOiAia2V5IiwgdHlwZTogInN0cmluZyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgIH0KICAgICAgXTsKICAgICAgYWRkcmVzc1Jlc29sdmVyQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJhZGRyIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbeyBuYW1lOiAiIiwgdHlwZTogImFkZHJlc3MiIH1dCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAiYWRkciIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJjb2luVHlwZSIsIHR5cGU6ICJ1aW50MjU2IiB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJieXRlcyIgfV0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFNpZ25hdHVyZVZhbGlkYXRvckFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiY29uc3RydWN0b3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiaXNWYWxpZFNpZyIKICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzIwQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic3ltYm9sIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXIiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICBlcmMyMEFiaV9ieXRlczMyID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJieXRlczMyIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYnl0ZXMzMiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0b3RhbFN1cHBseSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmVjaXBpZW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhbW91bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzcyMUFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZXZlbnQiLAogICAgICAgICAgbmFtZTogIkFwcHJvdmFsIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImV2ZW50IiwKICAgICAgICAgIG5hbWU6ICJBcHByb3ZhbEZvckFsbCIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm9wZXJhdG9yIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhcHByb3ZlZCIsCiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRva2VuSWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImFwcHJvdmUiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAicGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiZ2V0QXBwcm92ZWQiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImlzQXBwcm92ZWRGb3JBbGwiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAibmFtZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogIm93bmVyT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic2FmZVRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJwYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImZyb20iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNhZmVUcmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiaWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImRhdGEiLAogICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNldEFwcHJvdmFsRm9yQWxsIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFwcHJvdmVkIiwKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImluZGV4IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJpbmRleCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG9rZW5JZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG9rZW5VUkkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRva2VJZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbXQogICAgICAgIH0KICAgICAgXTsKICAgICAgZXJjNDYyNkFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiRGVwb3NpdCIsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiV2l0aGRyYXciLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImFsbG93YW5jZSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJhcHByb3ZlIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogImFzc2V0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldFRva2VuQWRkcmVzcyIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJjb252ZXJ0VG9Bc3NldHMiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiY29udmVydFRvU2hhcmVzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJkZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJjYWxsZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heERlcG9zaXQiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm1heEFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImNhbGxlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAibWF4TWludCIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFJlZGVlbSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFdpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJtYXhBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJtaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdEZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdNaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdSZWRlZW0iLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicHJldmlld1dpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicmVkZWVtIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsQXNzZXRzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b3RhbE1hbmFnZWRBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsU3VwcGx5IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiZnJvbSIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG8iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0s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LCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBDdXJyZW50IENoYWluIElEOiAgJHtjdXJyZW50Q2hhaW5JZH1gLAogICAgICAgICAgICAgIGBFeHBlY3RlZCBDaGFpbiBJRDogJHtjaGFpbi5pZH0gXHUyMDEzICR7Y2hhaW4ubmFtZX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDaGFpbk1pc21hdGNoRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIENoYWluTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICAgICAgICJObyBjaGFpbiB3YXMgcHJvdmlkZWQgdG8gdGhlIHJlcXVlc3QuIiwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgY2hhaW4gd2l0aCB0aGUgYGNoYWluYCBhcmd1bWVudCBvbiB0aGUgQWN0aW9uLCBvciBieSBzdXBwbHlpbmcgYSBgY2hhaW5gIHRvIFdhbGxldENsaWVudC4iCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkNoYWluTm90Rm91bmRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ2xpZW50Q2hhaW5Ob3RDb25maWd1cmVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoIk5vIGNoYWluIHdhcyBwcm92aWRlZCB0byB0aGUgQ2xpZW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIkNsaWVudENoYWluTm90Q29uZmlndXJlZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkQ2hhaW5JZEV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U1lc3NhZ2VzPy5sZW5ndGggPyAiIiA6IFtdLAogICAgICAgICAgICAgICJPZmZjaGFpbiBHYXRld2F5IENhbGw6IiwKICAgICAgICAgICAgICB1cmxzICYmIFsKICAgICAgICAgICAgICAgICIgIEdhdGV3YXkgVVJMKHMpOiIsCiAgICAgICAgICAgICAgICAuLi51cmxzLm1hcCgodXJsKSA9PiBgICAgICR7Z2V0VXJsKHVybCl9YCkKICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIGAgIFNlbmRlcjogJHtzZW5kZXJ9YCwKICAgICAgICAgICAgICBgICBEYXRhOiAke2RhdGF9YCwKICAgICAgICAgICAgICBgICBDYWxsYmFjayBzZWxlY3RvcjogJHtjYWxsYmFja1NlbGVjdG9yfWAsCiAgICAgICAgICAgICAgYCAgRXh0cmEgZGF0YTogJHtleHRyYURhdGF9YAogICAgICAgICAgICBdLmZsYXQoKSwKICAgICAgICAgICAgbmFtZTogIk9mZmNoYWluTG9va3VwRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwUmVzcG9uc2VNYWxmb3JtZWRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyByZXN1bHQsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiT2ZmY2hhaW4gZ2F0ZXdheSByZXNwb25zZSBpcyBtYWxmb3JtZWQuIFJlc3BvbnNlIGRhdGEgbXVzdCBiZSBhIGhleCB2YWx1ZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBHYXRld2F5IFVSTDogJHtnZXRVcmwodXJsKX1gLAogICAgICAgICAgICAgIGBSZXNwb25zZTogJHtzdHJpbmdpZnkocmVzdWx0KX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cFJlc3BvbnNlTWFsZm9yb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VybiBkYXRhXzsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICB0aHJvdyBuZXcgT2ZmY2hhaW5Mb29rdXBFcnJvcih7CiAgICAgICAgY2FsbGJhY2tTZWxlY3RvciwKICAgICAgICBjYXVzZTogZXJyLAogICAgICAgIGRhdGEsCiAgICAgICAgZXh0cmFEYXRhLAogICAgICAgIHNlbmRlciwKICAgICAgICB1cmxzCiAgICAgIH0pOwogICAgfQogIH0KICBhc3luYyBmdW5jdGlvbiBjY2lwUmVxdWVzdCh7IGRhdGEsIHNlbmRlciwgdXJscyB9KSB7CiAgICBsZXQgZXJyb3IgPSBuZXcgRXJyb3IoIkFuIHVua25vd24gZXJyb3Igb2NjdXJyZWQuIik7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHVybHMubGVuZ3RoOyBpKyspIHsKICAgICAgY29uc3QgdXJsID0gdXJsc1tpXTsKICAgICAgY29uc3QgbWV0aG9kID0gdXJsLmluY2x1ZGVzKCJ7ZGF0YX0iKSA/ICJHRVQiIDogIlBPU1QiOwogICAgICBjb25zdCBib2R5ID0gbWV0aG9kID09PSAiUE9TVCIgPyB7IGRhdGEsIHNlbmRlciB9IDogdm9pZCAwOwogICAgICBjb25zdCBoZWFkZXJzID0gbWV0aG9kID09PSAiUE9TVCIgPyB7ICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24vanNvbiIgfSA6IHt9OwogICAgICB0cnkgewogICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsLnJlcGxhY2UoIntzZW5kZXJ9Iiwgc2VuZGVyKS5yZXBsYWNlKCJ7ZGF0YX0iLCBkYXRhKSwgewogICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksCiAgICAgICAgICBoZWFkZXJzLAogICAgICAgICAgbWV0aG9kCiAgICAgICAgfSk7CiAgICAgICAgbGV0IHJlc3VsdDsKICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpIHsKICAgICAgICAgIHJlc3VsdCA9IChhd2FpdCByZXNwb25zZS5qc29uKCkpLmRhdGE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHJlc3VsdCA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICB9CiAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgZXJyb3IgPSBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgIGRldGFpbHM6IHJlc3VsdD8uZXJyb3IgPyBzdHJpbmdpZnkocmVzdWx0LmVycm9yKSA6IHJlc3BvbnNlLnN0YXR1c1RleHQsCiAgICAgICAgICAgIGhlYWRlcnM6IHJlc3BvbnNlLmhlYWRlcnMsCiAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICghaXNIZXgocmVzdWx0KSkgewogICAgICAgICAgZXJyb3IgPSBuZXcgT2ZmY2hhaW5Mb29rdXBSZXNwb25zZU1hbGZvcm1lZEVycm9yKHsKICAgICAgICAgICAgcmVzdWx0LAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgIGVycm9yID0gbmV3IEh0dHBSZXF1ZXN0RXJyb3IoewogICAgICAgICAgYm9keSwKICAgICAgICAgIGRldGFpbHM6IGVyci5tZXNzYWdlLAogICAgICAgICAgdXJsCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIHRocm93IGVycm9yOwogIH0KICB2YXIgb2ZmY2hhaW5Mb29rdXBTaWduYXR1cmUsIG9mZmNoYWluTG9va3VwQWJpSXRlbTsKICB2YXIgaW5pdF9jY2lwMiA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2NpcC5qcyIoKSB7CiAgICAgIGluaXRfY2FsbCgpOwogICAgICBpbml0X2NjaXAoKTsKICAgICAgaW5pdF9yZXF1ZXN0KCk7CiAgICAgIGluaXRfZGVjb2RlRXJyb3JSZXN1bHQoKTsKICAgICAgaW5pdF9lbmNvZGVBYmlQYXJhbWV0ZXJzKCk7CiAgICAgIGluaXRfaXNBZGRyZXNzRXF1YWwoKTsKICAgICAgaW5pdF9jb25jYXQoKTsKICAgICAgaW5pdF9pc0hleCgpOwogICAgICBpbml0X3N0cmluZ2lmeSgpOwogICAgICBvZmZjaGFpbkxvb2t1cFNpZ25hdHVyZSA9ICIweDU1NmYxODMwIjsKICAgICAgb2ZmY2hhaW5Mb29rdXBBYmlJdGVtID0gewogICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cCIsCiAgICAgICAgdHlwZTogImVycm9yIiwKICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInVybHMiLAogICAgICAgICAgICB0eXBlOiAic3RyaW5nW10iCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbERhdGEiLAogICAgICAgICAgICB0eXBlOiAiYnl0ZXMiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbGJhY2tGdW5jdGlvbiIsCiAgICAgICAgICAgIHR5cGU6ICJieXRlczQiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiZXh0cmFEYXRhI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x0aWNhbGxBZGRyZXNzOiBtdWx0aWNhbGxBZGRyZXNzXywgdG8gfSA9IGFyZ3M7CiAgICBsZXQgbXVsdGljYWxsQWRkcmVzcyA9IG11bHRpY2FsbEFkZHJlc3NfOwogICAgaWYgKCFtdWx0aWNhbGxBZGRyZXNzKSB7CiAgICAgIGlmICghY2xpZW50LmNoYWluKQogICAgICAgIHRocm93IG5ldyBDbGllbnRDaGFpbk5vdENvbmZpZ3VyZWRFcnJvcigpOwogICAgICBtdWx0aWNhbGxBZGRyZXNzID0gZ2V0Q2hhaW5Db250cmFjdEFkZHJlc3MoewogICAgICAgIGJsb2NrTnVtYmVyLAogICAgICAgIGNoYWluOiBjbGllbnQuY2hhaW4sCiAgICAgICAgY29udHJhY3Q6ICJtdWx0aWNhbGwzIgogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGJsb2NrTnVtYmVySGV4ID0gYmxvY2tOdW1iZXIgPyBudW1iZXJUb0hleChibG9ja051bWJlcikgOiB2b2lkIDA7CiAgICBjb25zdCBibG9jayA9IGJsb2NrTnVtYmVySGV4IHx8IGJsb2NrVGFnOwogICAgY29uc3QgeyBzY2hlZHVsZSB9ID0gY3JlYXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICBpZDogYCR7Y2xpZW50LnVpZH0uJHtibG9ja31gLAogICAgICB3YWl0OiB3YWl0MiwKICAgICAgc2hvdWxkU3BsaXRCYXRjaChhcmdzMikgewogICAgICAgIGNvbnN0IHNpemUzID0gYXJnczIucmVkdWNlKChzaXplNCwgeyBkYXRhOiBkYXRhMiB9KSA9PiBzaXplNCArIChkYXRhMi5sZW5ndGggLSAyKSwgMCk7CiAgICAgICAgcmV0dXJuIHNpemUzID4gYmF0Y2hTaXplICogMjsKICAgICAgfSwKICAgICAgZm46IGFzeW5jIChyZXF1ZXN0cykgPT4gewogICAgICAgIGNvbnN0IGNhbGxzID0gcmVxdWVzdHMubWFwKChyZXF1ZXN0KSA9PiAoewogICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgY2FsbERhdGE6IHJlcXVlc3QuZGF0YSwKICAgICAgICAgIHRhcmdldDogcmVxdWVzdC50bwogICAgICAgIH0pKTsKICAgICAgICBjb25zdCBjYWxsZGF0YSA9IGVuY29kZUZ1bmN0aW9uRGF0YSh7CiAgICAgICAgICBhYmk6IG11bHRpY2FsbDNBYmksCiAgICAgICAgICBhcmdzOiBbY2FsbHNdLAogICAgICAgICAgZnVuY3Rpb25OYW1lOiAiYWdncmVnYXRlMyIKICAgICAgICB9KTsKICAgICAgICBjb25zdCBkYXRhMiA9IGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgIG1ldGhvZDogImV0aF9jYWxsIiwKICAgICAgICAgIHBhcmFtczogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgZGF0YTogY2FsbGRhdGEsCiAgICAgICAgICAgICAgdG86IG11bHRpY2FsbEFkZHJlc3MKICAgICAgICAgICAgfSwKICAgICAgICAgICAgYmxvY2sKICAgICAgICAgIF0KICAgICAgICB9KTsKICAgICAgICByZXR1cm4gZGVjb2RlRnVuY3Rpb25SZXN1bHQoewogICAgICAgICAgYWJpOiBtdWx0aWNhbGwzQWJpLAogICAgICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgICAgIGZ1bmN0aW9uTmFtZTogImFnZ3JlZ2F0ZTMiLAogICAgICAgICAgZGF0YTogZGF0YTIgfHwgIjB4IgogICAgICAgIH0pOwogICAgICB9CiAgICB9KTsKICAgIGNvbnN0IFt7IHJldHVybkRhdGEsIHN1Y2Nlc3MgfV0gPSBhd2FpdCBzY2hlZHVsZSh7IGRhdGEsIHRvIH0pOwogICAgaWYgKCFzdWNjZXNzKQogICAgICB0aHJvdyBuZXcgUmF3Q29udHJhY3RFcnJvcih7IGRhdGE6IHJldHVybkRhdGEgfSk7CiAgICBpZiAocmV0dXJuRGF0YSA9PT0gIjB4IikKICAgICAgcmV0dXJuIHsgZGF0YTogdm9pZCAwIH07C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0hhc2g6ICgpID0+IGlzSGFzaCwKICAgIGlzSGV4OiAoKSA9PiBpc0hleCwKICAgIGtlY2NhazI1NjogKCkgPT4ga2VjY2FrMjU2LAogICAgbGFiZWxoYXNoOiAoKSA9PiBsYWJlbGhhc2gsCiAgICBtYXhJbnQxMDQ6ICgpID0+IG1heEludDEwNCwKICAgIG1heEludDExMjogKCkgPT4gbWF4SW50MTEyLAogICAgbWF4SW50MTIwOiAoKSA9PiBtYXhJbnQxMjAsCiAgICBtYXhJbnQxMjg6ICgpID0+IG1heEludDEyOCwKICAgIG1heEludDEzNjogKCkgPT4gbWF4SW50MTM2LAogICAgbWF4SW50MTQ0OiAoKSA9PiBtYXhJbnQxNDQsCiAgICBtYXhJbnQxNTI6ICgpID0+IG1heEludDE1MiwKICAgIG1heEludDE2OiAoKSA9PiBtYXhJbnQxNiwKICAgIG1heEludDE2MDogKCkgPT4gbWF4SW50MTYwLAogICAgbWF4SW50MTY4OiAoKSA9PiBtYXhJbnQxNjgsCiAgICBtYXhJbnQxNzY6ICgpID0+IG1heEludDE3NiwKICAgIG1heEludDE4NDogKCkgPT4gbWF4SW50MTg0LAogICAgbWF4SW50MTkyOiAoKSA9PiBtYXhJbnQxOTIsCiAgICBtYXhJbnQyMDA6ICgpID0+IG1heEludDIwMCwKICAgIG1heEludDIwODogKCkgPT4gbWF4SW50MjA4LAogICAgbWF4SW50MjE2OiAoKSA9PiBtYXhJbnQyMTYsCiAgICBtYXhJbnQyMjQ6ICgpID0+IG1heEludDIyNCwKICAgIG1heEludDIzMjogKCkgPT4gbWF4SW50MjMyLAogICAgbWF4SW50MjQ6ICgpID0+IG1heEludDI0LAogICAgbWF4SW50MjQwOiAoKSA9PiBtYXhJbnQyNDAsCiAgICBtYXhJbnQyNDg6ICgpID0+IG1heEludDI0OCwKICAgIG1heEludDI1NjogKCkgPT4gbWF4SW50MjU2LAogICAgbWF4SW50MzI6ICgpID0+IG1heEludDMyLAogICAgbWF4SW50NDA6ICgpID0+IG1heEludDQwLAogICAgbWF4SW50NDg6ICgpID0+IG1heEludDQ4LAogICAgbWF4SW50NTY6ICgpID0+IG1heEludDU2LAogICAgbWF4SW50NjQ6ICgpID0+IG1heEludDY0LAogICAgbWF4SW50NzI6ICgpID0+IG1heEludDcyLAogICAgbWF4SW50ODogKCkgPT4gbWF4SW50OCwKICAgIG1heEludDgwOiAoKSA9PiBtYXhJbnQ4MCwKICAgIG1heEludDg4OiAoKSA9PiBtYXhJbnQ4OCwKICAgIG1heEludDk2OiAoKSA9PiBtYXhJbnQ5NiwKICAgIG1heFVpbnQxMDQ6ICgpID0+IG1heFVpbnQxMDQsCiAgICBtYXhVaW50MTEyOiAoKSA9PiBtYXhVaW50MTEyLAogICAgbWF4VWludDEyMDogKCkgPT4gbWF4VWludDEyMCwKICAgIG1heFVpbnQxMjg6ICgpID0+IG1heFVpbnQxMjgsCiAgICBtYXhVaW50MTM2OiAoKSA9PiBtYXhVaW50MTM2LAogICAgbWF4VWludDE0NDogKCkgPT4gbWF4VWludDE0NCwKICAgIG1heFVpbnQxNTI6ICgpID0+IG1heFVpbnQxNTIsCiAgICBtYXhVaW50MTY6ICgpID0+IG1heFVpbnQxNiwKICAgIG1heFVpbnQxNjA6ICgpID0+IG1heFVpbnQxNjAsCiAgICBtYXhVaW50MTY4OiAoKSA9PiBtYXhVaW50MTY4LAogICAgbWF4VWludDE3NjogKCkgPT4gbWF4VWludDE3NiwKICAgIG1heFVpbnQxODQ6ICgpID0+IG1heFVpbnQxODQsCiAgICBtYXhVaW50MTkyOiAoKSA9PiBtYXhVaW50MTkyLAogICAgbWF4VWludDIwMDogKCkgPT4gbWF4VWludDIwMCwKICAgIG1heFVpbnQyMDg6ICgpID0+IG1heFVpbnQyMDgsCiAgICBtYXhVaW50MjE2OiAoKSA9PiBtYXhVaW50MjE2LAogICAgbWF4VWludDIyNDogKCkgPT4gbWF4VWludDIyNCwKICAgIG1heFVpbnQyMzI6ICgpID0+IG1heFVpbnQyMzIsCiAgICBtYXhVaW50MjQ6ICgpID0+IG1heFVpbnQyNCwKICAgIG1heFVpbnQyNDA6ICgpID0+IG1heFVpbnQyNDAsCiAgICBtYXhVaW50MjQ4OiAoKSA9PiBtYXhVaW50MjQ4LAogICAgbWF4VWludDI1NjogKCkgPT4gbWF4VWludDI1NiwKICAgIG1heFVpbnQzMjogKCkgPT4gbWF4VWludDMyLAogICAgbWF4VWludDQwOiAoKSA9PiBtYXhVaW50NDAsCiAgICBtYXhVaW50NDg6ICgpID0+IG1heFVpbnQ0OCwKICAgIG1heFVpbnQ1NjogKCkgPT4gbWF4VWludDU2LAogICAgbWF4VWludDY0OiAoKSA9PiBtYXhVaW50NjQsCiAgICBtYXhVaW50NzI6ICgpID0+IG1heFVpbnQ3MiwKICAgIG1heFVpbnQ4OiAoKSA9PiBtYXhVaW50OCwKICAgIG1heFVpbnQ4MDogKCkgPT4gbWF4VWludDgwLAogICAgbWF4VWludDg4OiAoKSA9PiBtYXhVaW50ODgsCiAgICBtYXhVaW50OTY6ICgpID0+IG1heFVpbnQ5NiwKICAgIG1pbkludDEwNDogKCkgPT4gbWluSW50MTA0LAogICAgbWluSW50MTEyOiAoKSA9PiBtaW5JbnQxMTIsCiAgICBtaW5JbnQxMjA6ICgpID0+IG1pbkludDEyMCwKICAgIG1pbkludDEyODogKCkgPT4gbWluSW50MTI4LAogICAgbWluSW50MTM2OiAoKSA9PiBtaW5JbnQxMzYsCiAgICBtaW5JbnQxNDQ6ICgpID0+IG1pbkludDE0NCwKICAgIG1pbkludDE1MjogKCkgPT4gbWluSW50MTUyLAogICAgbWluSW50MTY6ICgpID0+IG1pbkludDE2LAogICAgbWluSW50MTYwOiAoKSA9PiBtaW5JbnQxNjAsCiAgICBtaW5JbnQxNjg6ICgpID0+IG1pbkludDE2OCwKICAgIG1pbkludDE3NjogKCkgPT4gbWluSW50MTc2LAogICAgbWluSW50MTg0OiAoKSA9PiBtaW5JbnQxODQsCiAgICBtaW5JbnQxOTI6ICgpID0+IG1pbkludDE5MiwKICAgIG1pbkludDIwMDogKCkgPT4gbWluSW50MjAwLAogICAgbWluSW50MjA4OiAoKSA9PiBtaW5JbnQyMDgsCiAgICBtaW5JbnQyMTY6ICgpID0+IG1pbkludDIxNiwKICAgIG1pbkludDIyNDogKCkgPT4gbWluSW50MjI0LAogICAgbWluSW50MjMyOiAoKSA9PiBtaW5JbnQyMzIsCiAgICBtaW5JbnQyNDogKCkgPT4gbWluSW50MjQsCiAgICBtaW5JbnQyNDA6ICgpID0+IG1pbkludDI0MCwKICAgIG1pbkludDI0ODogKCkgPT4gbWluSW50MjQ4LAogICAgbWluSW50MjU2OiAoKSA9PiBtaW5JbnQyNTYsCiAgICBtaW5JbnQzMjogKCkgPT4gbWluSW50MzIsCiAgICBtaW5JbnQ0MDogKCkgPT4gbWluSW50NDAsCiAgICBtaW5JbnQ0ODogKCkgPT4gbWluSW50NDgsCiAgICBtaW5JbnQ1NjogKCkgPT4gbWluSW50NTYsCiAgICBtaW5JbnQ2NDogKCkgPT4gbWluSW50NjQsCiAgICBtaW5JbnQ3MjogKCkgPT4gbWluSW50NzIsCiAgICBtaW5JbnQ4OiAoKSA9PiBtaW5JbnQ4LAogICAgbWluSW50ODA6ICgpID0+IG1pbkludDgwLAogICAgbWluSW50ODg6ICgpID0+IG1pbkludDg4LAogICAgbWluSW50OTY6ICgpID0+IG1pbkludDk2LAogICAgbXVsdGljYWxsM0FiaTogKCkgPT4gbXVsdGljYWxsM0FiaSwKICAgIG5hbWVoYXNoOiAoKSA9PiBuYW1laGFzaCwKICAgIG5vbmNlTWFuYWdlcjogKCkgPT4gbm9uY2VNYW5hZ2VyLAogICAgbnVtYmVyVG9CeXRlczogKCkgPT4gbnVtYmVyVG9CeXRlcywKICAgIG51bWJlclRvSGV4OiAoKSA9PiBudW1iZXJUb0hleCwKICAgIG9mZmNoYWluTG9va3VwOiAoKSA9PiBvZmZjaGFpbkxvb2t1cCwKICAgIG9mZmNoYWluTG9va3VwQWJpSXRlbTogKCkgPT4g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iBjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyKGNsaWVudCwgcGFyYW1ldGVycykgewogICAgY29uc3QgeyBhZGRyZXNzLCBhYmk6IGFiaTIsIGFyZ3MsIGV2ZW50TmFtZSwgZnJvbUJsb2NrLCBzdHJpY3QsIHRvQmxvY2sgfSA9IHBhcmFtZXRlcnM7CiAgICBjb25zdCBnZXRSZXF1ZXN0ID0gY3JlYXRlRmlsdGVyUmVxdWVzdFNjb3BlKGNsaWVudCwgewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIgogICAgfSk7CiAgICBjb25zdCB0b3BpY3MgPSBldmVudE5hbWUgPyBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lCiAgICB9KSA6IHZvaWQgMDsKICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgdG9waWNzCiAgICAgICAgfQogICAgICBdCiAgICB9KTsKICAgIHJldHVybiB7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lLAogICAgICBpZCwKICAgICAgcmVxdWVzdDogZ2V0UmVxdWVzdChpZCksCiAgICAgIHN0cmljdDogQm9vbGVhbihzdHJpY3QpLAogICAgICB0eXBlOiAiZXZlbnQiCiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2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uc3Qgc2l6ZV8gPSBzaXplKGRhdGEpOwogICAgaWYgKCFzaXplXykKICAgICAgdGhyb3cgbmV3IEVtcHR5QmxvYkVycm9yKCk7CiAgICBpZiAoc2l6ZV8gPiBtYXhCeXRlc1BlclRyYW5zYWN0aW9uKQogICAgICB0aHJvdyBuZXcgQmxvYlNpemVUb29MYXJnZUVycm9yKHsKICAgICAgICBtYXhTaXplOiBtYXhCeXRlc1BlclRyYW5zYWN0aW9uLAogICAgICAgIHNpemU6IHNpemVfCiAgICAgIH0pOwogICAgY29uc3QgYmxvYnMgPSBbXTsKICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgbGV0IHBvc2l0aW9uID0gMDsKICAgIHdoaWxlIChhY3RpdmUpIHsKICAgICAgY29uc3QgYmxvYiA9IGNyZWF0ZUN1cnNvcihuZXcgVWludDhBcnJheShieXRlc1BlckJsb2IpKTsKICAgICAgbGV0IHNpemUzID0gMDsKICAgICAgd2hpbGUgKHNpemUzIDwgZmllbGRFbGVtZW50c1BlckJsb2IpIHsKICAgICAgICBjb25zdCBieXRlczIgPSBkYXRhLnNsaWNlKHBvc2l0aW9uLCBwb3NpdGlvbiArIChieXRlc1BlckZpZWxkRWxlbWVudCAtIDEpKTsKICAgICAgICBibG9iLnB1c2hCeXRlKDApOwogICAgICAgIGJsb2IucHVzaEJ5dGVzKGJ5dGVzMik7CiAgICAgICAgaWYgKGJ5dGVzMi5sZW5ndGggPCAzMSkgewogICAgICAgICAgYmxvYi5wdXNoQnl0ZSgxMjgpOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgc2l6ZTMrKzsKICAgICAgICBwb3NpdGlvbiArPSAzMTsKICAgICAgfQogICAgICBibG9icy5wdXNoKGJsb2IpOwogICAgfQogICAgcmV0dXJuIHRvID09PSAiYnl0ZXMiID8gYmxvYnMubWFwKCh4KSA9PiB4LmJ5dGVzKSA6IGJsb2JzLm1hcCgoeCkg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WNjb3VudCA9IGFjY291bnRfID8gcGFyc2VBY2NvdW50KGFjY291bnRfKSA6IGFjY291bnRfOwogICAgY29uc3QgcmVxdWVzdCA9IHsgLi4uYXJncywgLi4uYWNjb3VudCA/IHsgZnJvbTogYWNjb3VudD8uYWRkcmVzcyB9IDoge30gfTsKICAgIGxldCBibG9jazsKICAgIGFzeW5jIGZ1bmN0aW9uIGdldEJsb2NrMigpIHsKICAgICAgaWYgKGJsb2NrKQogICAgICAgIHJldHVybiBibG9jazsKICAgICAgYmxvY2sgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRCbG9jaywgImdldEJsb2NrIikoeyBibG9ja1RhZzogImxhdGVzdCIgfSk7CiAgICAgIHJldHVybiBibG9jazsKICAgIH0KICAgIGxldCBjaGFpbklkOwogICAgYXN5bmMgZnVuY3Rpb24gZ2V0Q2hhaW5JZDIoKSB7CiAgICAgIGlmIChjaGFpbklkKQogICAgICAgIHJldHVybiBjaGFpbklkOwogICAgICBpZiAoY2hhaW4pCiAgICAgICAgcmV0dXJuIGNoYWluLmlkOwogICAgICBpZiAodHlwZW9mIGFyZ3MuY2hhaW5JZCAhPT0gInVuZGVmaW5lZCIpCiAgICAgICAgcmV0dXJuIGFyZ3MuY2hhaW5JZDsKICAgICAgY29uc3QgY2hhaW5JZF8gPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRDaGFpbklkLCAiZ2V0Q2hhaW5JZCIpKHt9KTsKICAgICAgY2hhaW5JZCA9IGNoYWluSWRfOwogICAgICByZXR1cm4gY2hhaW5JZDsKICAgIH0KICAgIGlmICgocGFyYW1ldGVycy5pbmNsdWRlcygiYmxvYlZlcnNpb25lZEhhc2hlcyIpIHx8IHBhcmFtZXRlcnMuaW5jbHVkZXMoInNpZGVjYXJzIikpICYmIGJsb2JzICYmIGt6ZykgewogICAgICBjb25zdCBjb21taXRtZW50cyA9IGJsb2JzVG9Db21taXRtZW50cyh7IGJsb2JzLCBremcgfSk7CiAg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GFjY291bnQuYWRkcmVzcywKICAgICAgICAgIGNoYWluSWQ6IGNoYWluSWQyLAogICAgICAgICAgY2xpZW50CiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmVxdWVzdC5ub25jZSA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uQ291bnQsICJnZXRUcmFuc2FjdGlvbkNvdW50IikoewogICAgICAgICAgYWRkcmVzczogYWNjb3VudC5hZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBpZiAoKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSB8fCBwYXJhbWV0ZXJzLmluY2x1ZGVzKCJ0eXBlIikpICYmIHR5cGVvZiB0eXBlID09PSAidW5kZWZpbmVkIikgewogICAgICB0cnkgewogICAgICAgIHJlcXVlc3QudHlwZSA9IGdldFRyYW5zYWN0aW9uVHlwZShyZXF1ZXN0KTsKICAgICAgfSBjYXRjaCB7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgcmVxdWVzdC50eXBlID0gdHlwZW9mIGJsb2NrMj8uYmFzZUZlZVBlckdhcyA9PT0gImJpZ2ludCIgPyAiZWlwMTU1OSIgOiAibGVnYWN5IjsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSkgewogICAgICBpZiAocmVxdWVzdC50eXBlICE9PSAibGVnYWN5IiAmJiByZXF1ZXN0LnR5cGUgIT09ICJlaXAyOTMwIikgewogICAgICAgIGlmICh0eXBlb2YgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiByZXF1ZXN0Lm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgICBjb25zdCB7IG1heEZlZVBlckdhcywgbWF4UHJpb3JpdHlGZWVQZXJHYXMgfSA9IGF3YWl0IGludGVybmFsX2VzdGltYXRlRmVlc1BlckdhcyhjbGllbnQsIHsKICAgICAgICAgICAgYmxvY2s6IGJsb2NrMiwKICAgICAgICAgICAgY2hhaW4sCiAgICAgICAgICAgIHJlcXVlc3QKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIiAmJiBhcmdzLm1heEZlZVBlckdhcyAmJiBhcmdzLm1heEZlZVBlckdhcyA8IG1heFByaW9yaXR5RmVlUGVyR2FzKQogICAgICAgICAgICB0aHJvdyBuZXcgTWF4RmVlUGVyR2FzVG9vTG93RXJyb3IoewogICAgICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzCiAgICAgICAgICAgIH0pOwogICAgICAgICAgcmVxdWVzdC5tYXhQcmlvcml0eUZlZVBlckdhcyA9IG1heFByaW9yaXR5RmVlUGVyR2FzOwogICAgICAgICAgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPSBtYXhGZWVQZXJHYXM7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICh0eXBlb2YgYXJncy5tYXhGZWVQZXJHYXMgIT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZpbmVkIikKICAgICAgICAgIHRocm93IG5ldyBFaXAxNTU5RmVlc05vdFN1cHBvcnRlZEVycm9yKCk7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgY29uc3QgeyBnYXNQcmljZTogZ2FzUHJpY2VfIH0gPSBhd2FpdCBpbnRlcm5hbF9lc3RpbWF0ZUZlZXNQZXJHYXMoY2xpZW50LCB7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pXTsKICAgICAgY29uc3QgdG9waWMgPSBhcmdUb3BpY3NbaV07CiAgICAgIGlmICghdG9waWMpCiAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ1RvcGljc01pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBwYXJhbQogICAgICAgIH0pOwogICAgICBhcmdzW2lzVW5uYW1lZCA/IGkgOiBwYXJhbS5uYW1lIHx8IGldID0gZGVjb2RlVG9waWMoeyBwYXJhbSwgdmFsdWU6IHRvcGljIH0pOwogICAgfQogICAgY29uc3Qgbm9uSW5kZXhlZElucHV0cyA9IGlucHV0cy5maWx0ZXIoKHgpID0+ICEoImluZGV4ZWQiIGluIHggJiYgeC5pbmRleGVkKSk7CiAgICBpZiAobm9uSW5kZXhlZElucHV0cy5sZW5ndGggPiAwKSB7CiAgICAgIGlmIChkYXRhICYmIGRhdGEgIT09ICIweCIpIHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgZGVjb2RlZERhdGEgPSBkZWNvZGVBYmlQYXJhbWV0ZXJzKG5vbkluZGV4ZWRJbnB1dHMsIGRhdGEpOwogICAgICAgICAgaWYgKGRlY29kZWREYXRhKSB7CiAgICAgICAgICAgIGlmIChpc1VubmFtZWQpCiAgICAgICAgICAgICAgYXJncyA9IFsuLi5hcmdzLCAuLi5kZWNvZGVkRGF0YV07CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbm9uSW5kZXhlZElucHV0cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgYXJnc1tub25JbmRleGVkSW5wdXRzW2ldLm5hbWVdID0gZGVjb2RlZERhdGFbaV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICBpZiAoc3RyaWN0KSB7CiAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBBYmlEZWNvZGluZ0RhdGFTaXplVG9vU21hbGxFcnJvciB8fCBlcnIgaW5zdGFuY2VvZiBQb3NpdGlvbk91dE9mQm91bmRzRXJyb3IpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ0RhdGFNaXNtYXRjaCh7CiAgICAgICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgIHBhcmFtczogbm9uSW5kZXhlZElucHV0cywKICAgICAgICAgICAgICAgIHNpemU6IHNpemUoZGF0YSkKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChzdHJpY3QpIHsKICAgICAgICB0aHJvdyBuZXcgRGVjb2RlTG9nRGF0YU1pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBkYXRhOiAiMHgiLAogICAgICAgICAgcGFyYW1zOiBub25JbmRleGVkSW5wdXRzLAogICAgICAgICAgc2l6ZTogMAogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBldmVudE5hbWU6IG5hbWUsCiAgICAgIGFyZ3M6IE9iamVjdC52YWx1ZXMoYXJncykubGVuZ3RoID4gMCA/IGFyZ3MgOiB2b2lkIDAKICAgIH07CiAgfQogIGZ1bmN0aW9uIGRlY29kZVRvcGljKHsgcGFyYW0sIHZhbHVlIH0pIHsKICAgIGlmIChwYXJhbS50eXBlID09PSAic3RyaW5nIiB8fCBwYXJhbS50eXBlID09PSAiYnl0ZXMiIHx8IHBhcmFtLnR5cGUgPT09ICJ0dXBsZSIgfHwgcGFyYW0udHlwZS5tYXRjaCgvXiguKilcWyhcZCspP1xdJC8pKQogICAgICByZXR1cm4gdmFsdWU7CiAgICBjb25zdCBkZWNvZGVkQXJnID0gZGVjb2RlQWJpUGFyYW1ldGVycyhbcGFyYW1dLCB2YWx1ZSkgfHwgW107CiAgIC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FyZ3M6IGV2ZW50c18gPyB2b2lkIDAgOiBhcmdzCiAgICAgIH0pKTsKICAgICAgdG9waWNzID0gW2VuY29kZWRdOwogICAgICBpZiAoZXZlbnQpCiAgICAgICAgdG9waWNzID0gdG9waWNzWzBdOwogICAgfQogICAgbGV0IGxvZ3M7CiAgICBpZiAoYmxvY2tIYXNoKSB7CiAgICAgIGxvZ3MgPSBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgbWV0aG9kOiAiZXRoX2dldExvZ3MiLAogICAgICAgIHBhcmFtczogW3sgYWRkcmVzcywgdG9waWNzLCBibG9ja0hhc2ggfV0KICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBsb2dzID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9nZXRMb2dzIiwKICAgICAgICBwYXJhbXM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgdG9waWNzLAogICAgICAgICAgICBmcm9tQmxvY2s6IHR5cGVvZiBmcm9tQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgoZnJvbUJsb2NrKSA6IGZyb21CbG9jaywKICAgICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGZvcm1hdHRlZExvZ3MgPSBsb2dzLm1hcCgobG9nKSA9PiBmb3JtYXRMb2cobG9nKSk7CiAgICBpZiAoIWV2ZW50cykKICAgICAgcmV0dXJuIGZvcm1hdHRlZExvZ3M7CiAgICByZXR1cm4gcGFyc2VFdmVudExvZ3MoewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgbG9nczogZm9ybWF0dGVkTG9ncywKICAgICAgc3RyaWN0CiAgICB9KTsKICB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yLCBwcm9taXNlQ2FjaGUpOwogICAgY29uc3QgcmVzcG9uc2UgPSBidWlsZENhY2hlKGNhY2hlS2V5MiwgcmVzcG9uc2VDYWNoZSk7CiAgICByZXR1cm4gewogICAgICBjbGVhcjogKCkgPT4gewogICAgICAgIHByb21pc2UuY2xlYXIoKTsKICAgICAgICByZXNwb25zZS5jbGVhcigpOwogICAgICB9LAogICAgICBwcm9taXNlLAogICAgICByZXNwb25zZQogICAgfTsKICB9CiAgYXN5bmMgZnVuY3Rpb24gd2l0aENhY2hlKGZuLCB7IGNhY2hlS2V5OiBjYWNoZUtleTIsIGNhY2hlVGltZSA9IE51bWJlci5QT1NJVElWRV9JTkZJTklUWSB9KSB7CiAgICBjb25zdCBjYWNoZSA9IGdldENhY2hlKGNhY2hlS2V5Mik7CiAgICBjb25zdCByZXNwb25zZSA9IGNhY2hlLnJlc3BvbnNlLmdldCgpOwogICAgaWYgKHJlc3BvbnNlICYmIGNhY2hlVGltZSA+IDApIHsKICAgICAgY29uc3QgYWdlID0gKC8qIEBfX1BVUkVfXyAqLyBuZXcgRGF0ZSgpKS5nZXRUaW1lKCkgLSByZXNwb25zZS5jcmVhdGVkLmdldFRpbWUoKTsKICAgICAgaWYgKGFnZSA8IGNhY2hlVGltZSkKICAgICAgICByZXR1cm4gcmVzcG9uc2UuZGF0YTsKICAgIH0KICAgIGxldCBwcm9taXNlID0gY2FjaGUucHJvbWlzZS5nZXQoKTsKICAgIGlmICghcHJvbWlzZSkgewogICAgICBwcm9taXNlID0gZm4oKTsKICAgICAgY2FjaGUucHJvbWlzZS5zZXQocHJvbWlzZSk7CiAgICB9CiAgICB0cnkgewogICAgICBjb25zdCBkYXRhID0gYXdhaXQgcHJvbWlzZTsKICAgICAgY2FjaGUucmVzcG9uc2Uuc2V0KHsgY3JlYXRlZDogLyogQF9fUFVSRV9fICovIG5ldyBEYXRlKCksIGRhdGEgfSk7CiAgICAgIHJldHVybiBkYXRhOwogICAgfSBmaW5hbGx5IHsKICAg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0gcGFyYW1ldGVyczsKICAgIGNvbnN0IGVuYWJsZVBvbGxpbmcgPSAoKCkgPT4gewogICAgICBpZiAodHlwZW9mIHBvbGxfICE9PSAidW5kZWZpbmVkIikKICAgICAgICByZXR1cm4gcG9sbF87CiAgICAgIGlmICh0eXBlb2YgZnJvbUJsb2NrID09PSAiYmlnaW50IikKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAoY2xpZW50LnRyYW5zcG9ydC50eXBlID09PSAiZmFsbGJhY2siICYmIGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0c1swXS5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0pKCk7CiAgICBjb25zdCBwb2xsQ29udHJhY3RFdmVudCA9ICgpID0+IHsKICAgICAgY29uc3Qgc3RyaWN0ID0gc3RyaWN0XyA/PyBmYWxzZTsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQ29udHJhY3RFdmVudCIsCiAgICAgICAgYWRkcmVzcywKICAgICAgICBhcmdzLAogICAgICAgIGJhdGNoLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZXZlbnROYW1lLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBzdHJpY3QsCiAgICAgICAgZnJvbUJsb2NrCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uTG9ncywgb25FcnJvciB9LCAoZW1pdCkgPT4gewogICAgICAgIGxldCBwcmV2aW91c0Jsb2NrTnVtYmVyOwogICAgICAgIGlmIChmcm9tQmxvY2sgIT09IHZvaWQgMCkKICAgICAgICAgIHByZXZpb3VzQmxvY2tOdW1iZXIgPSBmcm9tQmxvY2sgLSAxbjsKICAgICAgICBsZXQgZmlsdGVyOwogICAgICAgIGxldCBpbml0aWFsaXplZCA9IGZhbHNlOwogICAgICAgIGNvbnN0IHVud2F0Y2ggPSBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmICghaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBmaWx0ZXIgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyLCAiY3JlYXRlQ29udHJhY3RFdmVudEZpbHRlciIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciA8IGJsb2NrTnVtYmVyKSB7CiAgICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICAgIGZyb21CbG9jazogcHJldmlvdXNCbG9ja051bWJlciArIDFuLAogICAgICAgICAgICAgICAgICB0b0Jsb2NrOiBibG9ja051bWJlciwKICAgICAgICAgICAgICAgICAgc3RyaWN0CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUNvbnRyYWN0RXZlbnQgPSAoKSA9PiB7CiAgICAgIGNvbnN0IHN0cmljdCA9IHN0cmljdF8gPz8gZmFsc2U7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaENvbnRyYWN0RXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50TmFtZSwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgc3RyaWN0CiAgICAgIF0pOwogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgOwogICAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQgPSAoKCkgPT4gewogICAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHMuZmluZCgodHJhbnNwb3J0MykgPT4gdHJhbnNwb3J0My5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpOwogICAgICAgICAgICAgICAgaWYgKCF0cmFuc3BvcnQyKQogICAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIHJldHVybiB0cmFuc3BvcnQyLnZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgY29uc3QgdG9waWNzID0gZXZlbnROYW1lID8gZW5jb2RlRXZlbnRUb3BpY3MoewogICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgYXJncwogICAgICAgICAgICB9KSA6IFtdOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJsb2dzIiwgeyBhZGRyZXNzLCB0b3BpY3MgfV0sCiAgICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBjb25zdCBsb2cgPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgIGNvbnN0IHsgZXZlbnROYW1lOiBldmVudE5hbWUyLCBhcmdzOiBhcmdzMiB9ID0gZGVjb2RlRXZlbnRMb2coewogICAgICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgICB0b3BpY3M6IGxvZy50b3BpY3MsCiAgICAgICAgICAgICAgICAgICAgc3RyaWN0OiBzdHJpY3RfCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBjb25zdCBmb3JtYXR0ZWQgPSBmb3JtYXRMb2cobG9nLCB7CiAgICAgICAgICAgICAgICAgICAgYXJnczogYXJnczIsCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgICAgbGV0IGV2ZW50TmFtZTI7CiAgICAgICAgICAgICAgICAgIGxldCBpc1VubmFtZWQ7CiAgICAgICAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dEYXRhTWlzbWF0Y2ggfHwgZXJyIGluc3RhbmNlb2YgRGVjb2RlTG9nVG9waWNzTWlzbWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBldmVudE5hbWUyID0gZXJyLmFiaUl0ZW0ubmFtZTsKICAgICAgICAgICAgICAgICAgICBpc1VubmFtZWQgPSBlcnIuYWJpSXRlbS5pbnB1dHM/LnNvbWUoKHgpID0+ICEoIm5hbWUiIGluIHggJiYgeC5uYW1lKSk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgewogICAgICAgICAgICAgICAgICAgIGFyZ3M6IGlzVW5uYW1lZCA/IFtdIDoge30sCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgIHVuc3Vic2NyaWJlKCk7CiAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgb25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSkoKTsKICAgICAgICByZXR1cm4gKCkgPT4gdW5zdWJzY3JpYmUoKTsKICAgICAgfSk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsQ29udHJhY3RFdmVudCgpIDogc3Vic2NyaWJlQ29udHJhY3RFdmVudCgpOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvd2FsbGV0L3dyaXRlQ29udHJhY3QuanMKICBpbml0X3BhcnNlQWNjb3VudCgpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL2FjY291bnQuanMKICBpbml0X2Jhc2UoKTsKICB2YXIgQWNjb3VudE5vdEZvdW5kRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgY29uc3RydWN0b3IoeyBkb2NzUGF0aDogZG9jc1BhdGg5IH0gPSB7fSkgewogICAgICBzdXBlcihbCiAgICAgICAgIkNvdWxkIG5vdCBmaW5kIGFuIEFjY291bnQgdG8gZXhlY3V0ZSB3aXRoIHRoaXMgQWN0aW9uLiIsCiAgICAgICAgIlBsZ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XJCbG9iR2FzLCBtYXhGZWVQZXJHYXMsIG1heFByaW9yaXR5RmVlUGVyR2FzLCBub25jZSwgdmFsdWUsIC4uLnJlc3QgfSA9IHBhcmFtZXRlcnM7CiAgICBpZiAodHlwZW9mIGFjY291bnRfID09PSAidW5kZWZpbmVkIikKICAgICAgdGhyb3cgbmV3IEFjY291bnROb3RGb3VuZEVycm9yKHsKICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2FjdGlvbnMvd2FsbGV0L3NlbmRUcmFuc2FjdGlvbiIKICAgICAgfSk7CiAgICBjb25zdCBhY2NvdW50ID0gYWNjb3VudF8gPyBwYXJzZUFjY291bnQoYWNjb3VudF8pIDogbnVsbDsKICAgIHRyeSB7CiAgICAgIGFzc2VydFJlcXVlc3QocGFyYW1ldGVycyk7CiAgICAgIGNvbnN0IHRvID0gYXdhaXQgKGFzeW5jICgpID0+IHsKICAgICAgICBpZiAocGFyYW1ldGVycy50bykKICAgICAgICAgIHJldHVybiBwYXJhbWV0ZXJzLnRvOwogICAgICAgIGlmIChhdXRob3JpemF0aW9uTGlzdCAmJiBhdXRob3JpemF0aW9uTGlzdC5sZW5ndGggPiAwKQogICAgICAgICAgcmV0dXJuIGF3YWl0IHJlY292ZXJBdXRob3JpemF0aW9uQWRkcmVzcyh7CiAgICAgICAgICAgIGF1dGhvcml6YXRpb246IGF1dGhvcml6YXRpb25MaXN0WzBdCiAgICAgICAgICB9KS5jYXRjaCgoKSA9PiB7CiAgICAgICAgICAgIHRocm93IG5ldyBCYXNlRXJyb3IyKCJgdG9gIGlzIHJlcXVpcmVkLiBDb3VsZCBub3QgaW5mZXIgZnJvbSBgYXV0aG9yaXphdGlvbkxpc3RgLiIpOwogICAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgfSkoKTsKICAgICAgaWYgKGFjY291bnQ/LnR5cGUgPT09ICJqc29uLXJwYyIgfHwgYWNjb3VudCA9PT0gbnVsbCkgewogICAgICAgIGxldCBjaGFpbklkOwogICAgICAgIGlmIChjaGFpbiAhPT0gbnVsbCkgewogICAgICAgICAgY2hhaW5JZCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldENoYWluSWQsICJnZXRDaGFpbklkIikoe30pOwogICAgICAgICAgYXNzZXJ0Q3VycmVudENoYWluKHsKICAgICAgICAgICAgY3VycmVudENoYWluSWQ6IGNoYWluSWQsCiAgICAgICAgICAgIGNoYWluCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2hhaW5Gb3JtYXQgPSBjbGllbnQuY2hhaW4/LmZvcm1hdHRlcnM/LnRyYW5zYWN0aW9uUmVxdWVzdD8uZm9ybWF0OwogICAgICAgIGNvbnN0IGZvcm1hdCA9IGNoYWluRm9ybWF0IHx8IGZvcm1hdFRyYW5zYWN0aW9uUmVxdWVzdDsKICAgICAgICBjb25zdCByZXF1ZXN0ID0gZm9ybWF0KHsKICAgICAgICAgIC8vIFBpY2sgb3V0IGV4dHJhIGRhdGEgdGhhdCBtaWdodCBleGlzdCBvbiB0aGUgY2hhaW4ncyB0cmFuc2FjdGlvbiByZXF1ZXN0IHR5cGUuCiAgICAgICAgICAuLi5leHRyYWN0KHJlc3QsIHsgZm9ybWF0OiBjaGFpbkZvcm1hdCB9KSwKICAgICAgICAgIGFjY2Vzc0xpc3QsCiAgICAgICAgICBhdXRob3JpemF0aW9uTGlzdCwKICAgICAgICAgIGJsb2JzLAogICAgICAgICAgY2hhaW5JZCwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICBmcm9tOiBhY2NvdW50Py5hZGRyZXNzLAogICAgICAgICAgZ2FzLAogICAgICAgICAgZ2FzUHJpY2UsCiAgICAgICAgICBtYXhGZWVQZXJCbG9iR2FzLAogICAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBub25jZSwKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUKICAgICAgICB9KTsKICAgICAgICBjb25zdCBtZXRob2QgPSBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5nZXQoY2xpZW50LnVpZCkgPyAid2FsbGV0X3NlbmRUcmFuc2FjdGlvbiIgOiAiZXRoX3NlbmRUcmFuc2FjdGlvbiI7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHJldHVybiBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgcGFyYW1zOiBbcmVxdWVzdF0KICAgICAgICAgIH0sIHsgcmV0cnlDb3VudDogMCB9KTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgICAgICBpZiAoZXJyb3IubmFtZSA9PT0gIkludmFsaWRJbnB1dFJwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiTWV0aG9kTm90Rm91bmRScGNFcnJvciIgfHwgZXJyb3IubmFtZSA9PT0gIk1ldGhvZE5vdFN1cHBvcnRlZFJwY0Vycm9yIikKICAgICAgICAgICAgcmV0dXJuIGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBtZXRob2Q6ICJ3YWxsZXRfc2VuZFRyYW5zYWN0aW9uIiwKICAgICAgICAgICAgICBwYXJhbXM6IFtyZXF1ZXN0XQogICAgICAgICAgICB9LCB7IHJldHJ5Q291bnQ6IDAgfSkudGhlbigoaGFzaDMpID0+IHsKICAgICAgICAgICAgICBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5zZXQoY2xpZW50LnVpZCwgdHJ1ZSk7CiAgICAgICAgICAgICAgcmV0dXJuIGhhc2gzOwogICAgICAgICAgICB9KTsKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gImxvY2FsIikgewogICAgICAgIGNvbnN0IHJlcXVlc3QgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBwcmVwYXJlVHJhbnNhY3Rpb25SZXF1ZXN0LCAicHJlcGFyZVRyYW5zYWN0aW9uUmVxdWVzdCIpKHsKICAgICAgICAgIGFjY291bnQsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3QsCiAgICAgICAgICBibG9icywKICAgICAgICAgIGNoYWluLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGdhcywKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgbWF4RmVlUGVyQmxvYkdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBub25jZU1hbmFnZXI6IGFjY291bnQubm9uY2VNYW5hZ2VyLAogICAgICAgICAgcGFyYW1ldGVyczogWy4uLmRlZmF1bHRQYXJhbWV0ZXJzLCAic2lkZWNhcnMiXSwKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgLi4ucmVzdCwKICAgICAgICAgIHRvCiAgICAgICAgfSk7CiAgICAgICAgY29uc3Qgc2VyaWFsaXplciA9IGNoYWluPy5zZXJpYWxpemVycz8udHJhbnNhY3Rpb247CiAgICAgICAgY29uc3Qgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gYXdhaXQgYWNjb3VudC5zaWduVHJhbnNhY3Rpb24ocmVxdWVzdCwgewogICAgICAgICAgc2VyaWFsaXplcgogICAgICAgIH0pOwogICAgICAgIHJldHVybiBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBzZW5kUmF3VHJhbnNhY3Rpb24sICJzZW5kUmF3VHJhbnNhY3Rpb24iKSh7CiAgICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24KICAgICAgICB9KTsKICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gInN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VudC5hY2NvdW50LCBhZGRyZXNzLCBhcmdzLCBkYXRhU3VmZml4LCBmdW5jdGlvbk5hbWUsIC4uLnJlcXVlc3QgfSA9IHBhcmFtZXRlcnM7CiAgICBpZiAodHlwZW9mIGFjY291bnRfID09PSAidW5kZWZpbmVkIikKICAgICAgdGhyb3cgbmV3IEFjY291bnROb3RGb3VuZEVycm9yKHsKICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2NvbnRyYWN0L3dyaXRlQ29udHJhY3QiCiAgICAgIH0pOwogICAgY29uc3QgYWNjb3VudCA9IGFjY291bnRfID8gcGFyc2VBY2NvdW50KGFjY291bnRfKSA6IG51bGw7CiAgICBjb25zdCBkYXRhID0gZW5jb2RlRnVuY3Rpb25EYXRhKHsKICAgICAgYWJpOiBhYmkyLAogICAgICBhcmdzLAogICAgICBmdW5jdGlvbk5hbWUKICAgIH0pOwogICAgdHJ5IHsKICAgICAgcmV0dXJuIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHNlbmRUcmFuc2FjdGlvbiwgInNlbmRUcmFuc2FjdGlvbiIpKHsKICAgICAgICBkYXRhOiBgJHtkYXRhfSR7ZGF0YVN1ZmZpeCA/IGRhdGFTdWZmaXgucmVwbGFjZSgiMHgiLCAiIikgOiAiIn1gLAogICAgICAgIHRvOiBhZGRyZXNzLAogICAgICAgIGFjY291bnQsCiAgICAgICAgLi4ucmVxdWVzdAogICAgICB9KTsKICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgIHRocm93IGdldENvbnRyYWN0RXJyb3IoZXJyb3IsIHsKICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgYWRkcmVzcywKICAgICAgICBhcmdzLAogICAgICAgIGRvY3NQYXRoOiAiL2RvY3MvY29udHJhY3Qvd3JpdGVDb250cmFjdCIsCiAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgIHNlbmRlcjogYWNjb3VudD8uYWRkcmVzcwogICAgICB9KTsKICAgIH0KICB9CgogIC8vIG5vZ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vbnN0IGl0ZW0gb2YgYWJpMikgewogICAgICBpZiAoaXRlbS50eXBlID09PSAiZnVuY3Rpb24iKQogICAgICAgIGlmIChpdGVtLnN0YXRlTXV0YWJpbGl0eSA9PT0gInZpZXciIHx8IGl0ZW0uc3RhdGVNdXRhYmlsaXR5ID09PSAicHVyZSIpCiAgICAgICAgICBoYXNSZWFkRnVuY3Rpb24gPSB0cnVlOwogICAgICAgIGVsc2UKICAgICAgICAgIGhhc1dyaXRlRnVuY3Rpb24gPSB0cnVlOwogICAgICBlbHNlIGlmIChpdGVtLnR5cGUgPT09ICJldmVudCIpCiAgICAgICAgaGFzRXZlbnQgPSB0cnVlOwogICAgICBpZiAoaGFzUmVhZEZ1bmN0aW9uICYmIGhhc1dyaXRlRnVuY3Rpb24gJiYgaGFzRXZlbnQpCiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBpZiAoaGFzUHVibGljQ2xpZW50KSB7CiAgICAgIGlmIChoYXNSZWFkRnVuY3Rpb24pCiAgICAgICAgY29udHJhY3QucmVhZCA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgcmVhZENvbnRyYWN0LCAicmVhZENvbnRyYWN0IikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGZ1bmN0aW9uTmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LnNpbXVsYXRlID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCBzaW11bGF0ZUNvbnRyYWN0LCAic2ltdWxhdGVDb250cmFjdCIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBmdW5jdGlvbk5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICBpZiAoaGFzRXZlbnQpIHsKICAgICAgICBjb250cmFjdC5jcmVhdGVFdmVudEZpbHRlciA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGV2ZW50TmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCBhYmlFdmVudCA9IGFiaTIuZmluZCgoeCkgPT4geC50eXBlID09PSAiZXZlbnQiICYmIHgubmFtZSA9PT0gZXZlbnROYW1lKTsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEV2ZW50UGFyYW1ldGVycyhwYXJhbWV0ZXJzLCBhYmlFdmVudCk7CiAgICAgICAgICAgICAgcmV0dXJuIGdldEFjdGlvbihwdWJsaWNDbGllbnQsIGNyZWF0ZUNvbnRyYWN0RXZlbnRGaWx0ZXIsICJjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyIikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgY29udHJhY3QuZ2V0RXZlbnRzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZXZlbnROYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IGFiaUV2ZW50ID0gYWJpMi5maW5kKCh4KSA9PiB4LnR5cGUgPT09ICJldmVudCIgJiYgeC5uYW1lID09PSBldmVudE5hbWUpOwogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RXZlbnRQYXJhbWV0ZXJzKHBhcmFtZXRlcnMsIGFiaUV2ZW50KTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIGNvbnRyYWN0LndhdGNoRXZlbnQgPSBuZXcgUHJveHkoe30sIHsKICAgICAgICAgIGdldChfLCBldmVudE5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuICguLi5wYXJhbWV0ZXJzKSA9PiB7CiAgICAgICAgICAgICAgY29uc3QgYWJpRXZlbnQgPSBhYmkyLmZpbmQoKHgpID0+IHgudHlwZSA9PT0gImV2ZW50IiAmJiB4Lm5hbWUgPT09IGV2ZW50TmFtZSk7CiAgICAgICAgICAgICAgY29uc3QgeyBhcmdzLCBvcHRpb25zIH0gPSBnZXRFdmVudFBhcmFtZXRlcnMocGFyYW1ldGVycywgYWJpRXZlbnQpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCB3YXRjaENvbnRyYWN0RXZlbnQsICJ3YXRjaENvbnRyYWN0RXZlbnQiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfQogICAgfQogICAgaWYgKGhhc1dhbGxldENsaWVudCkgewogICAgICBpZiAoaGFzV3JpdGVGdW5jdGlvbikKICAgICAgICBjb250cmFjdC53cml0ZSA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHdhbGxldENsaWVudCwgd3JpdGVDb250cmFjdCwgIndyaXRlQ29udHJhY3QiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGlmIChoYXNQdWJsaWNDbGllbnQgfHwgaGFzV2FsbGV0Q2xpZW50KSB7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LmVzdGltYXRlR2FzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIGNvbnN0IGNsaWVudDIgPSBwdWJsaWNDbGllbnQgPz8gd2FsbGV0Q2xpZW50OwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24oY2xpZW50MiwgZXN0aW1hdGVDb250cmFjdEdhcywgImVzdGltYXRlQ29udHJhY3RHYXMiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMsCiAgICAgICAgICAgICAgICBhY2NvdW50OiBvcHRpb25zLmFjY291bnQgPz8gd2FsbGV0Q2xpZW50LmFjY291bnQKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGNvbnRyYWN0LmFkZHJlc3MgPSBhZGRyZXNzOwogICAgY29udHJhY3QuY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WFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKSh7CiAgICAgICAgYWJpLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgZnVuY3Rpb25OYW1lOiAiZWlwNzEyRG9tYWluIiwKICAgICAgICBmYWN0b3J5LAogICAgICAgIGZhY3RvcnlEYXRhCiAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGRvbWFpbjogewogICAgICAgICAgbmFtZSwKICAgICAgICAgIHZlcnNpb246IHZlcnNpb24zLAogICAgICAgICAgY2hhaW5JZDogTnVtYmVyKGNoYWluSWQpLAogICAgICAgICAgdmVyaWZ5aW5nQ29udHJhY3QsCiAgICAgICAgICBzYWx0CiAgICAgICAgfSwKICAgICAgICBleHRlbnNpb25zLAogICAgICAgIGZpZWxkcwogICAgICB9OwogICAgfSBjYXRjaCAoZSkgewogICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgIGlmIChlcnJvci5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvbkV4ZWN1dGlvbkVycm9yIiAmJiBlcnJvci5jYXVzZS5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvblplcm9EYXRhRXJyb3IiKSB7CiAgICAgICAgdGhyb3cgbmV3IEVpcDcxMkRvbWFpbk5vdEZvdW5kRXJyb3IoeyBhZGRyZXNzIH0pOwogICAgICB9CiAgICAgIHRocm93IGVycm9yOwogICAgfQogIH0KICB2YXIgYWJpID0gWwogICAgewogICAgICBpbnB1dHM6IFtdLAogICAgICBuYW1lOiAiZWlwNzEyRG9tYWluIiwKICAgICAgb3V0cHV0czogWwogICAgICAgIHsgbmFtZTogImZpZWxkcyIsIHR5cGU6ICJieXRlczEiIH0sCiAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAidmVyc2lvbiIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAiY2hhaW5JZCIsIHR5cGU6ICJ1aW50Mj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ICJiYXNlIiB9ID0gcGFyYW1ldGVyczsKICAgIGNvbnN0IGNoYWluID0gcGFyYW1ldGVycy5jaGFpbjsKICAgIGNvbnN0IGFjY291bnQgPSBwYXJhbWV0ZXJzLmFjY291bnQgPyBwYXJzZUFjY291bnQocGFyYW1ldGVycy5hY2NvdW50KSA6IHZvaWQgMDsKICAgIGNvbnN0IHsgY29uZmlnLCByZXF1ZXN0LCB2YWx1ZSB9ID0gcGFyYW1ldGVycy50cmFuc3BvcnQoewogICAgICBjaGFpbiwKICAgICAgcG9sbGluZ0ludGVydmFsCiAgICB9KTsKICAgIGNvbnN0IHRyYW5zcG9ydCA9IHsgLi4uY29uZmlnLCAuLi52YWx1ZSB9OwogICAgY29uc3QgY2xpZW50ID0gewogICAgICBhY2NvdW50LAogICAgICBiYXRjaCwKICAgICAgY2FjaGVUaW1lLAogICAgICBjY2lwUmVhZCwKICAgICAgY2hhaW4sCiAgICAgIGtleSwKICAgICAgbmFtZSwKICAgICAgcG9sbGluZ0ludGVydmFsLAogICAgICByZXF1ZXN0LAogICAgICB0cmFuc3BvcnQsCiAgICAgIHR5cGUsCiAgICAgIHVpZDogdWlkKCkKICAgIH07CiAgICBmdW5jdGlvbiBleHRlbmQoYmFzZTIpIHsKICAgICAgcmV0dXJuIChleHRlbmRGbikgPT4gewogICAgICAgIGNvbnN0IGV4dGVuZGVkID0gZXh0ZW5kRm4oYmFzZTIpOwogICAgICAgIGZvciAoY29uc3Qga2V5MiBpbiBjbGllbnQpCiAgICAgICAgICBkZWxldGUgZXh0ZW5kZWRba2V5Ml07CiAgICAgICAgY29uc3QgY29tYmluZWQgPSB7IC4uLmJhc2UyLCAuLi5leHRlbmRlZCB9OwogICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNvbWJpbmVkLCB7IGV4dGVuZDogZXh0ZW5kKGNvbWJpbmVkKSB9KTsKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNsaWVudCwgeyBleHRlbm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gbWV0aG9kOiBhcmdzLm1ldGhvZCB9KTsKICAgICAgICAgICAgLy8gLTMyNjAyCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFBhcmFtc1JwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRQYXJhbXNScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzI2MDMKICAgICAgICAgICAgY2FzZSBJbnRlcm5hbFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludGVybmFsUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZElucHV0UnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZElucHV0UnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAxCiAgICAgICAgICAgIGNhc2UgUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFJlc291cmNlTm90Rm91bmRScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzIwMDIKICAgICAgICAgICAgY2FzZSBSZXNvdXJjZVVuYXZhaWxhYmxlUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgUmVzb3VyY2VVbmF2YWlsYWJsZVJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjAwMwogICAgICAgICAgICBjYXNlIFRyYW5zYWN0aW9uUmVqZWN0ZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA0CiAgICAgICAgICAgIGNhc2UgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IoZXJyLCB7CiAgICAgICAgICAgICAgICBtZXRob2Q6IGFyZ3MubWV0aG9kCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIC8vIC0zMjAwNQogICAgICAgICAgICBjYXNlIExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBMaW1pdEV4Y2VlZGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA2CiAgICAgICAgICAgIGNhc2UgSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpzb25ScGNWZXJzaW9uVW5zdXBwb3J0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MDAxCiAgICAgICAgICAgIGNhc2UgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFVzZXJSZWplY3RlZFJlcXVlc3RFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MTAwCiAgICAgICAgICAgIGNhc2UgVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBVbmF1dGhvcml6ZWRQcm92aWRlckVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQyMDAKICAgICAgICAgICAgY2FzZSBVbnN1cHBvcnRlZFByb3ZpZGVyTWV0aG9kRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRQcm92aWRlck1ldGhvZEVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQ5MDAKICAgICAgICAgICAgY2FzZSBQcm92aWRlckRpc2Nvbm5lY3RlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gNDkwMQogICAgICAgICAgICBjYXNlIENoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2hhaW5EaXNjb25uZWN0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0OTAyCiAgICAgICAgICAgIGNhc2UgU3dpdGNoQ2hhaW5FcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBTd2l0Y2hDaGFpbkVycm9yKGVycik7CiAgICAgICAgICAgIC8vIENBSVAtMjU6IFVzZXIgUmVqZWN0ZWQgRXJyb3IKICAgICAgICAgICAgLy8gaHR0cHM6Ly9kb2NzLndhbGxldGNvbm5lY3QuY29tLzIuMC9zcGVjcy9jbGllbnRzL3NpZ24vZXJyb3ItY29kZXMjcmVqZWN0ZWQtY2FpcC0yNQogICAgICAgICAgICBjYXNlIDVlMzoKICAgICAgICAgICAgICB0aHJvdyBuZXcgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yKGVycik7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGVycl8gaW5zdGFuY2VvZiBCYXNlRXJyb3IyKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyXzsKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5rbm93blJwY0Vycm9yKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9LCB7CiAgICAgICAgZGVsYXk6ICh7IGNvdW50LCBlcnJvciB9KSA9PiB7CiAgICAgICAgICBpZiAoZXJyb3IgJiYgZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yKSB7CiAgICAgICAgICAgIGNvbnN0IHJldHJ5QWZ0ZXIgPSBlcnJvcj8uaGVhZGVycz8uZ2V0KCJSZXRyeS1BZnRlciIpOwogICAgICAgICAgICBpZiAocmV0cnlBZnRlcj8ubWF0Y2goL1xkLykpCiAgICAgICAgICAgICAgcmV0dXJuIE51bWJlci5wYXJzZUludChyZXRyeUFmdGVyKSAqIDFlMzsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB+figxIDw8IGNvdW50KSAqIHJldHJ5RGVsYXk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHNob3VsZFJldHJ5OiAoeyBlcnJvciB9KSA9PiBzaG91bGRSZXRyeShlcnJvcikKICAgICAgfSksIHsgZW5hYmxlZDogZGVkdXBlLCBpZDogcmVxdWVzdElkIH0pOwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkUmV0cnkoZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSAtMSkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLmNvZGUgPT09IExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3IuY29kZSA9PT0gSW50ZXJuYWxScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yICYmIGVycm9yLnN0YXR1cykgewogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDQwOCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNDEzKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MjkpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwMCkKICAgICAgICByZXR1cm4gd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gICAgY29uc3QgZmV0Y2gyID0gYXN5bmMgKGkgPSAwKSA9PiB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSB0cmFuc3BvcnRzW2ldKHsKICAgICAgICAgICAgICAuLi5yZXN0LAogICAgICAgICAgICAgIGNoYWluLAogICAgICAgICAgICAgIHJldHJ5Q291bnQ6IDAsCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IHRyYW5zcG9ydDIucmVxdWVzdCh7CiAgICAgICAgICAgICAgICBtZXRob2QsCiAgICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBvblJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHJlc3BvbnNlLAogICAgICAgICAgICAgICAgdHJhbnNwb3J0OiB0cmFuc3BvcnQyLAogICAgICAgICAgICAgICAgc3RhdHVzOiAic3VjY2VzcyIKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIG9uUmVzcG9uc2UoewogICAgICAgICAgICAgICAgZXJyb3I6IGVyciwKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHRyYW5zcG9ydDogdHJhbnNwb3J0MiwKICAgICAgICAgICAgICAgIHN0YXR1czogImVycm9yIgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChzaG91bGRUaHJvdyhlcnIpKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgICAgIGlmIChpID09PSB0cmFuc3BvcnRzLmxlbmd0aCAtIDEpCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgcmV0dXJuIGZldGNoMihpICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH07CiAgICAgICAgICByZXR1cm4gZmV0Y2gyKCk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHJldHJ5RGVsYXksCiAgICAgICAgdHlwZTogImZhbGxiYWNrIgogICAgICB9LCB7CiAgICAgICAgb25SZXNwb25zZTogKGZuKSA9PiBvblJlc3BvbnNlID0gZm4sCiAgICAgICAgdHJhbnNwb3J0czogdHJhbnNwb3J0cy5tYXAoKGZuKSA9PiBmbih7IGNoYWluLCByZXRyeUNvdW50OiAwIH0pKQogICAgICB9KTsKICAgICAgaWYgKHJhbmspIHsKICAgICAgICBjb25zdCByYW5rT3B0aW9ucyA9IHR5cGVvZiByYW5rID09PSAib2JqZWN0IiA/IHJhbmsgOiB7fTsKICAgICAgICByYW5rVHJhbnNwb3J0cyh7CiAgICAgICAgICBjaGFpbiwKICAgICAgICAgIGludGVydmFsOiByYW5rT3B0aW9ucy5pbnRlcnZhbCA/PyBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgICBvblRyYW5zcG9ydHM6ICh0cmFuc3BvcnRzXzIpID0+IHRyYW5zcG9ydHMgPSB0cmFuc3BvcnRzXzIsCiAgICAgICAgICBzYW1wbGVDb3VudDogcmFua09wdGlvbnMuc2FtcGxlQ291bnQsCiAgICAgICAgICB0aW1lb3V0OiByYW5rT3B0aW9ucy50aW1lb3V0LAogICAgICAgICAgdHJhbnNwb3J0cywKICAgICAgICAgIHdlaWdodHM6IHJhbmtPcHRpb25zLndlaWdodHMKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm4gdHJhbnNwb3J0OwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkVGhyb3coZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1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HNpZ25hbDogY29udHJvbGxlcj8uc2lnbmFsIHx8IG51bGwgfSkpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVycj8ubmFtZSA9PT0gIkFib3J0RXJyb3IiKQogICAgICAgICAgICByZWplY3QoZXJyb3JJbnN0YW5jZSk7CiAgICAgICAgICByZWplY3QoZXJyKTsKICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXRJZCk7CiAgICAgICAgfQogICAgICB9KSgpOwogICAgfSk7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvcnBjL2h0dHAuanMKICBpbml0X3N0cmluZ2lmeSgpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvcnBjL2lkLmpzCiAgZnVuY3Rpb24gY3JlYXRlSWRTdG9yZSgpIHsKICAgIHJldHVybiB7CiAgICAgIGN1cnJlbnQ6IDAsCiAgICAgIHRha2UoKSB7CiAgICAgICAgcmV0dXJuIHRoaXMuY3VycmVudCsrOwogICAgICB9LAogICAgICByZXNldCgpIHsKICAgICAgICB0aGlzLmN1cnJlbnQgPSAwOwogICAgICB9CiAgICB9OwogIH0KICB2YXIgaWRDYWNoZSA9IC8qIEBfX1BVUkVfXyAqLyBjcmVhdGVJZFN0b3JlKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9ycGMvaHR0cC5qcwogIGZ1bmN0aW9uIGdldEh0dHBScGNDbGllbnQodXJsLCBvcHRpb25zID0ge30pIHsKICAgIHJldHVybiB7CiAgICAgIGFzeW5jIHJlcXVlc3QocGFyYW1zKSB7CiAgICAgICAgY29uc3QgeyBib2R5LCBvblJlcXVlc3QgPSBvcHRpb25zLm9uUmVxdWVzdCwgb25SZXNwb25zZSA9IG9wdGlvbnMub25SZXNwb25zZSwgdGltZW91dCA9IG9wdGlvbnMudGltZW91dCA/PyAxZTQgfSA9IHBhcmFtczsKICAgICAgICBjb25zdCBmZXRjaE9wdGlvbnMgPSB7CiAgICAgICAgICAuLi5vcHRpb25zLmZldGNoT3B0aW9ucyA/PyB7fSwKICAgICAgICAgIC4uLnBhcmFtcy5mZXRjaE9wdGlvbnMgPz8ge30KICAgICAgICB9OwogICAgICAgIGNvbnN0IHsgaGVhZGVycywgbWV0aG9kLCBzaWduYWw6IHNpZ25hbF8gfSA9IGZldGNoT3B0aW9uczsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB3aXRoVGltZW91dChhc3luYyAoeyBzaWduYWwgfSkgPT4gewogICAgICAgICAgICBjb25zdCBpbml0ID0gewogICAgICAgICAgICAgIC4uLmZldGNoT3B0aW9ucywKICAgICAgICAgICAgICBib2R5OiBBcnJheS5pc0FycmF5KGJvZHkpID8gc3RyaW5naWZ5KGJvZHkubWFwKChib2R5MikgPT4gKHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkyLmlkID8/IGlkQ2FjaGUudGFrZSgpLAogICAgICAgICAgICAgICAgLi4uYm9keTIKICAgICAgICAgICAgICB9KSkpIDogc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkuaWQgPz8gaWRDYWNoZS50YWtlKCksCiAgICAgICAgICAgICAgICAuLi5ib2R5CiAgICAgICAgICAgICAgfSksCiAgICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICAgIkNvbnRlbnQtVHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgICAgIC4uLmhlYWRlcnMKICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgIG1ldGhvZDogbWV0aG9kIHx8ICJQT1NUIiwKICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbF8gfHwgKHRpbWVvdXQgPiAwID8gc2lnbmFsIDogbnVsbCkKICAgICAgICAgICAgfTsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdCA9IG5ldyBSZXF1ZXN0KHVybCwgaW5pdCk7CiAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhd2FpdCBvblJlcXVlc3Q/LihyZXF1ZXN0LCBpbml0KSA/PyB7IC4uLmluaXQsIHVybCB9OwogICAgICAgICAgICBjb25zdCByZXNwb25zZTIgPSBhd2FpdCBmZXRjaChhcmdzLnVybCA/PyB1cmwsIGFyZ3MpOwogICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UyOwogICAgICAgICAgfSwgewogICAgICAgICAgICBlcnJvckluc3RhbmNlOiBuZXcgVGltZW91dEVycm9yKHsgYm9keSwgdXJsIH0pLAogICAgICAgICAgICB0aW1lb3V0LAogICAgICAgICAgICBzaWduYWw6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKG9uUmVzcG9uc2UpCiAgICAgICAgICAgIGF3YWl0IG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpCiAgICAgICAgICAgIGRhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgZGF0YSA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBkYXRhID0gSlNPTi5wYXJzZShkYXRhIHx8ICJ7fSIpOwogICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uub2spCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgZGF0YSA9IHsgZXJyb3I6IGRhdGEgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICB0aHJvdyBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBkZXRhaWxzOiBzdHJpbmdpZnkoZGF0YS5lcnJvcikgfHwgcmVzcG9uc2Uuc3RhdHVzVGV4dCwKICAgICAgICAgICAgICBoZWFkZXJzOiByZXNwb25zZS5oZWFkZXJzLAogICAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICAgIHVybAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBkYXRhOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIEh0dHBSZXF1ZXN0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBUaW1lb3V0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIHRocm93IG5ldyBIdHRwUmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgY2F1c2U6IGVyciwKICAgICAgICAgICAgdXJsCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2xpZW50cy90cmFuc3BvcnRzL2h0dHAuanMKICBmdW5jdGlvbiBodHRwKHVybCwgY29uZmlnID0ge30pIHsKICAgIGNvbnN0IHsgYmF0Y2gsIGZldGNoT3B0aW9ucyw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YXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICAgICAgICBpZDogdXJsXywKICAgICAgICAgICAgd2FpdDogd2FpdDIsCiAgICAgICAgICAgIHNob3VsZFNwbGl0QmF0Y2gocmVxdWVzdHMpIHsKICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdHMubGVuZ3RoID4gYmF0Y2hTaXplOwogICAgICAgICAgICB9LAogICAgICAgICAgICBmbjogKGJvZHkyKSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgICAgYm9keTogYm9keTIKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNvcnQ6IChhLCBiKSA9PiBhLmlkIC0gYi5pZAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCBmbiA9IGFzeW5jIChib2R5MikgPT4gYmF0Y2ggPyBzY2hlZHVsZShib2R5MikgOiBbCiAgICAgICAgICAgIGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBib2R5OiBib2R5MgogICAgICAgICAgICB9KQogICAgICAgICAgXTsKICAgICAgICAgIGNvbnN0IFt7IGVycm9yLCByZXN1bHQgfV0gPSBhd2FpdCBmbihib2R5KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogImh0dHAiCiAgICAgIH0sIHsKICAgICAgICBmZXRjaE9wdGlvbnMsCiAgICAgICAgdXJsOiB1cmxfCiAgICAgIH0pOwogICAgfTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQ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ID0gZ2V0QWN0aW9uKGNsaWVudCwgcmVhZENvbnRyYWN0LCAicmVhZENvbnRyYWN0Iik7CiAgICAgIGNvbnN0IHJlcyA9IGdhdGV3YXlVcmxzID8gYXdhaXQgcmVhZENvbnRyYWN0QWN0aW9uKHsKICAgICAgICAuLi5yZWFkQ29udHJhY3RQYXJhbWV0ZXJzLAogICAgICAgIGFyZ3M6IFsuLi5yZWFkQ29udHJhY3RQYXJhbWV0ZXJzLmFyZ3MsIGdhdGV3YXlVcmxzXQogICAgICB9KSA6IGF3YWl0IHJlYWRDb250cmFjdEFjdGlvbihyZWFkQ29udHJhY3RQYXJhbWV0ZXJzKTsKICAgICAgaWYgKHJlc1swXSA9PT0gIjB4IikKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgY29uc3QgYWRkcmVzcyA9IGRlY29kZUZ1bmN0aW9uUmVzdWx0KHsKICAgICAgICBhYmk6IGFkZHJlc3NSZXNvbHZlckFiaSwKICAgICAgICBhcmdzOiBjb2luVHlwZSAhPSBudWxsID8gW25hbWVoYXNoKG5hbWUpLCBCaWdJbnQoY29pblR5cGUpXSA6IHZvaWQgMCwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJhZGRyIiwKICAgICAgICBkYXRhOiByZXNbMF0KICAgICAgfSk7CiAgICAgIGlmIChhZGRyZXNzID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBpZiAodHJpbShhZGRyZXNzKSA9PT0gIjB4MDAiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gYWRkcmVzczsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICBpZiAoc3RyaWN0KQogICAgICAgIHRocm93IGVycjsKICAgICAgaWYgKGlzTnVsbFVuaXZlcnNhbFJlc29sdmVyRXJyb3IoZXJyLCAicmVzb2x2ZSIpKQogICAgICAgIHJldHVybiBudWxsOwogICAgICB0aHJvdyBlcnI7CiAgICB9CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8v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czogbmZ0LmNvbnRyYWN0QWRkcmVzcywKICAgICAgICBhYmk6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInRva2VuVVJJIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogInRva2VuSWQiLCB0eXBlOiAidWludDI1NiIgfV0sCiAgICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgICAgfQogICAgICAgIF0sCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidG9rZW5VUkkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIGlmIChuZnQubmFtZXNwYWNlID09PSAiZXJjMTE1NSIpIHsKICAgICAgcmV0dXJuIHJlYWRDb250cmFjdChjbGllbnQsIHsKICAgICAgICBhZGRyZXNzOiBuZnQuY29udHJhY3RBZGRyZXNzLAogICAgICAgIGFiaTogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAidXJpIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIl9pZCIsIHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJzdHJpbmciIH1dCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJ1cmkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBFbnNBdmF0YXJVbnN1cHBvcnRlZE5hbWVzcGFjZUVycm9yKHsgbmFtZXN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ICAgIGZ1bmN0aW9uTmFtZTogInRleHQiLAogICAgICAgICAgICBhcmdzOiBbbmFtZWhhc2gobmFtZSksIGtleV0KICAgICAgICAgIH0pCiAgICAgICAgXSwKICAgICAgICBibG9ja051bWJlciwKICAgICAgICBibG9ja1RhZwogICAgICB9OwogICAgICBjb25zdCByZWFkQ29udHJhY3RBY3Rpb24gPSBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKTsKICAgICAgY29uc3QgcmVzID0gZ2F0ZXdheVVybHMgPyBhd2FpdCByZWFkQ29udHJhY3RBY3Rpb24oewogICAgICAgIC4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMsCiAgICAgICAgYXJnczogWy4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMuYXJncywgZ2F0ZXdheVVybHNdCiAgICAgIH0pIDogYXdhaXQgcmVhZENvbnRyYWN0QWN0aW9uKHJlYWRDb250cmFjdFBhcmFtZXRlcnMpOwogICAgICBpZiAocmVzWzBdID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBjb25zdCByZWNvcmQgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidGV4dCIsCiAgICAgICAgZGF0YTogcmVzWzBdCiAgICAgIH0pOwogICAgICByZXR1cm4gcmVjb3JkID09PSAiIiA/IG51bGwgOiByZWNvcmQ7CiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgaWYgKHN0cmljdCkKICAgICAgICB0aHJvdyBlcnI7CiAgICAgIGlmIChpc051bGxVbml2ZXJzYWxSZXNvbHZlckVycm9yKGVyciwgInJlc29sdmUiKSkKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgdGhyb3cgZXJyOwogICAgfQogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub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yA/PyAoZXZlbnQgPyBbZXZlbnRdIDogdm9pZCAwKTsKICAgIGNvbnN0IGdldFJlcXVlc3QgPSBjcmVhdGVGaWx0ZXJSZXF1ZXN0U2NvcGUoY2xpZW50LCB7CiAgICAgIG1ldGhvZDogImV0aF9uZXdGaWx0ZXIiCiAgICB9KTsKICAgIGxldCB0b3BpY3MgPSBbXTsKICAgIGlmIChldmVudHMpIHsKICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50cy5mbGF0TWFwKChldmVudDIpID0+IGVuY29kZUV2ZW50VG9waWNzKHsKICAgICAgICBhYmk6IFtldmVudDJdLAogICAgICAgIGV2ZW50TmFtZTogZXZlbnQyLm5hbWUsCiAgICAgICAgYXJncwogICAgICB9KSk7CiAgICAgIHRvcGljcyA9IFtlbmNvZGVkXTsKICAgICAgaWYgKGV2ZW50KQogICAgICAgIHRvcGljcyA9IHRvcGljc1swXTsKICAgIH0KICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgLi4udG9waWNzLmxlbmd0aCA/IHsgdG9waWNzIH0gOiB7fQogICAgICAgIH0KICAgICAgXQogICAgfSk7CiAgICByZXR1cm4gewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lOiBldmVudCA/IGV2ZW50Lm5hbWUgOiB2b2lkIDAsCiAgICAgIGZyb21CbG9jaywKICAgIC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XN0Lm9uRXJyb3I/LihuZXcgU29ja2V0Q2xvc2VkRXJyb3IoeyB1cmwgfSkpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybCB9KSk7CiAgICAgICAgICAgICAgcmVxdWVzdHMuY2xlYXIoKTsKICAgICAgICAgICAgICBzdWJzY3JpcHRpb25zLmNsZWFyKCk7CiAgICAgICAgICAgICAgaWYgKHJlY29ubmVjdCAmJiByZWNvbm5lY3RDb3VudCA8IGF0dGVtcHRzKQogICAgICAgICAgICAgICAgc2V0VGltZW91dChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgIHJlY29ubmVjdENvdW50Kys7CiAgICAgICAgICAgICAgICAgIGF3YWl0IHNldHVwKCkuY2F0Y2goY29uc29sZS5lcnJvcik7CiAgICAgICAgICAgICAgICB9LCBkZWxheSk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uRXJyb3IoZXJyb3JfKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSBlcnJvcl87CiAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0IG9mIHJlcXVlc3RzLnZhbHVlcygpKQogICAgICAgICAgICAgICAgcmVxdWVzdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXF1ZXN0cy5jbGVhcigpOwogICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuY2xlYXIoKTsKICAgICAgICAgICAgICBpZiAocmVjb25uZWN0ICYmIHJlY29ubmVjdENvdW50IDwgYXR0ZW1wdHMpCiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGFzeW5jICgpID0+IHsKICAgICAgICAgICAgICAgICAgcmVjb25uZWN0Q291bnQrKzsKICAgICAgICAgICAgICAgICAgYXdhaXQgc2V0dXAoKS5jYXRjaChjb25zb2xlLmVycm9yKTsKICAgICAgICAgICAgICAgIH0sIGRlbGF5KTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25PcGVuKCkgewogICAgICAgICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgICAgICAgIHJlY29ubmVjdENvdW50ID0gMDsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25SZXNwb25zZShkYXRhKSB7CiAgICAgICAgICAgICAgY29uc3QgaXNTdWJzY3JpcHRpb24gPSBkYXRhLm1ldGhvZCA9PT0gImV0aF9zdWJzY3JpcHRpb24iOwogICAgICAgICAgICAgIGNvbnN0IGlkID0gaXNTdWJzY3JpcHRpb24gPyBkYXRhLnBhcmFtcy5zdWJzY3JpcHRpb24gOiBkYXRhLmlkOwogICAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gaXNTdWJzY3JpcHRpb24gPyBzdWJzY3JpcHRpb25zIDogcmVxdWVzdHM7CiAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2sgPSBjYWNoZS5nZXQoaWQpOwogICAgICAgICAgICAgIGlmIChjYWxsYmFjaykKICAgICAgICAgICAgICAgIGNhbGxiYWNrLm9uUmVzcG9uc2UoZGF0YSk7CiAgICAgICAgICAgICAgaWYgKCFpc1N1YnNjcmlwdGlvbikKICAgICAgICAgICAgICAgIGNhY2hlLmRlbGV0ZShpZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgc29ja2V0ID0gcmVzdWx0OwogICAgICAgICAgaWYgKGtlZXBBbGl2ZSkgewogICAgICAgICAgICBpZiAoa2VlcEFsaXZlVGltZXIpCiAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChrZWVwQWxpdmVUaW1lcik7CiAgICAgICAgICAgIGtlZXBBbGl2ZVRpbWVyID0gc2V0SW50ZXJ2YWwoKCkgPT4gc29ja2V0LnBpbmc/LigpLCBrZWVwQWxpdmVJbnRlcnZhbCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0KICAgICAgICBhd2FpdCBzZXR1cCgpOwogICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgIHNvY2tldENsaWVudCA9IHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBrZWVwQWxpdmVUaW1lciAmJiBjbGVhckludGVydmFsKGtlZXBBbGl2ZVRpbWVyKTsKICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7CiAgICAgICAgICAgIHNvY2tldENsaWVudENhY2hlLmRlbGV0ZShgJHtrZXl9OiR7dXJsfWApOwogICAgICAgICAgfSwKICAgICAgICAgIGdldCBzb2NrZXQoKSB7CiAgICAgICAgICAgIHJldHVybiBzb2NrZXQ7CiAgICAgICAgICB9LAogICAgICAgICAgcmVxdWVzdCh7IGJvZHksIG9uRXJyb3IsIG9uUmVzcG9uc2UgfSkgewogICAgICAgICAgICBpZiAoZXJyb3IgJiYgb25FcnJvcikKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKTsKICAgICAgICAgICAgY29uc3QgaWQgPSBib2R5LmlkID8/IGlkQ2FjaGUudGFrZSgpOwogICAgICAgICAgICBjb25zdCBjYWxsYmFjayA9IChyZXNwb25zZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzcG9uc2UuaWQgPT09ICJudW1iZXIiICYmIGlkICE9PSByZXNwb25zZS5pZCkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBpZiAoYm9keS5tZXRob2QgPT09ICJldGhfc3Vic2NyaWJlIiAmJiB0eXBlb2YgcmVzcG9uc2UucmVzdWx0ID09PSAic3RyaW5nIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuc2V0KHJlc3BvbnNlLnJlc3VsdCwgewogICAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiBjYWxsYmFjaywKICAgICAgICAgICAgICAgICAgb25FcnJvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgaWYgKGJvZHkubWV0aG9kID09PSAiZXRoX3Vuc3Vic2NyaWJlIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuZGVsZXRlKGJvZHkucGFyYW1zPy5bMF0pOwogICAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgICB9OwogICAgICAgICAgICByZXF1ZXN0cy5zZXQoaWQsIHsgb25SZXNwb25zZTogY2FsbGJhY2ssIG9uRXJyb3IgfSk7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgc29ja2V0LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBqc29ucnBjOiAiMi4wIiwKICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgIC4uLmJvZHkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yMik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0QXN5bmMoeyBib2R5LCB0aW1lb3V0ID0gMWU0IH0pIHsKICAgICAgICAgICAgcmV0dXJuIHdpdGhUaW1lb3V0KCgpID0+IG5ldyBQcm9taXNlKChvblJlc3BvbnNlLCBvbkVycm9yKSA9PiB0aGlzLnJlcXVlc3QoewogICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgb25FcnJvciwKICAgICAgICAgICAgICBvblJlc3BvbnNlCiAgICAgICAgICAgIH0pKSwgewogICAgICAgICAgICAgIGVycm9ySW5zdGFuY2U6IG5ldyBUaW1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b3NlKCk7CiAgICAgICAgICBzb2NrZXQucmVtb3ZlRXZlbnRMaXN0ZW5lcigiY2xvc2UiLCBvbkNsb3NlXyk7CiAgICAgICAgICBzb2NrZXQucmVtb3ZlRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsIG9uTWVzc2FnZSk7CiAgICAgICAgICBzb2NrZXQucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbkVycm9yKTsKICAgICAgICAgIHNvY2tldC5yZW1vdmVFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25NZXNzYWdlKHsgZGF0YSB9KSB7CiAgICAgICAgICBvblJlc3BvbnNlKEpTT04ucGFyc2UoZGF0YSkpOwogICAgICAgIH0KICAgICAgICBzb2NrZXQuYWRkRXZlbnRMaXN0ZW5lcigiY2xvc2UiLCBvbkNsb3NlXyk7CiAgICAgICAgc29ja2V0LmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBvbk1lc3NhZ2UpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsIG9uRXJyb3IpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICBpZiAoc29ja2V0LnJlYWR5U3RhdGUgPT09IFdlYlNvY2tldDMuQ09OTkVDVElORykgewogICAgICAgICAgYXdhaXQgbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICBpZiAoIXNvY2tldCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHNvY2tldC5vbm9wZW4gPSByZXNvbHZlOwogICAgICAgICAgICBzb2NrZXQub25lcnJvciA9IHJlamVjdDsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBjb25zdCB7IGNsb3NlOiBjbG9zZV8gfSA9IHNvY2tldDsKICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihzb2NrZXQsIHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBjbG9zZV8uYmluZChzb2NrZXQpKCk7CiAgICAgICAgICAgIG9uQ2xvc2UoKTsKICAgICAgICAgIH0sCiAgICAgICAgICBwaW5nKCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgV2ViU29ja2V0UmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgICBjYXVzZTogbmV3IFNvY2tldENsb3NlZEVycm9yKHsgdXJsOiBzb2NrZXQudXJsIH0pCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBjb25zdCBib2R5ID0gewogICAgICAgICAgICAgICAganNvbnJwYzogIjIuMCIsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICJuZXRfdmVyc2lvbiIsCiAgICAgICAgICAgICAgICBwYXJhbXM6IFtdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICBzb2NrZXQuc2VuZChKU09OLnN0cmluZ2lmeShib2R5KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0KHsgYm9keSB9KSB7CiAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IFdlYlNvY2tldFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgICBib2R5LAogICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgY2F1c2U6IG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybDogc29ja2V0LnVybCB9KQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gc29ja2V0LnNlbmQoSlNPTi5zdHJpbmdpZnkoYm9keSkpOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9LAogICAgICBrZWVwQWxpdmUsCiAgICAgIHJlY29ubmVjdCwKICAgICAgdXJsCiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9ycGMvY29tcGF0LmpzCiAgYXN5bmMgZnVuY3Rpb24gZ2V0U29ja2V0KHVybCkgewogICAgY29uc3QgY2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybCk7CiAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihjbGllbnQuc29ja2V0LCB7CiAgICAgIHJlcXVlc3RzOiBjbGllbnQucmVxdWVzdHMsCiAgICAgIHN1YnNjcmlwdGlvbnM6IGNsaWVudC5zdWJzY3JpcHRpb25zCiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy90eXBlZERhdGEuanMKICBpbml0X2FiaSgpOwogIGluaXRfYWRkcmVzcygpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL3R5cGVkRGF0YS5qcwogIGluaXRfYmFzZSgpOwogIHZhciBJbnZhbGlkUHJpbWFyeVR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAg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dGEuanMKICBpbml0X2VuY29kZUFiaVBhcmFtZXRlcnMoKTsKICBpbml0X2NvbmNhdCgpOwogIGluaXRfdG9IZXgoKTsKICBpbml0X2tlY2NhazI1NigpOwogIGZ1bmN0aW9uIGhhc2hUeXBlZERhdGEocGFyYW1ldGVycykgewogICAgY29uc3QgeyBkb21haW4gPSB7fSwgbWVzc2FnZSwgcHJpbWFyeVR5cGUgfSA9IHBhcmFtZXRlcnM7CiAgICBjb25zdCB0eXBlcyA9IHsKICAgICAgRUlQNzEyRG9tYWluOiBnZXRUeXBlc0ZvckVJUDcxMkRvbWFpbih7IGRvbWFpbiB9KSwKICAgICAgLi4ucGFyYW1ldGVycy50eXBlcwogICAgfTsKICAgIHZhbGlkYXRlVHlwZWREYXRhKHsKICAgICAgZG9tYWluLAogICAgICBtZXNzYWdlLAogICAgICBwcmltYXJ5VHlwZSwKICAgICAgdHlwZXMKICAgIH0pOwogICAgY29uc3QgcGFydHMgPSBbIjB4MTkwMSJdOwogICAgaWYgKGRvbWFpbikKICAgICAgcGFydHMucHVzaChoYXNoRG9tYWluKHsKICAgICAgICBkb21haW4sCiAgICAgICAgdHlwZXMKICAgICAgfSkpOwogICAgaWYgKHByaW1hcnlUeXBlICE9PSAiRUlQNzEyRG9tYWluIikKICAgICAgcGFydHMucHVzaChoYXNoU3RydWN0KHsKICAgICAgICBkYXRhOiBtZXNzYWdlLAogICAgICAgIHByaW1hcnlUeXBlLAogICAgICAgIHR5cGVzCiAgICAgIH0pKTsKICAgIHJldHVybiBrZWNjYWsyNTYoY29uY2F0KHBhcnRzKSk7CiAgfQogIGZ1bmN0aW9uIGhhc2hEb21haW4oeyBkb21haW4sIHR5cGVzIH0pIHsKICAgIHJldHVybiBoYXNoU3RydWN0KHsKICAgICAgZGF0YTogZG9tYWluLAogICAgICBwcmltYXJ5VHlwZTogIkVJUDcxMkRvbWFpbiIsCiAgICAgIHR5cGVzCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gaGFzaFN0cnVj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KSwgewogICAgICAgIHNpemU6IGlzQXJyYXkgPyAzMiA6IG51bGwKICAgICAgfSk7CiAgICB9CiAgICBpZiAodHlwZSA9PT0gInN0cmluZyIpCiAgICAgIHJldHVybiBzdHJpbmdUb0hleCh2YWx1ZSk7CiAgICBpZiAodHlwZSA9PT0gImJ5dGVzIikKICAgICAgcmV0dXJuIHZhbHVlOwogICAgaWYgKHR5cGUgPT09ICJib29sIikKICAgICAgcmV0dXJuIHBhZChib29sVG9IZXgodmFsdWUpLCB7IHNpemU6IGlzQXJyYXkgPyAzMiA6IDEgfSk7CiAgICBjb25zdCBpbnRNYXRjaCA9IHR5cGUubWF0Y2goaW50ZWdlclJlZ2V4Mik7CiAgICBpZiAoaW50TWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBiYXNlVHlwZSwgYml0cyA9ICIyNTYiXSA9IGludE1hdGNoOwogICAgICBjb25zdCBzaXplMyA9IE51bWJlci5wYXJzZUludChiaXRzKSAvIDg7CiAgICAgIHJldHVybiBudW1iZXJUb0hleCh2YWx1ZSwgewogICAgICAgIHNpemU6IGlzQXJyYXkgPyAzMiA6IHNpemUzLAogICAgICAgIHNpZ25lZDogYmFzZVR5cGUgPT09ICJpbnQiCiAgICAgIH0pOwogICAgfQogICAgY29uc3QgYnl0ZXNNYXRjaCA9IHR5cGUubWF0Y2goYnl0ZXNSZWdleDIpOwogICAgaWYgKGJ5dGVzTWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBzaXplM10gPSBieXRlc01hdGNoOwogICAgICBpZiAoTnVtYmVyLnBhcnNlSW50KHNpemUzKSAhPT0gKHZhbHVlLmxlbmd0aCAtIDIpIC8gMikKICAgICAgICB0aHJvdyBuZXcgQnl0ZXNTaXplTWlzbWF0Y2hFcnJvcih7CiAgICAgICAgICBleHBlY3RlZFNpemU6IE51bWJlci5wYXJzZUludChzaXplMyksCiAgICAgICAgICBnaXZlblNpemU6ICh2YWx1ZS5sZW5ndGggLSAyKSAvIDIKICAgIC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07CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCAxNjsgaSsrKSB7CiAgICAgICAgICBjb25zdCB0bCA9IHJvdGwoYWwgKyBmKGdyb3VwLCBibCwgY2wsIGRsKSArIFJfQlVGW3JsW2ldXSArIGhibCwgc2xbaV0pICsgZWwgfCAwOwogICAgICAgICAgYWwgPSBlbCwgZWwgPSBkbCwgZGwgPSByb3RsKGNsLCAxMCkgfCAwLCBjbCA9IGJsLCBibCA9IHRsOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDE2OyBpKyspIHsKICAgICAgICAgIGNvbnN0IHRyID0gcm90bChhciArIGYockdyb3VwLCBiciwgY3IsIGRyKSArIFJfQlVGW3JyW2ldXSArIGhiciwgc3JbaV0pICsgZXIgfCAwOwogICAgICAgICAgYXIgPSBlciwgZXIgPSBkciwgZHIgPSByb3RsKGNyLCAxMCkgfCAwLCBjciA9IGJyLCBiciA9IHRyOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLnNldCh0aGlzLmgxICsgY2wgKyBkciB8IDAsIHRoaXMuaDIgKyBkbCArIGVyIHwgMCwgdGhpcy5oMyArIGVsICsgYXIgfCAwLCB0aGlzLmg0ICsgYWwgKyBiciB8IDAsIHRoaXMuaDAgKyBibCArIGNyIHwgMCk7CiAgICB9CiAgICByb3VuZENsZWFuKCkgewogICAgICBSX0JVRi5maWxsKDApOwogICAgfQogICAgZGVzdHJveSgpIHsKICAgICAgdGhpcy5kZXN0cm95ZWQgPSB0cnVlOwogICAgICB0aGlzLmJ1ZmZlci5maWxsKDApOwogICAgICB0aGlzLnNldCgwLCAwLCAwLCAwLCAwKTsKICAgIH0KICB9OwogIHZhciByaXBlbWQxNjAgPSAvKiBAX19QVVJFX18gKi8gd3JhcENvbnN0cnVjdG9yKCgpID0+IG5ldyBSSVBFTUQxNjAoKSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1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ICAgdmFsdWUsCiAgICAgICAgICBkYXRhLAogICAgICAgICAgYWNjZXNzTGlzdCwKICAgICAgICAgIGF1dGhvcml6YXRpb25MaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAiZWlwNzcwMiIKICAgICAgfSk7CiAgICBjb25zdCB0cmFuc2FjdGlvbiA9IHsKICAgICAgY2hhaW5JZDogaGV4VG9OdW1iZXIoY2hhaW5JZCksCiAgICAgIHR5cGU6ICJlaXA3NzAyIgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvTnVtYmVyKG5vbmNlKTsKICAgIGlmIChpc0hleCh2YWx1ZSkgJiYgdmFsdWUgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnZhbHVlID0gaGV4VG9CaWdJbnQodmFsdWUpOwogICAgaWYgKGlzSGV4KG1heEZlZVBlckdhcykgJiYgbWF4RmVlUGVyR2FzICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5tYXhGZWVQZXJHYXMgPSBoZXhUb0JpZ0ludChtYXhGZWVQZXJHYXMpOwogICA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zTGlzdCwgdiwgciwgc10gPSB0cmFuc2FjdGlvbkFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDkgfHwgdHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDEyKSkKICAgICAgdGhyb3cgbmV3IEludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25FcnJvcih7CiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2hhaW5JZCwKICAgICAgICAgIG5vbmNlLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBtYXhGZWVQZXJHYXMsCiAgICAgICAgICBnYXMsCiAgICAgICAgICB0bywKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGFjY2Vzc0xpc3QsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDkgPyB7CiAgICAgICAgICAgIHYsCiAgICAgICAgICAgIHIsCiAgICAgICAgICAgIHMKICAgICAgICAgIH0gOiB7fQogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uLAogICAgICAgIHR5cGU6ICJlaXAxNTU5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICBjaGFpbklkOiBoZXhUb051bWJlcihjaGFpbklkKSwKICAgICAgdHlwZTogImVpcDE1NTkiCiAgICB9OwogICAgaWYgKGlzSGV4KHRvKSAmJiB0byAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24udG8gPSB0bzsKICAgIGlmIChpc0hleChnYXMpICYmIGdhcyAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZ2FzID0gaGV4VG9CaWdJbnQoZ2FzKTsKICAgIGlmIChpc0hleChkYXRhKSAmJiBkYXRhICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5kYXRhID0gZGF0YTsKICAgIGlmIChpc0hleChub25jZS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GdhcywgdG8sIHZhbHVlLCBkYXRhLCBjaGFpbklkT3JWXywgciwgc10gPSB0cmFuc2FjdGlvbkFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDYgfHwgdHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDkpKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBub25jZSwKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDYgPyB7CiAgICAgICAgICAgIHY6IGNoYWluSWRPclZfLAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAibGVnYWN5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICB0eXBlOiAibGVnYWN5IgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvTnVtYmVyKG5vbmNlKTsKICAg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nYgPT09IDM1biA/IDBuIDogMW4pOwogICAgICAgIH0KICAgICAgICBpZiAoY2hhaW5JZCA+IDApCiAgICAgICAgICByZXR1cm4gQmlnSW50KGNoYWluSWQgKiAyKSArIEJpZ0ludCgzNW4gKyBzaWduYXR1cmUudiAtIDI3bik7CiAgICAgICAgY29uc3QgdjIgPSAyN24gKyAoc2lnbmF0dXJlLnYgPT09IDI3biA/IDBuIDogMW4pOwogICAgICAgIGlmIChzaWduYXR1cmUudiAhPT0gdjIpCiAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZExlZ2FjeVZFcnJvcih7IHY6IHNpZ25hdHVyZS52IH0pOwogICAgICAgIHJldHVybiB2MjsKICAgICAgfSkoKTsKICAgICAgY29uc3QgciA9IHRyaW0oc2lnbmF0dXJlLnIpOwogICAgICBjb25zdCBzID0gdHJpbShzaWduYXR1cmUucyk7CiAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiA9IFsKICAgICAgICAuLi5zZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdG9IZXgodiksCiAgICAgICAgciA9PT0gIjB4MDAiID8gIjB4IiA6IHIsCiAgICAgICAgcyA9PT0gIjB4MDAiID8gIjB4IiA6IHMKICAgICAgXTsKICAgIH0gZWxzZSBpZiAoY2hhaW5JZCA+IDApIHsKICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gWwogICAgICAgIC4uLnNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0b0hleChjaGFpbklkKSwKICAgICAgICAiMHgiLAogICAgICAgICIweCIKICAgICAgXTsKICAgIH0KICAgIHJldHVybiB0b1JscChzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogIH0KICBmdW5jdGlvbiB0b1lQYXJpdHlTaWduYXR1cmVBcnJheSh0cmFuc2FjdGlvbiwgc2lnbmF0dXJlXykgewogICAgY29uc3Qgc2lnbmF0dXJlID0gc2lnbmF0dXJlXyA/PyB0cmFuc2FjdGlv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zZXQoeyBhZGRyZXNzLCBjaGFpbklkIH0sIG5vbmNlKTsKICAgICAgICBub25jZU1hcC5zZXQoa2V5LCBub25jZSk7CiAgICAgICAgcmV0dXJuIG5vbmNlOwogICAgICB9LAogICAgICBhc3luYyBpbmNyZW1lbnQoeyBhZGRyZXNzLCBjaGFpbklkIH0pIHsKICAgICAgICBjb25zdCBrZXkgPSBnZXRLZXkoeyBhZGRyZXNzLCBjaGFpbklkIH0pOwogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICBkZWx0YU1hcC5zZXQoa2V5LCBkZWx0YSArIDEpOwogICAgICB9LAogICAgICBhc3luYyBnZXQoeyBhZGRyZXNzLCBjaGFpbklkLCBjbGllbnQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgbGV0IHByb21pc2UgPSBwcm9taXNlTWFwLmdldChrZXkpOwogICAgICAgIGlmICghcHJvbWlzZSkgewogICAgICAgICAgcHJvbWlzZSA9IChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgY29uc3Qgbm9uY2UgPSBhd2FpdCBzb3VyY2UuZ2V0KHsgYWRkcmVzcywgY2hhaW5JZCwgY2xpZW50IH0pOwogICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzTm9uY2UgPSBub25jZU1hcC5nZXQoa2V5KSA/PyAwOwogICAgICAgICAgICAgIGlmIChwcmV2aW91c05vbmNlID4gMCAmJiBub25jZSA8PSBwcmV2aW91c05vbmNlKQogICAgICAgICAgICAgICAgcmV0dXJuIHByZXZpb3VzTm9uY2UgKyAxOwogICAgICAgICAgICAgIG5vbmNlTWFwLmRlbGV0ZShrZXkpOwogICAgICAgICAgICAgIHJldHVybiBub25jZTsKICAgICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgICB0aGlzLnJlc2V0KHsgYWRkcmVzcywgY2hhaW5JZCB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkoKTsKICAgICAgICAgIHByb21pc2VNYXAuc2V0KGtleSwgcHJvbWlzZSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICByZXR1cm4gZGVsdGEgKyBhd2FpdCBwcm9taXNlOwogICAgICB9LAogICAgICByZXNldCh7IGFkZHJlc3MsIGNoYWluSWQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgZGVsdGFNYXAuZGVsZXRlKGtleSk7CiAgICAgICAgcHJvbWlzZU1hcC5kZWxldGUoa2V5KTsKICAgICAgfQogICAgfTsKICB9CiAgZnVuY3Rpb24ganNvblJwYygpIHsKICAgIHJldHVybiB7CiAgICAgIGFzeW5jIGdldChwYXJhbWV0ZXJzKSB7CiAgICAgICAgY29uc3QgeyBhZGRyZXNzLCBjbGllbnQgfSA9IHBhcmFtZXRlcnM7CiAgICAgICAgcmV0dXJuIGdldFRyYW5zYWN0aW9uQ291bnQoY2xpZW50LCB7CiAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9LAogICAgICBzZXQoKSB7CiAgICAgIH0KICAgIH07CiAgfQogIHZhciBub25jZU1hbmFnZXIgPSAvKiBAX19QVVJFX18gKi8gY3JlYXRlTm9uY2VNYW5hZ2VyKHsKICAgIHNvdXJjZToganNvblJwYygpCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9mb3JtYXR0ZXJzL3Byb29mLmpzCiAgZnVuY3Rpb24gZm9ybWF0U3RvcmFnZVByb29mKHN0b3JhZ2VQcm9vZikgewogICAgcmV0dXJ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YXRjaCAoZXJyKSB7CiAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGFyZ3MsCiAgICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2NvbnRyYWN0L211bHRpY2FsbCIsCiAgICAgICAgICBmdW5jdGlvbk5hbWUKICAgICAgICB9KTsKICAgICAgICBpZiAoIWFsbG93RmFpbHVyZSkKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIGNodW5rZWRDYWxsc1tjdXJyZW50Q2h1bmtdID0gWwogICAgICAgICAgLi4uY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10sCiAgICAgICAgICB7CiAgICAgICAgICAgIGFsbG93RmFpbHVyZTogdHJ1ZSwKICAgICAgICAgICAgY2FsbERhdGE6ICIweCIsCiAgICAgICAgICAgIHRhcmdldDogYWRkcmVzcwogICAgICAgICAgfQogICAgICAgIF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGFnZ3JlZ2F0ZTNSZXN1bHRzID0gYXdhaXQgUHJvbWlzZS5hbGxTZXR0bGVkKGNodW5rZWRDYWxscy5tYXAoKGNhbGxzKSA9PiBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKSh7CiAgICAgIGFiaTogbXVsdGljYWxsM0FiaSwKICAgICAgYWRkcmVzczogbXVsdGljYWxsQWRkcmVzcywKICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgYmxvY2tOdW1iZXIsCiAgICAgIGJsb2NrVGFnLAogICAgICBmdW5jdGlvbk5hbWU6ICJhZ2dyZWdhdGUzIiwKICAgICAgc3RhdGVPdmVycmlkZQogICAgfSkpKTsKICAgIGNvbnN0IHJlc3VsdHMgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYWdncmVnYXRlM1Jlc3VsdHMubGVuZ3RoOyBpKyspIHsKICAgICAgY29uc3QgcmVzdWx0ID0gYWdncmVnYXRlM1Jlc3VsdHNbaV07CiAgICAgIGlmIChyZXN1bHQuc3RhdHVzID09PSAicmVqZWN0ZWQiKSB7CiAgICAgICAgaWYgKCFhbGxvd0ZhaWx1cmUpCiAgICAgICAgICB0aHJvdyByZXN1bHQucmVhc29uOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY2h1bmtlZENhbGxzW2ldLmxlbmd0aDsgaisrKSB7CiAgICAgICAgICByZXN1bHRzLnB1c2goewogICAgICAgICAgICBzdGF0dXM6ICJmYWlsdXJlIiwKICAgICAgICAgICAgZXJyb3I6IHJlc3VsdC5yZWFzb24sCiAgICAgICAgICAgIHJlc3VsdDogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QgYWdncmVnYXRlM1Jlc3VsdCA9IHJlc3VsdC52YWx1ZTsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBhZ2dyZWdhdGUzUmVzdWx0Lmxlbmd0aDsgaisrKSB7CiAgICAgICAgY29uc3QgeyByZXR1cm5EYXRhLCBzdWNjZXNzIH0gPSBhZ2dyZWdhdGUzUmVzdWx0W2pdOwogICAgICAgIGNvbnN0IHsgY2FsbERhdGEgfSA9IGNodW5rZWRDYWxsc1tpXVtqXTsKICAgICAgICBjb25zdCB7IGFiaTogYWJpMiwgYWRkcmVzcywgZnVuY3Rpb25OYW1lLCBhcmdzIH0gPSBjb250cmFjdHMyW3Jlc3VsdHMubGVuZ3RoXTsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGNhbGxEYXRhID09PSAiMHgiKQogICAgICAgICAgICB0aHJvdyBuZXcgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yKCk7CiAgICAgICAgICBpZiAoIXN1Y2Nlc3MpCiAgICAgICAgICAgIHRocm93IG5ldyBSYXdDb250cmFjdEVycm9yKHsgZGF0YTogcmV0dXJuRGF0YSB9KTsKICAgICAgICAgIGNvbnN0IHJlc3VsdDIgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgZGF0YTogcmV0dXJuRGF0YSwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIHJlc3VsdHMucHVzaChhbGxvd0ZhaWx1cmUgPyB7IHJlc3VsdDogcmVzdWx0Miwgc3RhdHVzOiAic3VjY2VzcyIgfSA6IHJlc3VsdDIpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2RvY3MvY29udHJhY3QvbXVsdGljYWxsIiwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIGlmICghYWxsb3dGYWlsdXJlKQogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIHJlc3VsdHMucHVzaCh7IGVycm9yLCByZXN1bHQ6IHZvaWQgMCwgc3RhdHVzOiAiZmFpbHVyZSIgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAocmVzdWx0cy5sZW5ndGggIT09IGNvbnRyYWN0czIubGVuZ3RoKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigibXVsdGljYWxsIHJlc3VsdHMgbWlzbWF0Y2giKTsKICAgIHJldHVybiByZXN1bHRzOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL3ZlcmlmeUhhc2guanMKICBpbml0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bCB9KSB7CiAgICBjb25zdCBlbmFibGVQb2xsaW5nID0gKCgpID0+IHsKICAgICAgaWYgKHR5cGVvZiBwb2xsXyAhPT0gInVuZGVmaW5lZCIpCiAgICAgICAgcmV0dXJuIHBvbGxfOwogICAgICBpZiAoY2xpZW50LnRyYW5zcG9ydC50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIgJiYgY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzWzBdLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIHJldHVybiB0cnVlOwogICAgfSkoKTsKICAgIGxldCBwcmV2QmxvY2tOdW1iZXI7CiAgICBjb25zdCBwb2xsQmxvY2tOdW1iZXIgPSAoKSA9PiB7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaEJsb2NrTnVtYmVyIiwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGVtaXRPbkJlZ2luLAogICAgICAgIGVtaXRNaXNzZWQsCiAgICAgICAgcG9sbGluZ0ludGVydmFsCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uQmxvY2tOdW1iZXIsIG9uRXJyb3IgfSwgKGVtaXQpID0+IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7IGNhY2hlVGltZTogMCB9KTsKICAgICAgICAgIGlmIChwcmV2QmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgaWYgKGJsb2NrTnVtYmVyID09PSBwcmV2QmxvY2tOdW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2tOdW1iZXIgLSBwcmV2QmxvY2tOdW1iZXIgPiAxICYmIGVtaXRNaXNzZWQpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBpID0gcHJldkJsb2NrTnVtYmVyICsgMW47IGkgPCBibG9ja051bWJlcjsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoaSwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoIXByZXZCbG9ja051bWJlciB8fCBibG9ja051bWJlciA+IHByZXZCbG9ja051bWJlcikgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoYmxvY2tOdW1iZXIsIHByZXZCbG9ja051bWJlcik7CiAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja051bWJlciA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQmxvY2tOdW1iZXIiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZW1pdE9uQmVnaW4sCiAgICAgICAgZW1pdE1pc3NlZAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrTnVtYmVyLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IGFjdGl2ZSA9IHRydWU7CiAgICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIikgewogICAgICAgICAgICAgICAgY29uc3QgdHJhbnNwb3J0MiA9IGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0cy5maW5kKCh0cmFuc3BvcnQzKSA9PiB0cmFuc3BvcnQzLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0Iik7CiAgICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICAgICAgcmV0dXJuIHRyYW5zcG9ydDIudmFsdWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJuZXdIZWFkcyJdLAogICAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2tOdW1iZXIgPSBoZXhUb0JpZ0ludChkYXRhLnJlc3VsdD8ubnVtYmVyKTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9ja051bWJlcihibG9ja051bWJlciwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIHVuc3Vic2NyaWJlID0gdW5zdWJzY3JpYmVfOwogICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICB1bnN1YnNjcmliZSgpOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgICAgfQogICAgICAgIH0pKCk7CiAgICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICAgIH0pOwogICAgfTsKICAgIHJldHVybiBlbmFibGVQb2xsaW5nID8gcG9sbEJsb2NrTnVtYmVyKCkgOiBzdWJzY3JpYmVCbG9ja051bWJlcigpOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL3dhaXRGb3JUcmFuc2FjdGlvblJlY2VpcHQuanMKICBhc3luYyBmdW5jdGlvbiB3YWl0Rm9yVHJhbnNhY3Rpb25SZWNlaXB0KGNsaWVudCwgewogICAgY29uZmlybWF0aW9ucyA9IDEsCiAgICBoYXNoOiBoYXNoMywKICAgIG9uUmVwbGFjZWQsCiAgICBwb2xsaW5nSW50ZXJ2YWwgPSBjbGllbnQucG9sbGluZ0ludGVydmFsLAogICAgcmV0cnlDb3VudCA9IDYsCiAgICByZXRyeURlbGF5ID0gKHsgY291bnQgfSkgPT4gfn4oMSA8PCBjb3VudCkgKiAyMDAsCiAgICAvLyBleHBvbmVudGlhbCBiYWNrb2ZmCiAgICB0aW1lb3V0ID0gMThlNAogIH0pIH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TsKICAgICAgICAgIGxldCBibG9ja051bWJlciA9IGJsb2NrTnVtYmVyXzsKICAgICAgICAgIGlmIChyZXRyeWluZykKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgaWYgKHJlY2VpcHQpIHsKICAgICAgICAgICAgICBpZiAoY29uZmlybWF0aW9ucyA+IDEgJiYgKCFyZWNlaXB0LmJsb2NrTnVtYmVyIHx8IGJsb2NrTnVtYmVyIC0gcmVjZWlwdC5ibG9ja051bWJlciArIDFuIDwgY29uZmlybWF0aW9ucykpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgZG9uZSgoKSA9PiBlbWl0LnJlc29sdmUocmVjZWlwdCkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgIGF3YWl0IHdpdGhSZXRyeShhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uLCAiZ2V0VHJhbnNhY3Rpb24iKSh7IGhhc2g6IGhhc2gzIH0pOwogICAgICAgICAgICAgICAgaWYgKHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyKQogICAgICAgICAgICAgICAgICBibG9ja051bWJlciA9IHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgcmV0cnlDb3VudAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIHJldHJ5aW5nID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVjZWlwdCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uUmVjZWlwdCwgImdldFRyYW5zYWN0aW9uUmVjZWlwdCIpKHsgaGFzaDogaGFzaDMgfSk7CiAgICAgICAgICAgIGlmIChjb25maXJtYXRpb25zID4gMSAmJiAoIXJlY2VpcHQuYmxvY2tOdW1iZXIgfHwgYmxvY2tOdW1iZXIgLSByZWNlaXB0LmJsb2NrTnVtYmVyICsgMW4gPCBjb25maXJtYXRpb25zKSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZXNvbHZlKHJlY2VpcHQpKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVHJhbnNhY3Rpb25Ob3RGb3VuZEVycm9yIHx8IGVyciBpbnN0YW5jZW9mIFRyYW5zYWN0aW9uUmVjZWlwdE5vdEZvdW5kRXJyb3IpIHsKICAgICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgICByZXRyeWluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiA9IHRyYW5zYWN0aW9uOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCB3aXRoUmV0cnkoKCkgPT4gZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHsKICAgICAgICAgICAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVUcmFuc2FjdGlvbnM6IHRydWUKICAgICAgICAgICAgICAgIH0pLCB7CiAgICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgICByZXRyeUNvdW50LAogICAgICAgICAgICAgICAgICBzaG91bGRSZXRyeTogKHsgZXJyb3IgfSkgPT4gZXJyb3IgaW5zdGFuY2VvZiBCbG9ja05vdEZvdW5kRXJyb3IKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcGxhY2VtZW50VHJhbnNhY3Rpb24gPSBibG9jay50cmFuc2FjdGlvbnMuZmluZCgoeyBmcm9tLCBub25jZSB9KSA9PiBmcm9tID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLmZyb20gJiYgbm9uY2UgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24ubm9uY2UpOwogICAgICAgICAgICAgICAgaWYgKCFyZXBsYWNlbWVudFRyYW5zYWN0aW9uKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICByZWNlaXB0ID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0VHJhbnNhY3Rpb25SZWNlaXB0LCAiZ2V0VHJhbnNhY3Rpb25SZWNlaXB0IikoewogICAgICAgICAgICAgICAgICBoYXNoOiByZXBsYWNlbWVudFRyYW5zYWN0aW9uLmhhc2gKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgaWYgKGNvbmZpcm1hdGlvbnMgPiAxICYmICghcmVjZWlwdC5ibG9ja051bWJlciB8fCBibG9ja051bWJlciAtIHJlY2VpcHQuYmxvY2tOdW1iZXIgKyAxbiA8IGNvbmZpcm1hdGlvbnMpKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgcmVhc29uID0gInJlcGxhY2VkIjsKICAgICAgICAgICAgICAgIGlmIChyZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24udmFsdWUpIHsKICAgICAgICAgICAgICAgICAgcmVhc29uID0gInJlcHJpY2VkIjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVwbGFjZW1lbnRUcmFuc2FjdGlvbi5mcm9tID09PSByZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IDBuKSB7CiAgICAgICAgICAgICAgICAgIHJlYXNvbiA9ICJjYW5jZWxsZWQiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZG9uZSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgIGVtaXQub25SZXBsYWNlZD8uKHsKICAgICAgICAgICAgICAgICAgICByZWFzb24sCiAgICAgICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbjogcmVwbGFjZW1lbnRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvblJlY2VpcHQ6IHJlY2VpcHQKICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgIGVtaXQucmVzb2x2ZShyZWNlaXB0KTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0gY2F0Y2ggKGVycl8pIHsKICAgICAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZWplY3QoZXJyXykpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBkb25lKCgpID0+IGVtaXQucmVqZWN0KGVycikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9KTsKICAgIH0pOwogICAgcmV0dXJuIHByb21pc2U7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vYWN0aW9ucy9wdWJsaWMvd2F0Y2hCbG9ja3MuanM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nNhY3Rpb25zLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrLCBvbkVycm9yIH0sIChlbWl0KSA9PiBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRCbG9jaywgImdldEJsb2NrIikoewogICAgICAgICAgICBibG9ja1RhZywKICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoYmxvY2subnVtYmVyICYmIHByZXZCbG9jaz8ubnVtYmVyKSB7CiAgICAgICAgICAgIGlmIChibG9jay5udW1iZXIgPT09IHByZXZCbG9jay5udW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2subnVtYmVyIC0gcHJldkJsb2NrLm51bWJlciA+IDEgJiYgZW1pdE1pc3NlZCkgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSBwcmV2QmxvY2s/Lm51bWJlciArIDFuOyBpIDwgYmxvY2subnVtYmVyOyBpKyspIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrMiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgICAgIGJsb2NrTnVtYmVyOiBpLAogICAgICAgICAgICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9jayhibG9jazIsIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoCiAgICAgICAgICAgIC8vIElmIG5vIHByZXZpb3VzIGJsb2NrIGV4aXN0cywgZW1pdC4KICAgICAgICAgICAgIXByZXZCbG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBibG9jayB0YWcgaXMgInBlbmRpbmciIHdpdGggbm8gYmxvY2sgbnVtYmVyLCBlbWl0LgogICAgICAgICAgICBibG9ja1RhZyA9PT0gInBlbmRpbmciICYmICFibG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBuZXh0IGJsb2NrIG51bWJlciBpcyBncmVhdGVyIHRoYW4gdGhlIHByZXZpb3VzIGJsb2NrIG51bWJlciwgZW1pdC4KICAgICAgICAgICAgLy8gV2UgZG9uJ3Qgd2FudCB0byBlbWl0IGJsb2NrcyBpbiB0aGUgcGFzdC4KICAgICAgICAgICAgYmxvY2subnVtYmVyICYmIGJsb2NrLm51bWJlciA+IHByZXZCbG9jay5udW1iZXIKICAgICAgICAgICkgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgIHByZXZCbG9jayA9IGJsb2NrOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja3MgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgZW1pdEZldGNoZWQgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGVtaXRPbkJlZ2luKSB7CiAgICAgICAgICAgIGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgICB9KS50aGVuKChibG9jaykgPT4gewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGlmICghZW1pdEZldGNoZWQpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgb25CbG9jayhibG9jaywgdm9pZCAwKTsKICAgICAgICAgICAgICBlbWl0RmV0Y2hlZCA9IGZhbHNlOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibmV3SGVhZHMiXSwKICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBjb25zdCBmb3JtYXQgPSBjbGllbnQuY2hhaW4/LmZvcm1hdHRlcnM/LmJsb2NrPy5mb3JtYXQgfHwgZm9ybWF0QmxvY2s7CiAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBmb3JtYXQoZGF0YS5yZXN1bHQpOwogICAgICAgICAgICAgIG9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgZW1pdEZldGNoZWQgPSBmYWxzZTsKICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIG9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgdW5zdWJzY3JpYmUoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgIH0KICAgICAgfSkoKTsKICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsQmxvY2tzKCkgOiBzdWJzY3JpYmVCbG9ja3MoKTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL3B1YmxpYy93YXRjaEV2ZW50LmpzCiAgaW5pdF9zdHJpbmdpZnkoKTsKICBpbml0X2FiaSgpOwogIGluaXRfcnBjKCk7CiAgZnVuY3Rpb24gd2F0Y2hFdmVudChjbGllbnQsIHsgYWRkcmVzcywgYXJncywgYmF0Y2ggPSB0cnVlLCBldmVudCwgZX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0IHByZXZpb3VzQmxvY2tOdW1iZXI7CiAgICAgICAgaWYgKGZyb21CbG9jayAhPT0gdm9pZCAwKQogICAgICAgICAgcHJldmlvdXNCbG9ja051bWJlciA9IGZyb21CbG9jayAtIDFuOwogICAgICAgIGxldCBmaWx0ZXI7CiAgICAgICAgbGV0IGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgY29uc3QgdW53YXRjaCA9IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgICAgaWYgKCFpbml0aWFsaXplZCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZUV2ZW50RmlsdGVyLCAiY3JlYXRlRXZlbnRGaWx0ZXIiKSh7CiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIGV2ZW50LAogICAgICAgICAgICAgICAgZXZlbnRzLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciAhPT0gYmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgICAgIGxvZ3MgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRMb2dzLCAiZ2V0TG9ncyIpKHsKICAgICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgICAgZXZlbnQsCiAgICAgICAgICAgICAgICAgIGV2ZW50cywKICAgICAgICAgICAgICAgICAgZnJvbUJsb2NrOiBwcmV2aW91c0Jsb2NrTnVtYmVyICsgMW4sCiAgICAgICAgICAgICAgICAgIHRvQmxvY2s6IGJsb2NrTnVtYmVyCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUV2ZW50ID0gKCkgPT4gewogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBldmVudHNfID0gZXZlbnRzID8/IChldmVudCA/IFtldmVudF0gOiB2b2lkIDApOwogICAgICAgICAgbGV0IHRvcGljcyA9IFtdOwogICAgICAgICAgaWYgKGV2ZW50c18pIHsKICAgICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50c18uZmxhdE1hcCgoZXZlbnQyKSA9PiBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgICAgICAgICAgYWJpOiBbZXZlbnQyXSwKICAgICAgICAgICAgICBldmVudE5hbWU6IGV2ZW50Mi5uYW1lLAogICAgICAgICAgICAgIGFyZ3MKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB0b3BpY3MgPSBbZW5jb2RlZF07CiAgICAgICAgICAgIGlmIChldmVudCkKICAgICAgICAgICAgICB0b3BpY3MgPSB0b3BpY3NbMF07CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibG9ncyIsIHsgYWRkcmVzcywgdG9waWNzIH1dLAogICAgICAgICAgICBvbkRhdGEoZGF0YSkgewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGNvbnN0IGxvZyA9IGRhdGEucmVzdWx0OwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBjb25zdCB7IGV2ZW50TmFtZSwgYXJnczogYXJnczIgfSA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgICAgICAgICAgYWJpOiBldmVudHNfID8/IFtdLAogICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgdG9waWNzOiBsb2cudG9waWNzLAogICAgICAgICAgICAgICAgICBzdHJpY3QKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgeyBhcmdzOiBhcmdzMiwgZXZlbnROYW1lIH0pOwogICAgICAgICAgICAgICAgb25Mb2dzKFtmb3JtYXR0ZWRdKTsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIGxldCBldmVudE5hbWU7CiAgICAgICAgICAgICAgICBsZXQgaXNVbm5hbWVkOwogICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIERlY29kZUxvZ0RhdGFNaXNtYXRjaCB8fCBlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCkgewogICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgIGV2ZW50TmFtZSA9IGVyci5hYmlJdGVtLm5hbWU7CiAgICAgICAgICAgICAgICAgIGlzVW5uYW1lZCA9IGVyci5hYmlJdGVtLmlucHV0cz8uc29tZSgoeCkgPT4gISgibmFtZSIgaW4geCAmJiB4Lm5hbWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZCA9IGZvcm1hdExvZyhsb2csIHsKICAgICAgICAgICAgICAgICAgYXJnczogaXNVbm5hbWVkID8gW10gOiB7fSwKICAgICAgICAgICAgICAgICAgZXZlbnROYW1lCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LAogICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICB1bnN1YnNjcmliZSA9IHVuc3Vic2NyaWJlXzsKICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICB1bnN1YnNjcmliZSgpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgb25FcnJvcj8uKG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0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGlmICghZmlsdGVyKSB7CiAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciwgImNyZWF0ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciIpKHt9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIHVud2F0Y2goKTsKICAgICAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgaGFzaGVzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgaWYgKGhhc2hlcy5sZW5ndGggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmF0Y2gpCiAgICAgICAgICAgICAgZW1pdC5vblRyYW5zYWN0aW9ucyhoYXNoZXMpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBoYXNoMyBvZiBoYXNoZXMpCiAgICAgICAgICAgICAgICBlbWl0Lm9uVHJhbnNhY3Rpb25zKFtoYXNoM10pOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZVBlbmRpbmdUcmFuc2FjdGlvbnMgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgeyB1bnN1YnNjcmliZTogdW5zdWJzY3JpYmVfIH0gPSBhd2FpdCBjbGllbnQudHJhbnNwb3J0LnN1YnNjcmliZSh7CiAgICAgICAgICAgIHBhcmFtczogWyJuZXdQZW5kaW5nVHJhbnNhY3Rpb25zIl0sCiAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgaWYgKCFhY3RpdmUpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICBvblRyYW5zYWN0aW9ucyhbdHJhbnNhY3Rpb25dKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIG9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgdW5zdWJzY3JpYmUoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgIH0KICAgICAgfSkoKTsKICAgICAgcmV0dXJuICg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WVvdXRfID8/IGNvbmZpZy50aW1lb3V0ID8/IDFlNDsKICAgICAgY29uc3QgdXJsXyA9IHVybCB8fCBjaGFpbj8ucnBjVXJscy5kZWZhdWx0LndlYlNvY2tldD8uWzBdOwogICAgICBpZiAoIXVybF8pCiAgICAgICAgdGhyb3cgbmV3IFVybFJlcXVpcmVkRXJyb3IoKTsKICAgICAgcmV0dXJuIGNyZWF0ZVRyYW5zcG9ydCh7CiAgICAgICAga2V5LAogICAgICAgIG5hbWUsCiAgICAgICAgYXN5bmMgcmVxdWVzdCh7IG1ldGhvZCwgcGFyYW1zIH0pIHsKICAgICAgICAgIGNvbnN0IGJvZHkgPSB7IG1ldGhvZCwgcGFyYW1zIH07CiAgICAgICAgICBjb25zdCBycGNDbGllbnQgPSBhd2FpdCBnZXRXZWJTb2NrZXRScGNDbGllbnQodXJsXywgewogICAgICAgICAgICBrZWVwQWxpdmUsCiAgICAgICAgICAgIHJlY29ubmVjdAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCB7IGVycm9yLCByZXN1bHQgfSA9IGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0QXN5bmMoewogICAgICAgICAgICBib2R5LAogICAgICAgICAgICB0aW1lb3V0CiAgICAgICAgICB9KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogIndlYlNvY2tldCIKICAgICAgfSwgewogICAgICAgIGdldFNvY2tldCgpIHsKICAgICAgICAgIHJldHVybiBnZXRTb2NrZXQodXJsXyk7CiAgICAgICAgfSwKICAgICAgICBnZXRScGNDbGllbnQoKSB7CiAgICAgICAgICByZXR1cm4gZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgIH0sCiAgICAgICAgYXN5bmMgc3Vic2NyaWJlKHsgcGFyYW1zLCBvbkRhdGEsIG9uRXJyb3IgfSkgewogICAgICAgICAgY29uc3QgcnBjQ2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgICAgY29uc3QgeyByZXN1bHQ6IHN1YnNjcmlwdGlvbklkIH0gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIGJvZHk6IHsKICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfc3Vic2NyaWJlIiwKICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIHJlamVjdChlcnJvcik7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuZXJyb3IpIHsKICAgICAgICAgICAgICAgIHJlamVjdChyZXNwb25zZS5lcnJvcik7CiAgICAgICAgICAgICAgICBvbkVycm9yPy4ocmVzcG9uc2UuZXJyb3IpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc3BvbnNlLmlkID09PSAibnVtYmVyIikgewogICAgICAgICAgICAgICAgcmVzb2x2ZShyZXNwb25zZSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChyZXNwb25zZS5tZXRob2QgIT09ICJldGhfc3Vic2NyaXB0aW9uIikKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBvbkRhdGEocmVzcG9uc2UucGFyYW1zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgc3Vic2NyaXB0aW9uSWQsCiAgICAgICAgICAgIGFzeW5jIHVuc3Vic2NyaWJlKCkgewogICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4gcnBjQ2xpZW50LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfdW5zdWJzY3JpYmUiLAogICAgICAgICAgICAgICAgICBwYXJhbXM6IFtzdWJzY3JpcHRpb25JZF0KICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiByZXNvbHZlCiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgfSk7CiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2luZGV4LmpzCiAgaW5pdF9hYmlzKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvYWRkcmVzcy5qcwogIHZhciB6ZXJvQWRkcmVzcyA9ICIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAiOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vaW5kZXguanMKICBpbml0X2NvbnRyYWN0cygpOwogIGluaXRfdW5pdCgpOwogIGluaXRfbnVtYmVyKCk7Ci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tYmVyOiBoZXhUb0JpZ0ludChsMlRvTDFMb2cuYmxvY2tIYXNoKSwKICAgICAgICAgICAgICBibG9ja0hhc2g6IGwyVG9MMUxvZy5ibG9ja0hhc2gsCiAgICAgICAgICAgICAgbDFCYXRjaE51bWJlcjogaGV4VG9CaWdJbnQobDJUb0wxTG9nLmwxQmF0Y2hOdW1iZXIpLAogICAgICAgICAgICAgIHRyYW5zYWN0aW9uSW5kZXg6IGhleFRvQmlnSW50KGwyVG9MMUxvZy50cmFuc2FjdGlvbkluZGV4KSwKICAgICAgICAgICAgICBzaGFyZElkOiBoZXhUb0JpZ0ludChsMlRvTDFMb2cuc2hhcmRJZCksCiAgICAgICAgICAgICAgaXNTZXJ2aWNlOiBsMlRvTDFMb2cuaXNTZXJ2aWNlLAogICAgICAgICAgICAgIHNlbmRlcjogbDJUb0wxTG9nLnNlbmRlciwKICAgICAgICAgICAgICBrZXk6IGwyVG9MMUxvZy5rZXksCiAgICAgICAgICAgICAgdmFsdWU6IGwyVG9MMUxvZy52YWx1ZSwKICAgICAgICAgICAgICB0cmFuc2FjdGlvbkhhc2g6IGwyVG9MMUxvZy50cmFuc2FjdGlvbkhhc2gsCiAgICAgICAgICAgICAgbG9nSW5kZXg6IGhleFRvQmlnSW50KGwyVG9MMUxvZy5sb2dJbmRleCkKICAgICAgICAgICAgfTsKICAgICAgICAgIH0pCiAgICAgICAgfTsKICAgICAgfQogICAgfSksCiAgICB0cmFuc2FjdGlvblJlcXVlc3Q6IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVUcmFuc2FjdGlvblJlcXVlc3QoewogICAgICBleGNsdWRlOiBbCiAgICAgICAgImN1c3RvbVNpZ25hdHVyZSIsCiAgICAgICAgImZhY3RvcnlEZXBzIiwKICAgICAgICAiZ2FzUGVyUHViZGF0YSIsCiAgICAgICAgInBheW1hc3RlciIsCiAgICAgICAgInBheW1hc3RlcklucHV0IgogICAgICBdLAogICAgICBmb3JtYXQoYXJncykgewogICAgICAgIGlmIChhcmdzLmdhc1BlclB1YmRhdGEgfHwgYXJncy5wYXltYXN0ZXIgJiYgYXJncy5wYXltYXN0ZXJJbnB1dCB8fCBhcmdzLmZhY3RvcnlEZXBzIHx8IGFyZ3MuY3VzdG9tU2lnbmF0dXJlKQogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgZWlwNzEyTWV0YTogewogICAgICAgICAgICAgIC4uLmFyZ3MuZ2FzUGVyUHViZGF0YSA/IHsgZ2FzUGVyUHViZGF0YTogdG9IZXgoYXJncy5nYXNQZXJQdWJkYXRhKSB9IDogeyBnYXNQZXJQdWJkYXRhOiB0b0hleChnYXNQZXJQdWJkYXRhRGVmYXVsdCkgfSwKICAgICAgICAgICAgICAuLi5hcmdzLnBheW1hc3RlciAmJiBhcmdzLnBheW1hc3RlcklucHV0ID8gewogICAgICAgICAgICAgICAgcGF5bWFzdGVyUGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgIHBheW1hc3RlcjogYXJncy5wYXltYXN0ZXIsCiAgICAgICAgICAgICAgICAgIHBheW1hc3RlcklucHV0OiBBcnJheS5mcm9tKGhleFRvQnl0ZXMoYXJncy5wYXltYXN0ZXJJbnB1dCkpCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSA6IHt9LAogICAgICAgICAgICAgIC4uLmFyZ3MuZmFjdG9yeURlcHMgPyB7CiAgICAgICAgICAgICAgICBmYWN0b3J5RGVwczogYXJncy5mYWN0b3J5RGVwcy5tYXAoKGRlcCkgPT4gQXJyYXkuZnJvbShoZXhUb0J5dGVzKGRlcCkpKQogICAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgICAuLi5hcmdzLmN1c3RvbVNpZ25hdHVyZSA/IHsKICAgICAgICAgICAgICAgIGN1c3RvbVNpZ25hdHVyZTogQXJyYXkuZnJvbShoZXhUb0J5dGVzKGFyZ3MuY3VzdG9tU2lnbmF0dXJlKSkKICAgICAgICAgICAgICB9IDoge30KICAgICAgICAgICAgfSwKICAgICA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mN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hbmNpZW50OC5nZyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkFuY2llbnQ4IGV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NjYW4uYW5jaWVudDguZ2ciLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vc2Nhbi5hbmNpZW50OC5nZy9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWRdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhCMDlEQzA4NDI4QzhiNEVGQjRmZjlDMDgyNzM4NkNERjM0Mjc3OTk2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkXTogewogICAgICAgICAgYWRkcmVzczogIjB4NjM5RjJBRUNFMzk4QWE3NmIwN2U1OWVGNmFiZTJjRmUzMmJhY2I2OCIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MDcwNTcxCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkXTogewogICAgICAgICAgYWRkcmVzczogIjB4ZDVlM2VEZjViNjgxMzVENTU5RDU3MkUyNmJGODYzRkJDMTk1MDAzMyIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MDcwNTcxCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQKICB9KTsKCiAgLy8gbm9kZV9t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ib2w6ICJBVkFYIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vYXBpLmF2YXgubmV0d29yay9leHQvYmMvQy9ycGMiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTbm93VHJhY2UiLAogICAgICAgIHVybDogImh0dHBzOi8vc25vd3RyYWNlLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS5zbm93dHJhY2UuaW8iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTE5MDc5MzQKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2F2YWxhbmNoZUZ1amkuanMKICB2YXIgYXZhbGFuY2hlRnVqaSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNDMxMTMsCiAgICBuYW1lOiAiQXZhbGFuY2hlIEZ1amkiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiQXZhbGFuY2hlIEZ1amkiLAogICAgICBzeW1ib2w6ICJBVkFYIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vYXBpLmF2YXgtdGVzdC5uZXR3b3JrL2V4dC9iYy9DL3JwYyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiA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AogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vcnBjMS5iYWhhbXV0LmlvIiwKICAgICAgICAgICJodHRwczovL2JhaGFtdXQtcnBjLnB1YmxpY25vZGUuY29tIiwKICAgICAgICAgICJodHRwczovL3JwYzIuYmFoYW11dC5pbyIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3dzMS5zYWhhcmEuYmFoYW11dGNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vYmFoYW11dC1ycGMucHVibGljbm9kZS5jb20iLAogICAgICAgICAgIndzczovL3dzMi5zYWhhcmEuYmFoYW11dGNoYWluLmNvbSIKICAgICAgICBdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZ0bnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vd3d3LmZ0bnNjYW4uY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3d3dy5mdG5zY2FuLmNvbS9hcGkiCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9iYXNlLmpzCiAgdmFyIHNvdXJjZUlkNiA9IDE7CiAgdmFyIGJhc2UgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDg0NTMsCiAgICBuYW1lOiAiQmFzZSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0c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oYWluIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAidEJSTktDIiwKICAgICAgc3ltYm9sOiAidEJSTktDIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vYnJua2MtdGVzdC5iZWFybmV0d29yay5uZXQiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCcm5rVGVzdFNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vYnJua3Rlc3Qtc2Nhbi5iZWFybmV0d29yay5uZXQiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYnJua3Rlc3Qtc2Nhbi5iZWFybmV0d29yay5uZXQvYXBpIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2JlcmFjaGFpblRlc3RuZXQuanMKICB2YXIgYmVyYWNoYWluVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODAwODUsCiAgICBuYW1lOiAiQmVyYWNoYWluIEFydGlvIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkJFUkEgVG9rZW4iLAogICAgICBzeW1ib2w6ICJCRVJBIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vYXJ0aW8ucnBjLmJlcmFjaGFpbi5jb20iXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6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llci1ycGMuY29tIiwKICAgICAgICAgICJodHRwczovL3JwYy5hbmtyLmNvbS9iaXRsYXllciIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly93cy5iaXRsYXllci5vcmciLCAid3NzOi8vd3MuYml0bGF5ZXItcnBjLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJpdGxheWVyKEJUUikgU2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly93d3cuYnRyc2Nhbi5jb20iCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9idHJUZXN0bmV0LmpzCiAgdmFyIGJ0clRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDIwMDgxMCwKICAgIG5hbWU6ICJCaXRsYXllciBUZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIG5hbWU6ICJCaXRjb2luIiwKICAgICAgc3ltYm9sOiAiQlRDIiwKICAgICAgZGVjaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLmJpdGxheWVyLm9yZyJdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3Rlc3RuZXQtd3MuYml0bGF5ZXIub3JnIiwKICAgICAgICAgICJ3c3M6Ly90ZXN0bmV0LXdzLmJpdGxheWVyLXJwYy5jb20iCiAgICAgICAgXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCaXRsY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9uKTsKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIC4uLmZvcm1hdHRlZCwKICAgICAgICAgICAgLi4udHJhbnNhY3Rpb24uZ2F0ZXdheUZlZSA/IHsKICAgICAgICAgICAgICBnYXRld2F5RmVlOiBoZXhUb0JpZ0ludCh0cmFuc2FjdGlvbi5nYXRld2F5RmVlKSwKICAgICAgICAgICAgICBnYXRld2F5RmVlUmVjaXBpZW50OiB0cmFuc2FjdGlvbi5nYXRld2F5RmVlUmVjaXBpZW50CiAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgZmVlQ3VycmVuY3k6IHRyYW5zYWN0aW9uLmZlZUN1cnJlbmN5CiAgICAgICAgICB9OwogICAgICAgIH0pOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICB0cmFuc2FjdGlvbnMsCiAgICAgICAgICAuLi5hcmdzLnJhbmRvbW5lc3MgPyB7IHJhbmRvbW5lc3M6IGFyZ3MucmFuZG9tbmVzcyB9IDoge30KICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICAgIHRyYW5zYWN0aW9uOiAvKiBAX19QVVJFX18gKi8gZGVmaW5lVHJhbnNhY3Rpb24oewogICAgICBmb3JtYXQoYXJncykgewogICAgICAgIGlmIChhcmdzLnR5cGUgPT09ICIweDdlIikKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIGlzU3lzdGVtVHg6IGFyZ3MuaXNTeXN0ZW1UeCwKICAgICAgICAgICAgbWludDogYXJncy5taW50ID8gaGV4VG9CaWdJbnQoYXJncy5taW50KSA6IHZvaWQgMCwKICAgICAgICAgICAgc291cmNlSGFzaDogYXJncy5zb3VyY2VIYXNoLAogICAgICAgICAgICB0eXBlOiAiZGVwb3NpdCIKICAgICAgICAgIH07CiAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSB7IGZlZUN1cnJlbmN5OiBhcmdzLmZlZUN1cnJlbmN5IH07CiAgICAgICAgaWYgKGFyZ3MudHlwZSA9PT0gIjB4N2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HVybDogImh0dHBzOi8vdGVzdG5ldC5jeWJlcnNjYW4uY28iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vdGVzdG5ldC5jeWJlcnNjYW4uY28vYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhmZmMzOTFGMDAxODI2OWQ0NzU4QUVBMWExNDQ3NzJFOEZCOTk1NDVFIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDMwNDU0NQogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2RhcndpbmlhLmpzCiAgdmFyIGRhcndpbmlhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA0NiwKICAgIG5hbWU6ICJEYXJ3aW5pYSBOZXR3b3JrIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlJJTkciLAogICAgICBzeW1ib2w6ICJSSU5HIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMuZGFyd2luaWEubmV0d29yayJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly9ycGMuZGFyd2luaWEubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7IG5hbWU6ICJFeHBsb3JlciIsIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZGFyd2luaWEubmV0d29yayIgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4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CiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy5kZWdlbi50aXBzIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiRGVnZW4gQ2hhaW4gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZGVnZW4udGlwcyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5kZWdlbi50aXBzL2FwaS92MiIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Rmay5qcwogIHZhciBkZmsgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDUzOTM1LAogICAgbmFtZTogIkRGSyBDaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJKZXdlbCIsCiAgICAgIHN5bWJvbDogIkpFV0VMIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9zdWJuZXRzLmF2YXgubmV0d29yay9kZWZpLWtpbmdkb21zL2Rmay1jaGFpbi9ycGMiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJERktTdWJuZXRTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3N1Ym5ldHMuYXZheC5uZXR3b3JrL2RlZmkta2luZ2RvbXMiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzN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ZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9lZGdld2FsbGV0MS54bG9uLm9yZyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV4Y2Vsb24gZXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZXhjZWxvbi5pbyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2ZhbnRvbS5qcwogIHZhciBmYW50b20gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDI1MCwKICAgIG5hbWU6ICJGYW50b20iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRmFudG9tIiwKICAgICAgc3ltYm9sOiAiRlRNIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjLmFua3IuY29tL2ZhbnRvbSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZUTVNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vZnRtc2Nhbi5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLmZ0bXNjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAzMzAwMTk4NwogICAgICB9CiAgICB9C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6cm9jLmFydCJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZpYm9TY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3NjYW4uZmlib2NoYWluLm9yZyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2ZpbGVjb2luLmpzCiAgdmFyIGZpbGVjb2luID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAzMTQsCiAgICBuYW1lOiAiRmlsZWNvaW4gTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJmaWxlY29pbiIsCiAgICAgIHN5bWJvbDogIkZJTCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL2FwaS5ub2RlLmdsaWYuaW8vcnBjL3YxIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiRmlsZm94IiwKICAgICAgICB1cmw6ICJodHRwczovL2ZpbGZveC5pbmZvL2VuIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDMzMjg1OTQKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2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BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNzQ3LAogICAgbmFtZTogIkZsb3dFVk0gTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJGbG93IiwKICAgICAgc3ltYm9sOiAiRkxPVyIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbWFpbm5ldC5ldm0ubm9kZXMub25mbG93Lm9yZyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1haW5uZXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZmxvd2RpdmVyLmlvIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvZmxvd1ByZXZpZXduZXQuanMKICB2YXIgZmxvd1ByZXZpZXduZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDY0NiwKICAgIG5hbWU6ICJGbG93RVZNIFByZXZpZXduZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRmxvdyIsCiAgICAgIHN5bWJvbDogIkZMT1ciCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3ByZXZpZXduZXQuZXZtLm5vZGVzLm9uZmxvdy5vcmciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJQcmV2aWV3bmV0IEV4c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JodHRwczovL3JwYy5mcmF4LmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImZyYXhzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2ZyYXhzY2FuLmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9hcGkuZnJheHNjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDE0XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjZDQzkxNkVkNUM2QzJGQTk3MDE0ZjdEMWNEMTQxNTI4QWUxNzFlNCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQxNF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDM2Y2I2NWMxOTY3QTBGYjBFRUUxMTU2OUM1MUMyZjJhQTFDYTZmNkQiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTEzNTMyMwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDE0XTogewogICAgICAgICAgYWRkcmVzczogIjB4MzRDMGJENTg3N0E1RWU3MDk5RDBmNTY4OEQ2NUY0YkI5MTU4QkRFMiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MTM1MzIzCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMTQKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5k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ICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMuYW5rci5jb20vaGFybW9ueSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkhhcm1vbnkgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuaGFybW9ueS5vbmUiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjQxODU3NTMKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hhc2hrZXlDaGFpblRlc3RuZXQuanMKICB2YXIgaGFzaGtleVRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEzMywKICAgIG5hbWU6ICJIYXNoS2V5IENoYWluIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiSGFzaEtleSBFY29Qb2ludHMiLAogICAgICBzeW1ib2w6ICJIU0siCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2hhc2hrZXljaGFpbi10ZXN0bmV0LmFsdC50ZWNobm9sb2d5Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSGFzaEtleSBDaGFpbiBFeHBsb3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1lOiAiaW5FVk0gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vaW5ldm0uY2FsZGVyYWV4cGxvcmVyLnh5eiIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9pbmV2bS5jYWxkZXJhZXhwbG9yZXIueHl6L2FwaS92MiIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMTg2MDYKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2lua1NlcG9saWEuanMKICB2YXIgc291cmNlSWQxOSA9IDExMTU1MTExOwogIHZhciBpbmtTZXBvbGlhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiA3NjMzNzMsCiAgICBuYW1lOiAiSW5rIFNlcG9saWEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlNlcG9saWEgRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMtZ2VsLXNlcG9saWEuaW5rb25jaGFpbi5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLXNlcG9saWEuaW5rb25jaGFpbi5jb20vIiwKICAgICAgICBhcGlVcm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c3QsCiAgICAgICAgZGF0YSwKICAgICAgICBnYXMsCiAgICAgICAgZ2FzUHJpY2UsCiAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgIG5vbmNlLAogICAgICAgIHRvLAogICAgICAgIHZhbHVlCiAgICAgIH0pOwogICAgICBjb25zdCB7IGJhc2VGZWVQZXJHYXMsIGdhc0xpbWl0LCBwcmlvcml0eUZlZVBlckdhcyB9ID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImxpbmVhX2VzdGltYXRlR2FzIiwKICAgICAgICBwYXJhbXM6IGJsb2NrID8gW3JlcXVlc3QsIGJsb2NrXSA6IFtyZXF1ZXN0XQogICAgICB9KTsKICAgICAgcmV0dXJuIHsKICAgICAgICBiYXNlRmVlUGVyR2FzOiBCaWdJbnQoYmFzZUZlZVBlckdhcyksCiAgICAgICAgZ2FzTGltaXQ6IEJpZ0ludChnYXNMaW1pdCksCiAgICAgICAgcHJpb3JpdHlGZWVQZXJHYXM6IEJpZ0ludChwcmlvcml0eUZlZVBlckdhcykKICAgICAgfTsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICB0aHJvdyBnZXRDYWxsRXJyb3IoZXJyLCB7CiAgICAgICAgLi4uYXJncywKICAgICAgICBhY2NvdW50LAogICAgICAgIGNoYWluOiBjbGllbnQuY2hhaW4KICAgICAgfSk7CiAgICB9CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vbGluZWEvY2hhaW5Db25maWcuanMKICB2YXIgY2hhaW5Db25maWc0ID0gewogICAgZmVlczogewogICAgICBlc3RpbWF0ZUZlZXNQZXJHYXM6IGVzdGltYXRlRmVlc1BlckdhczIsCiAgICAgIGFzeW5jIG1heFByaW9yaXR5RmVlUGVyR2FzKHsgYmxvY2ssIGNsaWVudCwgcmVxdWVzdCB9K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Ikxpc2siLAogICAgbmV0d29yazogImxpc2siLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hcGkubGlzay5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL2Jsb2Nrc2NvdXQubGlzay5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYmxvY2tzY291dC5saXNrLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweEE5ZDcxRTFkZDdjYTI2RjI2ZTY1NkU2NmQ2QUE4MWVkN2Y3NDViZjAiCiAgICAgIH0sCiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7CiAgICAgICAgW3NvdXJjZUlkMjBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgxMTNjQjk5MjgzQUYyNDJEYTBBMEM1NDM0NzY2N2VkRjUzMUFhN2Q2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgyNmRCOTNGOGI4YjRmNzAxNjI0MGFmNjJGNzczMDk3OWQzNTNmOUE3IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDIwXTogewogICAgICAgICAgYWRkcmVzczogIjB4MjY1ODcy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vbSIsCiAgICAgICAgICAiaHR0cHM6Ly91cy1lYXN0Lmx5Y2FuY2hhaW4uY29tIiwKICAgICAgICAgICJodHRwczovL3VzLXdlc3QubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgImh0dHBzOi8vZXUtbm9ydGgubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgImh0dHBzOi8vZXUtd2VzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAiaHR0cHM6Ly9hc2lhLXNvdXRoZWFzdC5seWNhbmNoYWluLmNvbSIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3JwYy5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vdXMtZWFzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vdXMtd2VzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vZXUtbm9ydGgubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgIndzczovL2V1LXdlc3QubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgIndzczovL2FzaWEtc291dGhlYXN0Lmx5Y2FuY2hhaW4uY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTHljYW4gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubHljYW5jaGFpbi5jb20iCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9seXJhLmpzCiAgdmFyIGx5cmEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDk1NywKICAgIG5hbWU6ICJMeXJhIENoYWluIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5seXJhLmZpbmFuY2UiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJMeXJhIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLmx5cmEuZmluYW5jZSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5seXJhLmZpbmFuY2UvYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MzUxOTgKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21haW5uZXQuanMKICB2YXIgbWFpbm5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMSwKICAgIG5hbWU6ICJFdGhlcmV1bSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9jbG91ZGZsYXJlLWV0aC5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVm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AgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLm1ldGFsbDIuY29tIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy5tZXRhbGwyLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLm1ldGFsbDIuY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLm1ldGFsbDIuY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDIyXTogewogICAgICAgICAgYWRkcmVzczogIjB4M0IxRjdhRGEwRmNjMjZCMTM1MTVhZjc1MkRkMDdmQjFDQWMxMTQyNiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDAKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjJdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgzRjM3YUJkRTJDNmI1QjJlZDZGODA0NTc4N0RmMUVEMUUzNzUzOTU2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDIyXTogewogICAgICAgICAgYWRkcmVzczogIjB4NmQwZjY1RDU5YjU1QjBGRUM1ZDJkMTUzNjUxNTREY0FEQzE0MEJGMyIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQyMgogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGVyLmpzCiAgdmFyIG1ldGVyID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4MiwKICAgIG5hbWU6ICJNZXRlciIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJNVFIiLAogICAgICBzeW1ib2w6ICJNVFIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMubWV0ZXIuaW8iXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNZXRlclNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vc2Nhbi5tZXRlci5pbyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGVyVGVzdG5ldC5qcwogIHZhciBtZXRlclRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDgzLAogICAgbmFtZTogIk1ldGVyIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiTVRSIiwKICAgICAgc3ltYm9sOiAiTVRSIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjdGVzdC5tZXRlci5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4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UN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5uZXQubW9kZS5uZXR3b3JrIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTW9kZXNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vbW9kZXNjYW4uaW8iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjQ2NTg4MgogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDIzXTogewogICAgICAgICAgYWRkcmVzczogIjB4NDMxN2JhMTQ2RDQ5MzNEODg5NTE4YTNlNUUxMUZlN2E1MzE5OWIwNCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDIzXTogewogICAgICAgICAgYWRkcmVzczogIjB4OEIzNGIxNGM3YzcxMjM0NTlDZjMwNzZiOENiOTI5QkUwOTdkMEMwNyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQyM106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDczNWFEQmJFNzIyMjZCRDUyZTgxOEU3MTgxOTUzZjQyRTNiMEZGMjEiCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkM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B9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJOZW9uc2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9kZXZuZXQubmVvbnNjYW4ub3JnIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwNTIwNjExMgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL25lb25NYWlubmV0LmpzCiAgdmFyIG5lb25NYWlubmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyNDUwMjI5MzQsCiAgICBuZXR3b3JrOiAibmVvbk1haW5uZXQiLAogICAgbmFtZTogIk5lb24gRVZNIE1haW5OZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIk5FT04iLCBzeW1ib2w6ICJORU9OIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbmVvbi1wcm94eS1tYWlubmV0LnNvbGFuYS5wMnAub3JnIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTmVvbnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vbmVvbnNjYW4ub3JnIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2Fs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AgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vZXhjaGFpbnJwYy5va2V4Lm9yZyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIm9rbGluayIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly93d3cub2tsaW5rLmNvbS9va2MiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTAzNjQ3OTIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL29vcnRtYWlubmV0RGV2LmpzCiAgdmFyIG9vcnRNYWlubmV0RGV2ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA5NzAwLAogICAgbmFtZTogIk9PUlQgTWFpbm5ldERldiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJPT1JUIiwKICAgICAgc3ltYm9sOiAiT09SVCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL2Rldi1ycGMub29ydGVjaC5jb20iXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJPT1JUIE1haW5uZXREZXYgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZGV2LXNjYW4ub29ydGVjaC5jb20iCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9t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3k6IHsgbmFtZTogIkV0aGVyIiwgc3ltYm9sOiAiRVRIIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbWFpbm5ldC5vcHRpbWlzbS5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk9wdGltaXNtIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL29wdGltaXN0aWMuZXRoZXJzY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1vcHRpbWlzdGljLmV0aGVyc2Nhbi5pby9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgZGlzcHV0ZUdhbWVGYWN0b3J5OiB7CiAgICAgICAgW3NvdXJjZUlkMjddOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhlNTk2NUFiNTk2MmVEYzc0NzdDODUyMDI0M0E5NTUxN0NEMjUyZkE5IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyN106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGRmZTk3ODY4MjMzZDFhYTIyZTgxNWEyNjY5ODJmMmNmMTc2ODVhMjciCiAgICAgICAgfQogICAgICB9LAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA0Mjg2MjYzCiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDI3XTogewogICAgICAgICAgYWRkcmVzczogIjB4YkViNUZj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ExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxNTQyOTI0OAogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3Bnbi5qcwogIHZhciBzb3VyY2VJZDMwID0gMTsKICB2YXIgcGduID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA0MjQsCiAgICBuZXR3b3JrOiAicGduIiwKICAgIG5hbWU6ICJQR04iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkV0aGVyIiwgc3ltYm9sOiAiRVRIIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnB1YmxpY2dvb2RzLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJQR04gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIucHVibGljZ29vZHMubmV0d29yayIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5wdWJsaWNnb29kcy5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDMwXTogewogICAgICAgICAgYWRkcmVzczogIjB4OUU2MjA0Rjc1MGNEODY2YjI5OTU5NGUyYUM5ZUE4MjRFMmU1Zjk1YyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhj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DogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGN1cmwubWFpbm5ldC5wbGdjaGFpbi5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJQbGdzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3d3dy5wbGdzY2FuLmNvbSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4MDk4OTU3NjE2MGYyZTcwOTI5MDhCQjk0Nzk2MzFiOTAxMDYwYjZlNCIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDQ0ODkKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3BsdW1lVGVzdG5ldC5qcwogIHZhciBzb3VyY2VJZDMyID0gMTExNTUxMTE7CiAgdmFyIHBsdW1lVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMTYxMjIxMTM1LAogICAgbmFtZTogIlBsdW1lIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgbmFtZTogIlBsdW1lIFNlcG9saWEgRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vdGVzdG5ldC1ycGMucGx1bWVuZXR3b3JrLnh5ei9odHRwIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3Rlc3RuZXQtcnBjLnBsdW1lbmV0d29yay54eXovd3MiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFe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S9jaGFpbnMvZGVmaW5pdGlvbnMvcG9seWdvbk11bWJhaS5qcwogIHZhciBwb2x5Z29uTXVtYmFpID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4MDAwMSwKICAgIG5hbWU6ICJQb2x5Z29uIE11bWJhaSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiTUFUSUMiLCBzeW1ib2w6ICJNQVRJQyIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hbmtyLmNvbS9wb2x5Z29uX211bWJhaSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlBvbHlnb25TY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL211bWJhaS5wb2x5Z29uc2Nhbi5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLXRlc3RuZXQucG9seWdvbnNjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAyNTc3MDE2MAogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3BvbHlnb25aa0V2bS5qcwogIHZhciBwb2x5Z29uWmtFdm0gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDExMDEsCiAgICBuYW1lOiAiUG9seWdvbiB6a0VWT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AgICAgW3NvdXJjZUlkMzNdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhhNDI2QTA1MmY2NTdBRUVlZmMyOThiM0I1YzM1YTQ3MGU0NzM5ZDY5IiwKICAgICAgICAgIGJsb2NrQ3JlYXRlZDogMTk1NzgzMzcKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQzM106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGM0NzNjYTdFMDJhZjI0YzEyOWMyZUVmNTFGMmFEZjA0MTFjMURmNjkiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTU3ODMzMQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3JleWFOZXR3b3JrLmpzCiAgdmFyIHJleWFOZXR3b3JrID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxNzI5LAogICAgbmFtZTogIlJleWEgTmV0d29yayIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBkZWNpbWFsczogMTgsIG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMucmV5YS5uZXR3b3JrIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3dzLnJleWEubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlJleWEgTmV0d29yayBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5yZXlhLm5ldHdvcmsiCiAgICAgIH0KICAgIH0sCiAgICB0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VzdG5ldC5qcwogIHZhciByb2xsdXhUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA1N2UzLAogICAgbmFtZTogIlJvbGx1eCBUZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlN5c2NvaW4iLAogICAgICBzeW1ib2w6ICJTWVMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy10YW5lbmJhdW0ucm9sbHV4LmNvbS8iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vcnBjLXRhbmVuYmF1bS5yb2xsdXguY29tL3dzcyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlJvbGx1eFRlc3RuZXRFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9yb2xsdXgudGFuZW5iYXVtLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3JvbGx1eC50YW5lbmJhdW0uaW8vYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE4MTM2NzUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3JvbmluLmpzCiAgdmFyIHJvbmluID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMDIwLAogICAgbmFtZTogIl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Nhbi54eXoiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vc2hhcGVzY2FuLnh5ei9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQzNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDZFZjhjNjlDZkU0NjM1ZDg2NmUzRTAyNzMyMDY4MDIyYzA2ZTcyNEQiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDM2OTk0MAogICAgICAgIH0KICAgICAgfSwKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEVCMDZmRmExNjAxMUI1NjI4QmFCOThFMjk3NzYzNjFjODM3NDFkZDMiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDM2OTkzMwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDM2XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjJFZGQ1ZjQ5MzBFYTkyZENhM2ZCODE2ODliREQ5YjlkMDc2YjU3QiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwMzY5OTM1CiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMzYKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9zaGFwZVNlcG9saWEuanMKICB2YXIgc291cmNlSWQzNyA9IDExMTU1MTExOwogIHZhciBzaGFwZVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDExMDExLAogICAgbmFtZTogIlNoYXBlIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiU2Vwb2xpYSBFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEuc2hhcGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXItc2Vwb2xpYS5zaGFwZS5uZXR3b3JrLyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci1zZXBvbGlhLnNoYXBlLm5ldHdvcmsvYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDEKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQzNwogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoYXJkZXVtU3BoaW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gIG5ldHdvcms6ICJzaGltbWVyIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlNoaW1tZXIiLAogICAgICBzeW1ib2w6ICJTTVIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS5zaGltbWVyLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTaGltbWVyIE5ldHdvcmsgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZXZtLnNoaW1tZXIubmV0d29yayIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5ldm0uc2hpbW1lci5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoaW1tZXJUZXN0bmV0LmpzCiAgdmFyIHNoaW1tZXJUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMDczLAogICAgbmFtZTogIlNoaW1tZXIgVGVzdG5ldCIsCiAgICBuZXR3b3JrOiAic2hpbW1lci10ZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlNoaW1tZXIiLAogICAgICBzeW1ib2w6ICJTTVIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS50ZXN0bmV0LnNoaW1tZXIubmV0d29yayJdCiAgICAgIH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9sOiAiRVRIIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vdGVzdG5ldC5zbmF4Y2hhaW4uaW8iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTbmF4IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQzOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDIwNmE3NWQ4OWQ0NUYxNDZDNTQwMjBGMTMyRkY5M2JFREQwOWY1NUUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM5XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjBlM0EzNjhhNGNkQ0VmODVmZkI5NjRlMzcyNzI2RjU2QTQ2MjIxZSIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGI1YWZkZDBFOGRERjA4MUVmOTBlOEEzZTBjN2I1Nzk4ZTY2RTk1NEUiCiAgICAgICAgfQogICAgICB9LAogICAgIC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LAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIudGVzdG5ldC5zb3Bob24ueHl6IgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHg4M2MwNGQxMTJhZGVkQTJDNkQ5MDM3YmI2ZWNiNDJFN2YwYjEwOEFmIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE1NjQyCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvc3BpY3kuanMKICB2YXIgc3BpY3kgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDg4ODgyLAogICAgbmFtZTogIkNoaWxpeiBTcGljeSBUZXN0bmV0IiwKICAgIG5ldHdvcms6ICJjaGlsaXotc3BpY3ktVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJDSFoiLAogICAgICBzeW1ib2w6ICJDSFoiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vc3BpY3ktcnBjLmNoaWxpei5jb20iLAogICAgICAgICAgImh0dHBzOi8vY2hpbGl6LXNwaWN5LXJwYy5wdWJsaWNub2RlLmNvbSIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3NwaWN5LXJwYy13cy5jaGlsaXouY29tIiwKICAgICAgICAgICJ3c3M6Ly9jaGlsaXotc3BpY3ktcnBjLnB1YmxpY25vZGUuY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwb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VyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NhdHVybi1leHBsb3Jlci5zd2FuY2hhaW4uaW8iCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvc3lzY29pbi5qcwogIHZhciBzeXNjb2luID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA1NywKICAgIG5hbWU6ICJTeXNjb2luIE1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiU3lzY29pbiIsCiAgICAgIHN5bWJvbDogIlNZUyIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnN5c2NvaW4ub3JnIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy5zeXNjb2luLm9yZy93c3MiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTeXNjb2luRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuc3lzY29pbi5vcmciLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuc3lzY29pbi5vcmcvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDI4NzEzOQogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVf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MvZGVmaW5pdGlvbnMvdGhhdC5qcwogIHZhciB0aGF0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4NDI4LAogICAgbmFtZTogIlRIQVQgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiVEhBVCIsIHN5bWJvbDogIlRIQVQiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9hcGkudGhhdGNoYWluLmlvL21haW5uZXQiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL3RoYXQuYmxvY2tzY291dC5jb20iCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3RoZXRhLmpzCiAgdmFyIHRoZXRhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAzNjEsCiAgICBuYW1lOiAiVGhldGEgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiVEZVRUwiLCBzeW1ib2w6ICJURlVFTCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2V0aC1ycGMtYXBpLnRoZXRhdG9rZW4ub3JnL3JwYyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlRoZXRhIEV4cGxvcmVyIiwKICAgICAgICB1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NjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8veGRjc2Nhbi5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweDBCMTc5NWNjQThFNGVDNGRmMDIzNDZhMDgyZGY1NEQ0MzdGOEQ5YUYiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogNzU4ODQwMjAKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3hkY1Rlc3RuZXQuanMKICB2YXIgeGRjVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNTEsCiAgICBuYW1lOiAiQXBvdGhlbSBOZXR3b3JrIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlRYREMiLAogICAgICBzeW1ib2w6ICJUWERDIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vZXJwYy5hcG90aGVtLm5ldHdvcmsiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJYRENTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQueGRjc2Nhbi5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogNTk3NjUzODkKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX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cnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy56aGVqaWFuZy5ldGhwYW5kYW9wcy5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJlYWNvbmNoYWluIiwKICAgICAgICB1cmw6ICJodHRwczovL3poZWppYW5nLmJlYWNvbmNoYS5pbiIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy96aWxsaXFhLmpzCiAgdmFyIHppbGxpcWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDMyNzY5LAogICAgbmFtZTogIlppbGxpcWEiLAogICAgbmV0d29yazogInppbGxpcWEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlppbGxpcWEiLCBzeW1ib2w6ICJaSUwiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9hcGkuemlsbGlxYS5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFdGhlcm5hbCIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9ldm14LnppbGxpcWEuY29tIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy96aWxsaXFhVGVzdG5ldC5qcwogI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S1tYWlubmV0LmxpcXVpZnkuY29tIiwKICAgICAgICAgICJodHRwczovL3ppcmN1aXQtbWFpbm5ldC5kcnBjLm9yZyIKICAgICAgICBdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlppcmN1aXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuemlyY3VpdC5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3ppcmN1aXRUZXN0bmV0LmpzCiAgdmFyIHppcmN1aXRUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA0ODg5OSwKICAgIG5hbWU6ICJaaXJjdWl0IFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkVUSCIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vemlyY3VpdDEtdGVzdG5ldC5wMnBpZnkuY29tIiwKICAgICAgICAgICJodHRwczovL3ppcmN1aXQxLXRlc3RuZXQubGlxdWlmeS5jb20iCiAgICAgICAgXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJaaXJ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ICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogNjA5MDk1OQogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy96a0ZhaXJUZXN0bmV0LmpzCiAgdmFyIHprRmFpclRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDQzODUxLAogICAgbmFtZTogIlpLRmFpciBUZXN0bmV0IiwKICAgIG5ldHdvcms6ICJ6a2ZhaXItdGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJVU0QgQ29pbiIsCiAgICAgIHN5bWJvbDogIlVTREMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLnprZmFpci5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogInprRmFpciBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly90ZXN0bmV0LXNjYW4uemtmYWlyLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3prTGlua05vdmEuanMKICB2YXIgemtMaW5rTm92YSA9IC8qIEBfX1BVUkVf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4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NlcG9saWEuZXhwbG9yZXIuemtsaW5rLmlvIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvemtzeW5jLmpzCiAgdmFyIHprc3luYyA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICAuLi5jaGFpbkNvbmZpZywKICAgIGlkOiAzMjQsCiAgICBuYW1lOiAiWktzeW5jIEVyYSIsCiAgICBuZXR3b3JrOiAiemtzeW5jLWVyYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbWFpbm5ldC5lcmEuemtzeW5jLmlvIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL21haW5uZXQuZXJhLnprc3luYy5pby93cyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV0aGVyc2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9lcmEuemtzeW5jLm5ldHdvcmsvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1lcmEuemtzeW5jLm5ldHdvcmsvYXBpIgogICAgICB9LAogICAgICBuYXRpdmU6IHsKICAgICAgICBuYW1lOiAiWktzeW5jIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnprc3luYy5pby8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYmxvY2stZXhwbG9yZXItYXBpLm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6IDc3Nzc3NzcsCiAgICBuYW1lOiAiWm9yYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnpvcmEuZW5lcmd5Il0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy56b3JhLmVuZXJneSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnpvcmEuZW5lcmd5IiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLnpvcmEuZW5lcmd5L2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDQ0XTogewogICAgICAgICAgYWRkcmVzczogIjB4OUU2MjA0Rjc1MGNEODY2YjI5OTU5NGUyYUM5ZUE4MjRFMmU1Zjk1YyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDU4ODIKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkNDRdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgxYTBhZDAxMTkxM0ExNTBmNjlmNkExOURGNDQ3QTBDZkQ5NTUxMDU0IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDQ0XTogewogICAgICAgICAgYWRkcmVzczogIjB4M2UyRWE5QjkyQjdFNDhBNTIyOTZmRDI2MWRjMjZmZDk5NTI4NDYzMSIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQ0NAogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3pvcmFTZXBvbGlhLmpzCiAgdmFyIHNvdXJjZUlkNDUgPSAxMTE1NTExMTsKICB2YXIgem9yYVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDk5OTk5OTk5OSwKICAgIG5hbWU6ICJab3JhIFNlcG9saWEiLAogICAgbmV0d29yazogInpvcmEtc2Vwb2xpYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJab3JhIFNlcG9saWEiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEucnBjLnpvcmEuZW5lcmd5Il0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3NlcG9saWEucnBjLnpvcmEuZW5lcmd5Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiWm9yYSBTZXBvbGlhIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NlcG9saWEuZXhwbG9yZXIuem9yYS5lbmVyZ3kvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3NlcG9sa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Jlc3NlcygpOwogICAgICBjb25zb2xlLmxvZygicmVxdWVzdEFjY291bnRzIiwgYWRkcmVzcyk7CiAgICAgIHRoaXMuc2VsZWN0ZWRBZGRyZXNzID0gYWRkcmVzczsKICAgICAgcmV0dXJuIFthZGRyZXNzXTsKICAgIH0KICAgIGdldEFjY291bnRzKCkgewogICAgICByZXR1cm4gdGhpcy5zZWxlY3RlZEFkZHJlc3MgPyBbdGhpcy5zZWxlY3RlZEFkZHJlc3NdIDogW107CiAgICB9CiAgICBhc3luYyBzZW5kVHJhbnNhY3Rpb24odHgpIHsKICAgICAgaWYgKCF0aGlzLnNlbGVjdGVkQWRkcmVzcykgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiTm8gYWNjb3VudHMgYXZhaWxhYmxlIik7CiAgICAgIH0KICAgICAgaWYgKCF0eC50byB8fCAhdHgudmFsdWUgfHwgIXR4LmdhcykgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiTWlzc2luZyByZXF1aXJlZCB0cmFuc2FjdGlvbiBwYXJhbWV0ZXJzIik7CiAgICAgIH0KICAgICAgY29uc29sZS5sb2coInNlbmRUcmFuc2FjdGlvbiB0eDogIiwgdHgpOwogICAgICBjb25zb2xlLmxvZygiVHJhbnNhY3Rpb24gZ2FzUHJpY2U6ICIsIHR4Lmdhc1ByaWNlKTsKICAgICAgY29uc29sZS5sb2coIlRyYW5zYWN0aW9uIGdhczogIiwgdHguZ2FzKTsKICAgICAgY29uc3QgdmFsdWUgPSBCaWdJbnQodHgudmFsdWUpOwogICAgICBjb25zdCB2YWx1ZUluRXRoID0gTnVtYmVyKHZhbHVlKSAvIDEwICoqIDE4OwogICAgICBjb25zb2xlLmxvZyhgVHJhbnNhY3Rpb24gdmFsdWUgaW4gRVRIOiAke3ZhbHVlSW5FdGh9YCk7CiAgICAgIGNvbnN0IHRyYW5zYWN0aW9uQ29udGVudCA9IHsKICAgICAgICB0bzogdHgudG8sCiAgICAgICAgdmFsdWUsCiAgICAgICAgZGF0YT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ICAgICAgY29uc3QgbWVzc2FnZSA9IFsKICAgICAgICAgICAgc2hvcnRNZXNzYWdlIHx8ICJBbiBlcnJvciBvY2N1cnJlZC4iLAogICAgICAgICAgICAiIiwKICAgICAgICAgICAgLi4uYXJncy5tZXRhTWVzc2FnZXMgPyBbLi4uYXJncy5tZXRhTWVzc2FnZXMsICIiXSA6IFtdLAogICAgICAgICAgICAuLi5kb2NzUGF0aDkgPyBbYERvY3M6IGh0dHBzOi8vYWJpdHlwZS5kZXYke2RvY3NQYXRoOX1gXSA6IFtdLAogICAgICAgICAgICAuLi5kZXRhaWxzID8gW2BEZXRhaWxzOiAke2RldGFpbHN9YF0gOiBbXSwKICAgICAgICAgICAgYFZlcnNpb246IGFiaXR5cGVAJHt2ZXJzaW9ufWAKICAgICAgICAgIF0uam9pbigiXG4iKTsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkZXRhaWxzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZG9jc1BhdGgiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtZXRhTWVzc2FnZXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaG9ydE1lc3NhZ2UiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkFiaVR5cGVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKGFyZ3MuY2F1c2UpCiAgICAgICAgICAgIHRoaXMuY2F1c2UgPSBhcmdzLmNhdXNlOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5zaG9ydE1lc3NhZ2UgPSBzaG9ydE1lc3NhZ2U7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9yZWdleC5qcwogIGZ1bmN0aW9uIGV4ZWNUeXBlZChyZWdleCwgc3RyaW5nKSB7CiAgICBjb25zdCBtYXRjaCA9IHJlZ2V4LmV4Z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KTsKICAgICAgSW52YWxpZEFiaUl0ZW1FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHNpZ25hdHVyZSB9KSB7CiAgICAgICAgICBzdXBlcigiRmFpbGVkIHRvIHBhcnNlIEFCSSBpdGVtLiIsIHsKICAgICAgICAgICAgZGV0YWlsczogYHBhcnNlQWJpSXRlbSgke0pTT04uc3RyaW5naWZ5KHNpZ25hdHVyZSwgbnVsbCwgMil9KWAsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2FwaS9odW1hbiNwYXJzZWFiaWl0ZW0tMSIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRBYmlJdGVtRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVua25vd25UeXBlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0eXBlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHR5cGUuIiwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgVHlwZSAiJHt0eXBlfSIgaXMgbm90IGEgdmFsaWQgQUJJIHR5cGUuIFBlcmhhcHMgeW91IGZvcmdvdCB0byBpbmNsdWRlIGEgc3RydWN0IHNpZ25hdHVyZT9gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIlVua25vd25UeXBlRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVua25vd25Tb2xpZGl0eVR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoIlVua25vd24gdHlwZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogW2BUeXBlICIke3R5cGV9IiBpcyBub3QgYSB2YWxpZCBBQkkgdHlwZS5gXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNvbGlkaXR5VHlwZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9lcnJvcnMvYWJpUGFyYW1ldGVyLmpzCiAgdmFyIEludmFsaWRBYmlQYXJhbWV0ZXJFcnJvciwgSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciwgSW52YWxpZFBhcmFtZXRlckVycm9yLCBTb2xpZGl0eVByb3RlY3RlZEtleXdvcmRFcnJvciwgSW52YWxpZE1vZGlmaWVyRXJyb3IsIEludmFsaWRGdW5jdGlvbk1vZGlmaWVyRXJyb3IsIEludmFsaWRBYmlUeXB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ICAgICAgICAgICBkZXRhaWxzOiBgcGFyc2VBYmlQYXJhbWV0ZXJzKCR7SlNPTi5zdHJpbmdpZnkocGFyYW1zLCBudWxsLCAyKX0pYCwKICAgICAgICAgICAgZG9jc1BhdGg6ICIvYXBpL2h1bWFuI3BhcnNlYWJpcGFyYW1ldGVycy0xIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZFBhcmFtZXRlckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0gfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6ICJJbnZhbGlkUGFyYW1ldGVyRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFNvbGlkaXR5UHJvdGVjdGVkS2V5d29yZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIG5hbWUgfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtLAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgIiR7bmFtZX0iIGlzIGEgcHJvdGVjdGVkIFNvbGlkaXR5IGtleXdvcmQuIE1vcmUgaW5mbzogaHR0cHM6Ly9kb2NzLnNvbGlkaXR5bGFuZy5vcmcvZW4vbGF0ZXN0L2NoZWF0c2hlZXQuaHRtbGAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiU29saWRpdHlQcm90ZWN0ZWRLZXl3b3JkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRNb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRNb2RpZmllckVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRnVuY3Rpb25Nb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gLAogICAgICAgICAgICAgIGBEYXRhIGxvY2F0aW9uIGNhbiBvbmx5IGJlIHNwZWNpZmllZCBmb3IgYXJyYXksIHN0cnVjdCwgb3IgbWFwcGluZyB0eXBlcywgYnV0ICIke21vZGlmaWVyfSIgd2FzIGdpdmVuLmAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEZ1bmN0aW9uTW9kaWZpZXJFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZEFiaVR5cGVQYXJhbWV0Z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JbnZhbGlkU2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzaWduYXR1cmUsIHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgJHt0eXBlfSBzaWduYXR1cmUuYCwgewogICAgICAgICAgICBkZXRhaWxzOiBzaWduYXR1cmUKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRTaWduYXR1cmVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgVW5rbm93blNpZ25hdHVyZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgc2lnbmF0dXJlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNpZ25hdHVyZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU3RydWN0U2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3Ryd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CB7IHR5cGU6ICJib29sIiB9XSwKICAgICAgICBbImJ5dGVzIiwgeyB0eXBlOiAiYnl0ZXMiIH1dLAogICAgICAgIFsiYnl0ZXMzMiIsIHsgdHlwZTogImJ5dGVzMzIiIH1dLAogICAgICAgIFsiaW50IiwgeyB0eXBlOiAiaW50MjU2IiB9XSwKICAgICAgICBbImludDI1NiIsIHsgdHlwZTogImludDI1NiIgfV0sCiAgICAgICAgWyJzdHJpbmciLCB7IHR5cGU6ICJzdHJpbmciIH1dLAogICAgICAgIFsidWludCIsIHsgdHlwZTogInVpbnQyNTYiIH1dLAogICAgICAgIFsidWludDgiLCB7IHR5cGU6ICJ1aW50OCIgfV0sCiAgICAgICAgWyJ1aW50MTYiLCB7IHR5cGU6ICJ1aW50MTYiIH1dLAogICAgICAgIFsidWludDI0IiwgeyB0eXBlOiAidWludDI0IiB9XSwKICAgICAgICBbInVpbnQzMiIsIHsgdHlwZTogInVpbnQzMiIgfV0sCiAgICAgICAgWyJ1aW50NjQiLCB7IHR5cGU6ICJ1aW50NjQiIH1dLAogICAgICAgIFsidWludDk2IiwgeyB0eXBlOiAidWludDk2IiB9XSwKICAgICAgICBbInVpbnQxMTIiLCB7IHR5cGU6ICJ1aW50MTEyIiB9XSwKICAgICAgICBbInVpbnQxNjAiLCB7IHR5cGU6ICJ1aW50MTYwIiB9XSwKICAgICAgICBbInVpbnQxOTIiLCB7IHR5cGU6ICJ1aW50MTkyIiB9XSwKICAgICAgICBbInVpbnQyNTYiLCB7IHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAvLyBOYW1lZAogICAgICAgIFsiYWRkcmVzcyBvd25lciIsIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAib3duZXIiIH1dLAogICAgICAgIFsiYWRkcmVzcyB0byIsIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAidG8iIH1dLAogICAgICAgIFsiYm9vbCBhcHByb3ZlZCIsIHsgdHlwZTogImJvb2wiLCBuYW1lOiAiY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gICAgfQogICAgICB9CiAgICAgIHJldHVybiB7CiAgICAgICAgbmFtZTogbWF0Y2gubmFtZSwKICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgIHN0YXRlTXV0YWJpbGl0eTogbWF0Y2guc3RhdGVNdXRhYmlsaXR5ID8/ICJub25wYXlhYmxlIiwKICAgICAgICBpbnB1dHMsCiAgICAgICAgb3V0cHV0cwogICAgICB9OwogICAgfQogICAgaWYgKGlzRXZlbnRTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFdmVudFNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJldmVudCIgfSk7CiAgICAgIGNvbnN0IHBhcmFtcyA9IHNwbGl0UGFyYW1ldGVycyhtYXRjaC5wYXJhbWV0ZXJzKTsKICAgICAgY29uc3QgYWJpUGFyYW1ldGVycyA9IFtdOwogICAgICBjb25zdCBsZW5ndGggPSBwYXJhbXMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgYWJpUGFyYW1ldGVycy5wdXNoKHBhcnNlQWJpUGFyYW1ldGVyKHBhcmFtc1tpXSwgewogICAgICAgICAgbW9kaWZpZXJzOiBldmVudE1vZGlmaWVycywKICAgICAgICAgIHN0cnVjdHMsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiB7IG5hbWU6IG1hdGNoLm5hbWUsIHR5cGU6ICJldmVudCIsIGlucHV0czogYWJpUGFyYW1ldGVycyB9OwogICAgfQogICAgaWYgKGlzRXJyb3JTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFcnJvclNpZ25hdH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ICAgaWYgKGFuY2VzdG9ycy5oYXModHlwZSkpCiAgICAgICAgICAgIHRocm93IG5ldyBDaXJjdWxhclJlZmVyZW5jZUVycm9yKHsgdHlwZSB9KTsKICAgICAgICAgIGNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgICAgIC4uLmFiaVBhcmFtZXRlciwKICAgICAgICAgICAgdHlwZTogYHR1cGxlJHthcnJheSA/PyAiIn1gLAogICAgICAgICAgICBjb21wb25lbnRzOiByZXNvbHZlU3RydWN0cyhzdHJ1Y3RzW3R5cGVdID8/IFtdLCBzdHJ1Y3RzLCAvKiBAX19QVVJFX18gKi8gbmV3IFNldChbLi4uYW5jZXN0b3JzLCB0eXBlXSkpCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGlzU29saWRpdHlUeXBlKHR5cGUpKQogICAgICAgICAgICBjb21wb25lbnRzLnB1c2goYWJpUGFyYW1ldGVyKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgdGhyb3cgbmV3IFVua25vd25UeXBlRXJyb3IoeyB0eXBlIH0pOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGNvbXBvbmVudHM7CiAgfQogIHZhciB0eXBlV2l0aG91dFR1cGxlUmVnZXg7CiAgdmFyIGluaXRfc3RydWN0cyA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9ydW50aW1lL3N0cnVjdHMuanMiKCkgewogICAgICBpbml0X3JlZ2V4KCk7CiAgICAgIGluaXRfYWJpSXRlbSgpOwogICAgICBpbml0X2FiaVBhcmFtZXRlcigpOwogICAgICBpbml0X3NpZ25hdHVyZSgpOwogICAgICBpbml0X3N0cnVjdCgpOwogICAgICBpbml0X3NpZ25hdHVyZXMoKTsKICAgICAgaW5pdF91dGlscygpOwogICAgICB0eXBlV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AgY29uc3QgZGV0YWlscyA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kZXRhaWxzOwogICAgICAgICAgICBpZiAoYXJncy5jYXVzZT8ubWVzc2FnZSkKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5tZXNzYWdlOwogICAgICAgICAgICByZXR1cm4gYXJncy5kZXRhaWxzOwogICAgICAgICAgfSkoKTsKICAgICAgICAgIGNvbnN0IGRvY3NQYXRoOSA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kb2NzUGF0aCB8fCBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgICByZXR1cm4gYXJncy5kb2NzUGF0aDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBkb2NzVXJsID0gZXJyb3JDb25maWcuZ2V0RG9jc1VybD8uKHsgLi4uYXJncywgZG9jc1BhdGg6IGRvY3NQYXRoOSB9KTsKICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBbCiAgICAgICAgICAgIHNob3J0TWVzc2FnZSB8fCAiQW4gZXJyb3Igb2NjdXJyZWQuIiwKICAgICAgICAgICAgIiIsCiAgICAgICAgICAgIC4uLmFyZ3MubWV0YU1lc3NhZ2VzID8gWy4uLmFyZ3MubWV0YU1lc3NhZ2VzLCAiIl0gOiBbXSwKICAgICAgICAgICAgLi4uZG9jc1VybCA/IFtgRG9jczogJHtkb2NzVXJsfWBdIDogW10sCiAgICAgICAgICAgIC4uLmRldGFpbHMgPyBbYERldGFpbHM6ICR7ZGV0YWlsc31gXSA6IFtdLAogICAgICAgICAgICAuLi5lcnJvckNvbmZpZy52ZXJzaW9uID8gW2BWZXJzaW9uOiAke2Vycm9yQ29uZmlnLnZlcnNpb259YF0gOiBbXQogICAgICAgICAgXS5qb2luKCJcbiIpOwogICAgICAgICAgc3VwZXIobWVzc2FnZSwgYXJncy5jYXVzZSA/IHsgY2F1c2U6IGFyZ3MuY2F1c2UgfSA6IHZvaWQgMCk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRldGFpbHMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkb2NzUGF0aCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm1ldGFNZXNzYWdlcyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNob3J0TWVzc2FnZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInZlcnNpb24iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkJhc2VFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5uYW1lID0gYXJncy5uYW1lID8/IHRoaXMubmFtZTsKICAgICAgICAgIHRoaXMuc2hvcnRNZXNzYWdlID0gc2hvcnRNZXNzYWdlOwogICAgICAgICAgdGhpcy52ZXJzaW9uID0gdmVyc2lvbjI7CiAgICAgICAgfQogICAgICAgIHdhbGsoZm4pIHsKICAgICAgICAgIHJldHVybiB3YWxrKHRoaXMsIGZuKTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9lcnJvcnMvYWJpLmpzCiAgdmFyIEFiaUNvbnN0cnVjdG9yTm90Rm91bmRFcnJvciwgQWJpQ29uc3RydWN0b3JQYXJhbXNOb3RGb3VuZEVycm9yLCBBYmlEZWNvZGluZ0RhdGFTaX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3RzLiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBuYW1lOiAiQWJpQ29uc3RydWN0b3JQYXJhbXNOb3RGb3VuZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBBYmlEZWNvZGluZ0RhdGFTaXplSW52YWxpZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IGRhdGEsIHNpemU6IHNpemUzIH0pIHsKICAgICAgICAgIHN1cGVyKFsKICAgICAgICAgICAgYERhdGEgc2l6ZSBvZiAke3NpemUzfSBieXRlcyBpcyBpbnZhbGlkLmAsCiAgICAgICAgICAgICJTaXplIG11c3QgYmUgaW4gaW5jcmVtZW50cyBvZiAzMiBieXRlcyAoc2l6ZSAlIDMyID09PSAwKS4iCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbYERhdGE6ICR7ZGF0YX0gKCR7c2l6ZTN9IGJ5dGVzKWBdLAogICAgICAgICAgICBuYW1lOiAiQWJpRGVjb2RpbmdEYXRhU2l6ZUludmFsaWRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQWJpRGVjb2RpbmdEYXRhU2l6ZVRvb1NtYWxsRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgZGF0YSwgcGFyYW1zLCBzaXplOiBzaXplMyB9KSB7CiAgICAgICAgICBzdXBlcihbYERhdGEgc2l6ZSBvZiAke3NpemUzfSBieXRlcyBpcyB0b28gc21hbGwgZm9yIGdpdmVuIHBhcmFtZXRlcnMuYF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgUGFyYW1zOiAoJHtmb3JtYXRBYmlQYXJhbXMocGFyYW1zLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pfSlgLAogICAgICAgICAgICAgIGBEYXRhOiAgICR7ZGF0YX0gKCR7c2l6ZTN9IGJ5dGVzKWAKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkFiaURlY29kaW5nRGF0YVNpemVUb29TbWFsbEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJwYXJhbXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuZGF0YSA9IGRhdGE7CiAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgIHRoaXMuc2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yID0g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wgZ2l2ZW5TaXplIH0pIHsKICAgICAgICAgIHN1cGVyKGBFeHBlY3RlZCBieXRlcyR7ZXhwZWN0ZWRTaXplfSwgZ290IGJ5dGVzJHtnaXZlblNpemV9LmAsIHsKICAgICAgICAgICAgbmFtZTogIkJ5dGVzU2l6ZU1pc21hdGNoRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIERlY29kZUxvZ0RhdGFNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBkYXRhLCBwYXJhbXMsIHNpemU6IHNpemUzIH0pIHsKICAgICAgICAgIHN1cGVyKFsKICAgICAgICAgICAgYERhdGEgc2l6ZSBvZiAke3NpemUzfSBieXRlcyBpcyB0b28gc21hbGwgZm9yIG5vbi1pbmRleGVkIGV2ZW50IHBhcmFtZXRlcnMuYAogICAgICAgICAgXS5qb2luKCJcbiIpLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBQYXJhbXM6ICgke2Zvcm1hdEFiaVBhcmFtcyhwYXJhbXMsIHsgaW5jbHVkZU5hbWU6IHRydWUgfSl9KWAsCiAgICAgICAgICAgICAgYERhdGE6ICAgJHtkYXRhfSAoJHtzaXplM30gYnl0ZXMpYAogICAgICAgICAgICBdLAogICAgICAgICAgICBuYW1lOiAiRGVjb2RlTG9nRGF0YU1pc21hdGNoIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImFiaUl0ZW0iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkYXRhIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAicGFyYW1zIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAic2l6ZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaUl0ZW0gPSBhYmlJdGVtOwogICAgICAgICAgdGhpcy5kYXRhID0gZGF0YTsKICAgICAgICAgIHRoaXMucGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgdGhpcy5zaXplID0gc2l6ZTM7CiAgICAgICAgfQogICAgICB9OwogICAgICBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBwYXJhbSB9KSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICAgICAgIGBFeHBlY3RlZCBhIHRvcGljIGZvciBpbmRleGVkIGV2ZW50IHBhcmFtZXRlciR7cGFyYW0ubmFtZSA/IGAgIiR7cGFyYW0ubmFtZ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1cGVyKFsKICAgICAgICAgICAgYFR5cGUgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlY29kaW5nIHR5cGUuYCwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgdmFsaWQgQUJJIHR5cGUuIgogICAgICAgICAgXS5qb2luKCJcbiIpLCB7IGRvY3NQYXRoOiBkb2NzUGF0aDksIG5hbWU6ICJJbnZhbGlkQWJpRGVjb2RpbmdUeXBlIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRBcnJheUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih2YWx1ZSkgewogICAgICAgICAgc3VwZXIoW2BWYWx1ZSAiJHt2YWx1ZX0iIGlzIG5vdCBhIHZhbGlkIGFycmF5LmBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBcnJheUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRGVmaW5pdGlvblR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlZmluaXRpb24gdHlwZS5gLAogICAgICAgICAgICAnVmFsaWQgdHlwZXM6ICJmdW5jdGlvbiIsICJldmVudCIsICJlcnJvciInCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsgbmFtZTogIkludmFsaWREZWZpbml0aW9uVHlwZUVycm9yIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVuc3VwcG9ydGVkUGFja2VkQWJpVHlwZSA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoYFR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50bzsKICAgIGlmICh0byA9PT0gIm51bWJlciIpCiAgICAgIHJldHVybiBoZXhUb051bWJlcihoZXgsIG9wdHMpOwogICAgaWYgKHRvID09PSAiYmlnaW50IikKICAgICAgcmV0dXJuIGhleFRvQmlnSW50KGhleCwgb3B0cyk7CiAgICBpZiAodG8gPT09ICJzdHJpbmciKQogICAgICByZXR1cm4gaGV4VG9TdHJpbmcoaGV4LCBvcHRzKTsKICAgIGlmICh0byA9PT0gImJvb2xlYW4iKQogICAgICByZXR1cm4gaGV4VG9Cb29sKGhleCwgb3B0cyk7CiAgICByZXR1cm4gaGV4VG9CeXRlcyhoZXgsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBoZXhUb0JpZ0ludChoZXgsIG9wdHMgPSB7fSkgewogICAgY29uc3QgeyBzaWduZWQgfSA9IG9wdHM7CiAgICBpZiAob3B0cy5zaXplKQogICAgICBhc3NlcnRTaXplKGhleCwgeyBzaXplOiBvcHRzLnNpemUgfSk7CiAgICBjb25zdCB2YWx1ZSA9IEJpZ0ludChoZXgpOwogICAgaWYgKCFzaWduZWQpCiAgICAgIHJldHVybiB2YWx1ZTsKICAgIGNvbnN0IHNpemUzID0gKGhleC5sZW5ndGggLSAyKSAvIDI7CiAgICBjb25zdCBtYXggPSAoMW4gPDwgQmlnSW50KHNpemUzKSAqIDhuIC0gMW4pIC0gMW47CiAgICBpZiAodmFsdWUgPD0gbWF4KQogICAgICByZXR1cm4gdmFsdWU7CiAgICByZXR1cm4gdmFsdWUgLSBCaWdJbnQoYDB4JHsiZiIucGFkU3RhcnQoc2l6ZTMgKiAyLCAiZiIpfWApIC0gMW47CiAgfQogIGZ1bmN0aW9uIGhleFRvQm9vbChoZXhfLCBvcHRzID0ge30pIHsKICAgIGxldCBoZXggPSBoZXhfOwogICAgaWYgKG9wdHMuc2l6ZSkgewogICAgICBhc3NlcnRTaXplKGhleCwgeyBzaXplOiBvcHRzLnNpemUgfSk7CiAgICAgIGhleCA9IHRyaW0oaGV4KTsK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dGlsczIoKTsKICAgICAgU0hBM19QSSA9IFtdOwogICAgICBTSEEzX1JPVEwgPSBbXTsKICAgICAgX1NIQTNfSU9UQSA9IFtdOwogICAgICBfMG4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDApOwogICAgICBfMW4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDEpOwogICAgICBfMm4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDIpOwogICAgICBfN24gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDcpOwogICAgICBfMjU2biA9IC8qIEBfX1BVUkVfXyAqLyBCaWdJbnQoMjU2KTsKICAgICAgXzB4NzFuID0gLyogQF9fUFVSRV9fICovIEJpZ0ludCgxMTMpOwogICAgICBmb3IgKGxldCByb3VuZCA9IDAsIFIgPSBfMW4sIHggPSAxLCB5ID0gMDsgcm91bmQgPCAyNDsgcm91bmQrKykgewogICAgICAgIFt4LCB5XSA9IFt5LCAoMiAqIHggKyAzICogeSkgJSA1XTsKICAgICAgICBTSEEzX1BJLnB1c2goMiAqICg1ICogeSArIHgpKTsKICAgICAgICBTSEEzX1JPVEwucHVzaCgocm91bmQgKyAxKSAqIChyb3VuZCArIDIpIC8gMiAlIDY0KTsKICAgICAgICBsZXQgdCA9IF8wbjsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDc7IGorKykgewogICAgICAgICAgUiA9IChSIDw8IF8xbiBeIChSID4+IF83bikgKiBfMHg3MW4pICUgXzI1Nm47CiAgICAgICAgICBpZiAoUiAmIF8ybikKICAgICAgICAgICAgdCBePSBfMW4gPDwgKF8xbiA8PCAvKiBAX19QVVJFX18gKi8gQmlnSW50KGopKSAtIF8xbjsKICAgICAgICB9CiAgICAgICAgX1NIQTNfSU9UQS5wdXNoKHQpOwogICAgICB9CiAgICAgIFtTSEEzX0lPVEFfSCwgU0hBM19JT1RBX0xdID0gLyogQF9fUFVSRV9fICovIHNwbGl0KF9TSEEzX0lPVEEsIHRydWUpOwogICAgICByb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FycmF5KDIwMCk7CiAgICAgICAgICB0aGlzLnN0YXRlMzIgPSB1MzIodGhpcy5zdGF0ZSk7CiAgICAgICAgfQogICAgICAgIGtlY2NhaygpIHsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAga2VjY2FrUCh0aGlzLnN0YXRlMzIsIHRoaXMucm91bmRzKTsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAgdGhpcy5wb3NPdXQgPSAwOwogICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiwgc3RhdGUgfSA9IHRoaXM7CiAgICAgICAgICBkYXRhID0gdG9CeXRlczIoZGF0YSk7CiAgICAgICAgICBjb25zdCBsZW4gPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDA7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGNvbnN0IHRha2UgPSBNYXRoLm1pbihibG9ja0xlbiAtIHRoaXMucG9zLCBsZW4gLSBwb3MpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRha2U7IGkrKykKICAgICAgICAgICAgICBzdGF0ZVt0aGlzLnBvcysrXSBePSBkYXRhW3BvcysrXTsKICAgICAgICAgICAgaWYgKHRoaXMucG9zID09PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGZpbmlzaCgpIHsKICAgICAgICAgIGlmICh0aGlzLmZpbmlzaGVkKQogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB0aGlzLmZpbmlzaGVkID0gdHJ1ZTsKICAgICAgICAgIGNvbnN0IHsgc3RhdGUsIHN1ZmZpeCwgcG9zLCBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIHN0YXRlW3Bvc10gXj0gc3VmZml4OwogICAgICAgICAgaWYgKChzdWZmaXggJiAxMjgpICE9PSAwICYmIHBvcyA9PT0gYmxvY2tMZW4gLSAxKQogICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgc3RhdGVbYmxvY2tMZW4gLSAxXSBePSAxMjg7CiAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgIH0KICAgICAgICB3cml0ZUludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcywgZmFsc2UpOwogICAgICAgICAgYnl0ZXMob3V0KTsKICAgICAgICAgIHRoaXMuZmluaXNoKCk7CiAgICAgICAgICBjb25zdCBidWZmZXJPdXQgPSB0aGlzLnN0YXRlOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDAsIGxlbiA9IG91dC5sZW5ndGg7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnBvc091dCA+PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvc091dCwgbGVuIC0gcG9zKTsKICAgICAgICAgICAgb3V0LnNldChidWZmZXJPdXQuc3ViYXJyYXkodGhpcy5wb3NPdXQsIHRoaXMucG9zT3V0ICsgdGFrZSksIHBvcyk7CiAgICAgICAgICAgIHRoaXMucG9zT3V0ICs9IHRha2U7CiAgICAgICAgICAgIHBvcyArPSB0YWtlOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG91dDsKICAgICAgICB9CiAgICAgICAgeG9mSW50byhvdXQpIHsKICAgICAgICAgIGlmICghdGhpcy5lbmFibGVYT0YpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiWE9GIGlzIG5vdCBwb3NzaWJsZSBmb3IgdGhpcyBpbnN0YW5jZSIpOwogICAgICAgICAgcmV0dXJuIHRoaXMud3JpdGVJbnRvKG91dCk7CiAgICAgICAgfQogICAgICAgIHhvZihieXRlczIpIHsKICAgICAgICAgIG51bWJlcihieXRlczIpOwogICAgICAgICAgcmV0dXJuIHRoaXMueG9mSW50byhuZXcgVWludDhBcnJheShieXRlczIpKTsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIG91dHB1dChvdXQsIHRoaXMpOwogICAgICAgICAgaWYgKHRoaXMuZmluaXNoZWQpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZGlnZXN0KCkgd2FzIGFscmVhZHkgY2FsbGVkIik7CiAgICAgICAgICB0aGlzLndyaXRlSW50byhvdXQpOwogICAgICAgICAgdGhpcy5kZXN0cm95KCk7CiAgICAgICAgICByZXR1cm4gb3V0OwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5kaWdlc3RJbnRvKG5ldyBVaW50OEFycmF5KHRoaXMub3V0cHV0TGVuKSk7CiAgICAgICAgfQogICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICB0aGlzLnN0YXRlLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIGNvbnN0IHsgYmxvY2tMZW4sIHN1ZmZpeCwgb3V0cHV0TGVuLCByb3VuZHMsIGVuYWJsZVhPRiB9ID0gdGhpczsKICAgICAgICAgIHRvIHx8ICh0byA9IG5ldyBfS2VjY2FrKGJsb2NrTGVuLCBzdWZmaXgsIG91dHB1dExlbiwgZW5hYmxlWE9GLCByb3VuZHMpKTsKICAgICAgICAgIHRvLnN0YXRlMzIuc2V0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ZGVzKGNoYXIpKQogICAgICAgIGFjdGl2ZSA9IHRydWU7CiAgICAgIGlmIChjaGFyID09PSAiKCIpCiAgICAgICAgbGV2ZWwrKzsKICAgICAgaWYgKGNoYXIgPT09ICIpIikKICAgICAgICBsZXZlbC0tOwogICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICBjb250aW51ZTsKICAgICAgaWYgKGxldmVsID09PSAwKSB7CiAgICAgICAgaWYgKGNoYXIgPT09ICIgIiAmJiBbImV2ZW50IiwgImZ1bmN0aW9uIiwgIiJdLmluY2x1ZGVzKHJlc3VsdCkpCiAgICAgICAgICByZXN1bHQgPSAiIjsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICAgICAgaWYgKGNoYXIgPT09ICIpIikgewogICAgICAgICAgICB2YWxpZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gIiAiKSB7CiAgICAgICAgaWYgKHNpZ25hdHVyZVtpIC0gMV0gIT09ICIsIiAmJiBjdXJyZW50ICE9PSAiLCIgJiYgY3VycmVudCAhPT0gIiwoIikgewogICAgICAgICAgY3VycmVudCA9ICIiOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICBjdXJyZW50ICs9IGNoYXI7CiAgICB9CiAgICBpZiAoIXZhbGlkKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigiVW5hYmxlIHRvIG5vcm1hbGl6ZSBzaWduYXR1cmUuIik7CiAgICByZXR1cm4gcmVzdWx0OwogIH0KICB2YXIgaW5pdF9ub3JtYWxpemVTaWduYXR1cmUgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2Rl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GBBZGRyZXNzICIke2FkZHJlc3N9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIi0gQWRkcmVzcyBtdXN0IGJlIGEgaGV4IHZhbHVlIG9mIDIwIGJ5dGVzICg0MCBoZXggY2hhcmFjdGVycykuIiwKICAgICAgICAgICAgICAiLSBBZGRyZXNzIG11c3QgbWF0Y2ggaXRzIGNoZWNrc3VtIGNvdW50ZXJwYXJ0LiIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBZGRyZXNzRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9scnUuanMKICB2YXIgTHJ1TWFwOwogIHZhciBpbml0X2xydSA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvbHJ1LmpzIigpIHsKICAgICAgTHJ1TWFwID0gY2xhc3MgZXh0ZW5kcyBNYXAgewogICAgICAgIGNvbnN0cnVjdG9yKHNpemUzKSB7CiAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtYXhTaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMubWF4U2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgICBnZXQoa2V5KSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHN1cGVyLmdldChrZXkpOwogICAgICAgICAgaWYgKHN1cGVyLmhhcyhrZXkpICYmIHZhbHVlICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgdGhpcy5kZWxldGUoa2V5KTsKICAgICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0KICAgICAgICBzZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgaWYgKHRoaXMubWF4U2l6ZSAmJiB0aGlzLnNpemUgPiB0aGlzLm1heFNpemUpIHsKICAgICAgICAgICAgY29uc3QgZmlyc3RLZXkgPSB0aGlzLmtleXMoKS5uZXh0KCkudmFsdWU7CiAgICAgICAgICAgIGlmIChmaXJzdEtleSkKICAgICAgICAgICAgICB0aGlzLmRlbGV0ZShmaXJzdEtleSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9hZGRyZXNzL2dldEFkZHJlc3MuanMKICBmdW5jdGlvbiBjaGVja3N1bUFkZHJlc3MoYWRkcmVzc18sIGNoYWluSWQpIHsKICAgIGlmIChjaGVja3N1bUFkZHJlc3NDYWNoZS5oYXMoYCR7YWRkcmVzc199LiR7Y2hhaW5JZH1gKSkKICAgICAgcmV0dXJuIGNoZWNrc3VtQWRkcmVzc0NhY2hlLmdldChgJHthZGRyZXNzX30uJHtjaGFpbklkfWApOwogICAgY29uc3QgaGV4QWRkcmVzcyA9IGNoYWluSWQgPyBgJHtjaGFpbklkfSR7YWRkcmVzc18udG9Mb3dlckNhc2UoKX1gIDogYWRkcmVzc18uc3Vic3RyaW5nKDIpLnRvTG93ZXJDYXNlKCk7C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YCBvbiBhbiBlbXB0eSBhcnJheSIsCiAgICAgICAgNTA6ICJBcnJheSBpbmRleCBpcyBvdXQgb2YgYm91bmRzLiIsCiAgICAgICAgNjU6ICJBbGxvY2F0ZWQgdG9vIG11Y2ggbWVtb3J5IG9yIGNyZWF0ZWQgYW4gYXJyYXkgd2hpY2ggaXMgdG9vIGxhcmdlLiIsCiAgICAgICAgODE6ICJBdHRlbXB0ZWQgdG8gY2FsbCBhIHplcm8taW5pdGlhbGl6ZWQgdmFyaWFibGUgb2YgaW50ZXJuYWwgZnVuY3Rpb24gdHlwZS4iCiAgICAgIH07CiAgICAgIHNvbGlkaXR5RXJyb3IgPSB7CiAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICB7CiAgICAgICAgICAgIG5hbWU6ICJtZXNzYWdlIiwKICAgICAgICAgICAgdHlwZTogInN0cmluZyIKICAgICAgICAgIH0KICAgICAgICBdLAogICAgICAgIG5hbWU6ICJFcnJvciIsCiAgICAgICAgdHlwZTogImVycm9yIgogICAgICB9OwogICAgICBzb2xpZGl0eVBhbmljID0gewogICAgICAgIGlucHV0czogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAicmVhc29uIiwKICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBuYW1lOiAiUGFuaWMiLAogICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2Vycm9ycy9jdXJzb3IuanMKICB2YXIgTmVnYXRpdmVPZmZzZXRFcnJvciwgUG9zaXRpb25PdXRPZkJvdW5kc0Vycm9yLCBSZWN1cnNpdmVSZWFkTGltaXRFeGNlZWRlZEVycm9yOwogIHZhciBpbml0X2N1cnNvciA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllb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AgICAgZ2V0UmVhZENvdW50KHBvc2l0aW9uKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5wb3NpdGlvblJlYWRDb3VudC5nZXQocG9zaXRpb24gfHwgdGhpcy5wb3NpdGlvbikgfHwgMDsKICAgICAgICB9LAogICAgICAgIGluY3JlbWVudFBvc2l0aW9uKG9mZnNldCkgewogICAgICAgICAgaWYgKG9mZnNldCA8IDApCiAgICAgICAgICAgIHRocm93IG5ldyBOZWdhdGl2ZU9mZnNldEVycm9yKHsgb2Zmc2V0IH0pOwogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uICsgb2Zmc2V0OwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0Qnl0ZShwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzW3Bvc2l0aW9uXTsKICAgICAgICB9LAogICAgICAgIGluc3BlY3RCeXRlcyhsZW5ndGgsIHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyBsZW5ndGggLSAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLnN1YmFycmF5KHBvc2l0aW9uLCBwb3NpdGlvbiArIGxlbmd0aCk7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDgocG9zaXRpb25fKSB7CiAgICAgICAgICBjb25zdCBwb3NpdGlvbiA9IHBvc2l0aW9uXyA/PyB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICByZXR1cm4gdGhpcy5ieXRlc1twb3NpdGlvbl07CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDE2KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmRhdGFWaWV3LmdldFVpbnQxNihwb3NpdGlvbik7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDI0KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAyKTsKICAgICAgICAgIHJldHVybiAodGhpcy5kYXRhVmlldy5nZXRVaW50MTYocG9zaXRpb24pIDw8IDgpICsgdGhpcy5kYXRhVmlldy5nZXRVaW50OChwb3NpdGlvbiArIDIpOwogICAgICAgIH0sCiAgICAgICAgaW5zcGVjdFVpbnQzMihwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uICsgMyk7CiAgICAgICAgICByZXR1cm4gdGhpcy5kYXRhVmlldy5nZXRVaW50MzIocG9zaXRpb24pOwogICAgICAgIH0sCiAgICAgICAgcHVzaEJ5dGUoYnl0ZSkgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9uKTsKICAgICAgICAgIHRoaXMuYnl0ZXNbdGhpcy5wb3N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gcHVzaFVpbnQzMih2YWx1ZSkgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9uICsgMyk7CiAgICAgICAgICB0aGlzLmRhdGFWaWV3LnNldFVpbnQzMih0aGlzLnBvc2l0aW9uLCB2YWx1ZSk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDQ7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZSgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RCeXRlKCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uKys7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZXMobGVuZ3RoLCBzaXplMykgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdEJ5dGVzKGxlbmd0aCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IHNpemUzID8/IGxlbmd0aDsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50OCgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50OCgpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAxOwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgcmVhZFVpbnQxNigpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50MTYoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb24gKz0gMjsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50MjQoKSB7CiAgICAgICAgICB0aGlzLmFzc2VydFJlYWRMaW1pdCgpOwogICAgICAgICAgdGhpcy5fdG91Y2goKTsKICAgICAgICAgIGNvbnN0IHZhbHVlID0gdGhpcy5pbnNwZWN0VWludDI0KCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDM7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkVWludDMyKCkgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdFVpbnQzMigpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSA0OwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgZ2V0IHJlbWFpbmluZygpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmxlbmd0aCAtIHRoaXMucG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBzZXRQb3NpdGlvbihwb3NpdGlvbikgewogICAgICAgICAgY29uc3Qgb2xkUG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgICByZXR1cm4gKCkgPT4gdGhpcy5wb3NpdGlvbiA9IG9sZFBvc2l0aW9uOwogICAgICAgIH0sCiAgICAgICAgX3RvdWNoKCkgewogICAgICAgICAgaWYgKHRoaXMucmVjdXJzaXZlUmVhZExpbWl0ID09PSBOd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ogIkFjY291bnRTdGF0ZUNvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoInN0YXRlIGFuZCBzdGF0ZURpZmYgYXJlIHNldCBvbiB0aGUgc2FtZSBhY2NvdW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIlN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9lcnJvcnMvdHJhbnNhY3Rpb24uanMKICBmdW5jdGlvbiBwcmV0dHlQcmludChhcmdzKSB7CiAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoYXJncykubWFwKChba2V5LCB2YWx1ZV0pID0+IHsKICAgICAgaWYgKHZhbHVlID09PSB2b2lkIDAgfHwgdmFsdWUgPT09IGZhbHNlKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gW2tleSwgdmFsdWVdOwogICAgfSkuZmlsdGVyKEJvb2xlYW4pOwogICAgY29uc3QgbWF4TGVuZ3RoID0gZW50cmllcy5yZWR1Y2UoKGFjYywgW2tleV0pID0+IE1hdGgubWF4KGFjYywga2V5Lmxlbmd0aCksIDApOwogICAgcmV0dXJuIGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IGAgICR7YCR7a2V5fTpgLnBhZEVuZChtYXhMZW5ndGggKyAxKX0gICR7dmFsdWV9YCkuam9pbigiXG4iKTsKICB9CiAgdmFyIEZlZUNvbmZsaWN0RXJyb3IsIEludmFsaWRMZWdhY3lWRXJyb3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nJvciIgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkTGVnYWN5VkVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHYgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgXGB2XGAgdmFsdWUgIiR7dn0iLiBFeHBlY3RlZCAyNyBvciAyOC5gLCB7CiAgICAgICAgICAgIG5hbWU6ICJJbnZhbGlkTGVnYWN5VkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXphYmxlVHJhbnNhY3Rpb25FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0cmFuc2FjdGlvbiB9KSB7CiAgICAgICAgICBzdXBlcigiQ2Fubm90IGluZmVyIGEgdHJhbnNhY3Rpb24gdHlwZSBmcm9tIHByb3ZpZGVkIHRyYW5zYWN0aW9uLiIsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIlByb3ZpZGVkIFRyYW5zYWN0aW9uOiIsCiAgICAgICAgICAgICAgInsiLAogICAgICAgICAgICAgIHByZXR0eVByaW50KHRyYW5zYWN0aW9uKSwKICAgICAgICAgICAgICAifSIsCiAgICAgICAgICAgICAgIiIsCiAgICAgICAgICAgICAgIlRvIGluZmVyIHRoZSB0eXBlLCBlaXRoZXIgcHJvdmlkZToiLAogICAgICAgICAgICAgICItIGEgYHR5cGVgIHRvIHRoZSBUcmFuc2FjdGlvbiwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC0xNTU5IFRyYW5zYWN0aW9uIHdpdGggYG1heEZlZVBlckdhc2AsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtMjkzMCBUcmFuc2FjdGlvbiB3aXRoIGBnYXNQcmljZWAgJiBgYWNjZXNzTGlzdGAsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtNDg0NCBUcmFuc2FjdGlvbiB3aXRoIGBibG9ic2AsIGBibG9iVmVyc2lvbmVkSGFzaGVzYCwgYHNpZGVjYXJzYCwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC03NzAyIFRyYW5zYWN0aW9uIHdpdGggYGF1dGhvcml6YXRpb25MaXN0YCwgb3IiLAogICAgICAgICAgICAgICItIGEgTGVnYWN5IFRyYW5zYWN0aW9uIHdpdGggYGdhc1ByaWNlYCIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemFibGVUcmFuc2FjdGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uVHlwZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHNlcmlhbGl6ZWRUeXBlIH0pIHsKICAgICAgICAgIHN1cGVyKGBTZXJpYWxpemVkIHRyYW5zYWN0aW9uIHR5cGUgIiR7c2VyaWFsaXplZFR5cGV9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25UeXBlIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlcmlhbGl6ZWRUeXBlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuc2VyaWFsaXplZFR5cGUgPSBzZXJpYWxpemVkVHlwZTsKICAgICAgICB9CiAgICAgIH07CiAgICAg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ogICAgICAgICAgICAgIHByZXR0eUFyZ3MKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJUcmFuc2FjdGlvbkV4ZWN1dGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuY2F1c2UgPSBjYXVzZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFRyYW5zYWN0aW9uTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBibG9ja0hhc2gsIGJsb2NrTnVtYmVyLCBibG9ja1RhZywgaGFzaDogaGFzaDMsIGluZGV4OiBpbmRleDIgfSkgewogICAgICAgICAgbGV0IGlkZW50aWZpZXIgPSAiVHJhbnNhY3Rpb24iOwogICAgICAgICAgaWYgKGJsb2NrVGFnICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIHRpbWUgIiR7YmxvY2tUYWd9IiBhdCBpbmRleCAiJHtpbmRleDJ9ImA7CiAgICAgICAgICBpZiAoYmxvY2tIYXNoICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIGhhc2ggIiR7YmxvY2tIYXNofSIgYXQgaW5kZXggIiR7aW5kZXgyfSJgOwogICAgICAgICAgaWYgKGJsb2NrTnVtYmVyICYmIGluZGV4MiAhPT0gdm9pZCAwKQog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ogdHlwZW9mIGdhc1ByaWNlICE9PSAidW5kZWZpbmVkIiAmJiBgJHtmb3JtYXRHd2VpKGdhc1ByaWNlKX0gZ3dlaWAsCiAgICAgICAgICAgIG1heEZlZVBlckdhczogdHlwZW9mIG1heEZlZVBlckdhcyAhPT0gInVuZGVmaW5lZCIgJiYgYCR7Zm9ybWF0R3dlaShtYXhGZWVQZXJHYXMpfSBnd2VpYCwKICAgICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXM6IHR5cGVvZiBtYXhQcmlvcml0eUZlZVBlckdhcyAhPT0gInVuZGVmaW5lZCIgJiYgYCR7Zm9ybWF0R3dlaShtYXhQcmlvcml0eUZlZVBlckdhcyl9IGd3ZWlgLAogICAgICAgICAgICBub25jZQogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoc3RhdGVPdmVycmlkZSkgewogICAgICAgICAgICBwcmV0dHlBcmdzICs9IGAKJHtwcmV0dHlTdGF0ZU92ZXJyaWRlKHN0YXRlT3ZlcnJpZGUpfWA7CiAgICAgICAgICB9CiAgICAgICAgICBzdXBlcihjYXVzZS5zaG9ydE1lc3NhZ2UsIHsKICAgICAgICAgICAgY2F1c2UsCiAgICAgICAgICAgIGRvY3NQYXRoOiBkb2NzUGF0aDksCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIC4uLmNhdXNlLm1ldGFNZXNzYWdlcyA/IFsuLi5jYXVzZS5tZXRhTWVzc2FnZXMsICIgIl0gOiBbXSwKICAgICAgICAgICAgICAiUmF3IENhbGwgQXJndW1lbnRzOiIsCiAgICAgICAgICAgICAgcHJldHR5QXJncwogICAgICAgICAgICBdLmZpbHRlcihCb29sZWFuKSwKICAgICAgICAgICAgbmFtZTogIkNhbGxFeGVjdXRpb25FcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjYXVzZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uRXhlY3V0aW9uRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlLCB7IGFiaTogYWJpMiwgYXJncywgY29udHJhY3RBZGRyZXNzLCBkb2NzUGF0aDogZG9jc1BhdGg5LCBmdW5jdGlvbk5hbWUsIHNlbmRlciB9KSB7CiAgICAgICAgICBjb25zdCBhYmlJdGVtID0gZ2V0QWJpSXRlbSh7IGFiaTogYWJpMiwgYXJncywgbmFtZTogZnVuY3Rpb25OYW1lIH0pOwogICAgICAgICAgY29uc3QgZm9ybWF0dGVkQXJncyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtV2l0aEFyZ3MoewogICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICBhcmdzLAogICAgICAgICAgICBpbmNsdWRlRnVuY3Rpb25OYW1lOiBmYWxzZSwKICAgICAgICAgICAgaW5jbHVkZU5hbWU6IGZhbHNlCiAgICAgICAgICB9KSA6IHZvaWQgMDsKICAgICAgICAgIGNvbnN0IGZ1bmN0aW9uV2l0aFBhcmFtcyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtMihhYmlJdGVtLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pIDogdm9pZCAwOwogICAgICAgICAgY29uc3QgcHJldHR5QXJncyA9IHByZXR0eVByaW50KHsKICAgICAgICAgICAgYWRkcmVzczogY29udHJhY3RBZGRyZXNzICYmIGdldENvbnRyYWN0QWRkcmVzcyhjb250cmFjdEFkZHJlc3MpLAogICAgICAgICAgICBmdW5jdG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amVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiYXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29udHJhY3RBZGRyZXNzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZm9ybWF0dGVkQXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImZ1bmN0aW9uTmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlbmRlciIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaSA9IGFiaTI7CiAgICAgICAgICB0aGlzLmFyZ3MgPSBhcmdzOwogICAgICAgICAgdGhpcy5jYXVzZSA9IGNhdXNlOwogICAgICAgICAgdGhpcy5jb250cmFjdEFkZHJlc3MgPSBjb250cmFjdEFkZHJlc3M7CiAgICAgICAgICB0aGlzLmZ1bmN0aW9uTmFtZSA9IGZ1bmN0aW9uTmFtZTsKICAgICAgICAgIHRoaXMuc2VuZGVyID0gc2VuZGVyOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYWJpOiBhYmkyLCBkYXRhLCBmdW5jdGlvbk5hbWUsIG1lc3NhZ2UgfSkgewogICAgICAgICAgbGV0IGNhdXNlOwogICAgICAgICAgbGV0IGRlY29kZWREYXRhID0gdm9pZCAwOwogICAgICAgICAgbGV0IG1ldGFNZXNzYWdlczsKICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICBpZiAoZGF0YSAmJiBkYXRhICE9PSAiMHgiKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZGVjb2RlZERhdGEgPSBkZWNvZGVFcnJvclJlc3VsdCh7IGFiaTogYWJpMiwgZGF0YSB9KTsKICAgICAgICAgICAgICBjb25zdCB7IGFiaUl0ZW0sIGVycm9yTmFtZSwgYXJnczogZXJyb3JBcmdzIH0gPSBkZWNvZGVkRGF0YTsKICAgICAgICAgICAgICBpZiAoZXJyb3JOYW1lID09PSAiRXJyb3IiKSB7CiAgICAgICAgICAgICAgICByZWFzb24gPSBlcnJvckFyZ3NbMF07CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnJvck5hbWUgPT09ICJQYW5pYyIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IFtmaXJzdEFyZ10gPSBlcnJvckFyZ3M7CiAgICAgICAgICAgICAgICByZWFzb24gPSBwYW5pY1JlYXNvbnNbZmlyc3RBcmddOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb25zdCBlcnJvcldpdGhQYXJhbXMgPSBhYmlJdGVtID8gZm9ybWF0QWJpSXRlbTIoYWJpSXRlbSwgeyBpbmNsdWRlTmFtZTogdHJ1ZSB9KSA6IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZEFyZ3MgPSBhYmlJdGVtICYmIGVycm9yQXJncyA/IGZvcm1hdEFiaUl0ZW1XaXRoQXJncyh7CiAgICAgICAgICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICAgICAgICAgIGFyZ3M6IGVycm9yQXJncywKICAgICAgICAgICAgICAgICAgaW5jbHVkZUZ1bmN0aW9uTmFtZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVOYW1lOiBmYWxzZQogICAgICAgICAgICAgICAgfSkgOiB2b2lkIDA7CiAgICAgICAgICAgICAgICBtZXRhTWVzc2FnZXMgPSBbCiAgICAgICAgICAgICAgICAgIGVycm9yV2l0aFBhcmFtcyA/IGBFcnJvcjogJHtlcnJvcldpdGhQYXJhbXN9YCA6ICIiLAogICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRBcmdzICYmIGZvcm1hdHRlZEFyZ3MgIT09ICIoKSIgPyBgICAgICAgICR7Wy4uLkFycmF5KGVycm9yTmFtZT8ubGVuZ3RoID8/IDApLmtleXMoKV0ubWFwKCgpID0+ICIgIikuam9pbigiIil9JHtmb3JtYXR0ZWRBcmdzfWAgOiAiIgogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIGNhdXNlID0gZXJyOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKG1lc3NhZ2UpCiAgICAgICAgICAgIHJlYXNvbiA9IG1lc3NhZ2U7CiAgICAgICAgICBsZXQgc2lnbmF0dXJlOwogICAgICAgICAgaWYgKGNhdXNlIGluc3RhbmNlb2YgQWJpRXJyb3JTaWduYXR1cmVOb3RGb3VuZEVycm9yKSB7CiAgICAgICAgICAgIHNpZ25hdHVyZSA9IGNhdXNlLnNpZ25hdHVyZTsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzID0gWwogICAgICAgICAgICAgIGBVbmFibGUgdG8gZGVjb2RlIHNpZ25hdHVyZSAiJHtzaWduYXR1cmV9IiBhcyBpdCB3YXMgbm90IGZvdW5kIG9uIHRoZSBwcm92aWRlZCBBQkkuYCwKICAgICAgICAgICAgICAiTWFrZSBzdXJlIHlvdSBhcmUgdXNpbmcgdGhlIGNvcnJlY3QgQUJJIGFuZCB0aGF0IHRoZSBlcnJvciBleGlzdHMgb24gaXQuIiwKICAgICAgICAgICAgICBgWW91IGNhbiBsb29rIHVwIHRoZSBkZWNvZGVkIHNpZ25hdHVyZSBoZXJlOiBodHRwczovL29wZW5jaGFpbi54eXovc2lnbmF0dXJlcz9xdWVyeT0ke3NpZ25hdHVyZX0uYAogICAgICAgICAgICBdOwogICAgICAgICAgfQogICAgICAgICAgc3VwZXIocmVhc29uICYmIHJlYXNvbiAhPT0gImV4ZWN1dGlvbiByZXZlcnRlZCIgfHwgc2lnbmF0dXJlID8gWwogICAgICAgICAgICBgVGhlIGNvbnRyYWN0IGZ1bmN0aW9uICIke2Z1bmN0aW9uTmFtZX0iIHJldmVydGVkIHdpdGggdGhlIGZvbGxvd2luZyAke3NpZ25hdHVyZSA/ICJzaWduYXR1cmUiIDogInJlYXNvbiJ9OmAsCiAgICAgICAgICAgIHJlYXNvbiB8fCBzaWduYXR1cmUKICAgICAgICAgIF0uam9pbigiXG4iKSA6IGBUaGUgY29udHJhY3QgZnVuY3Rpb24gIiR7ZnVuY3Rpb25OYW1lfSIgcmV2ZXJ0ZWQuYCwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzLAogICAgICAgICAgICBuYW1lOiAiQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZGF0YSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInJlYXNvbiIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hdHVyZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmRhdGEgPSBkZWNvZGVkRGF0YTsKICAgICAgICAgIHR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ZWQke2ZhY3RvcnkgPyBgIGZvciBmYWN0b3J5ICIke2ZhY3Rvcnl9Ii5gIDogIiJ9YCwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAiUGxlYXNlIGVuc3VyZToiLAogICAgICAgICAgICAgICItIFRoZSBgZmFjdG9yeWAgaXMgYSB2YWxpZCBjb250cmFjdCBkZXBsb3ltZW50IGZhY3RvcnkgKGllLiBDcmVhdGUyIEZhY3RvcnksIEVSQy00MzM3IEZhY3RvcnksIGV0YykuIiwKICAgICAgICAgICAgICAiLSBUaGUgYGZhY3RvcnlEYXRhYCBpcyBhIHZhbGlkIGVuY29kZWQgZnVuY3Rpb24gY2FsbCBmb3IgY29udHJhY3QgZGVwbG95bWVudCBmdW5jdGlvbiBvbiB0aGUgZmFjdG9yeS4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb3VudGVyZmFjdHVhbERlcGxveW1lbnRGYWlsZWRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgUmF3Q29udHJhY3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBkYXRhLCBtZXNzYWdlIH0pIHsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UgfHwgIiIsIHsgbmFtZTogIlJhd0NvbnRyYWN0RXJyb3IiIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjb2RlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogMwogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6I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AgICAgICAgICAgICAgYm9keSAmJiBgUmVxdWVzdCBib2R5OiAke3N0cmluZ2lmeShib2R5KX1gCiAgICAgICAgICAgIF0uZmlsdGVyKEJvb2xlYW4pLAogICAgICAgICAgICBuYW1lOiAiSHR0cFJlcXVlc3RFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJib2R5IiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiaGVhZGVycyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInN0YXR1cyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInVybCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmJvZHkgPSBib2R5OwogICAgICAgICAgdGhpcy5oZWFkZXJzID0gaGVhZGVyczsKICAgICAgICAgIHRoaXMuc3RhdHVzID0gc3RhdHVzOwogICAgICAgICAgdGhpcy51cmwgPSB1cmw7CiAgICAgICAgfQogICAgICB9OwogICAgICBXZWJTb2NrZXRSZXF1ZXN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYm9keSwgY2F1c2UsIGRldGFpbHMsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiV2ViU29ja2V0IHJlcXVlc3QgZmFpbGVkLiIsIHsKICAgICAgICAgICAgY2F1c2UsCiAgICAgICAgICAgIGRldGFpbHMsCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBVUkw6ICR7Z2V0VXJsKHVybCl9YCwKICAgICAgICAgICAgICBib2R5ICYmIGBSZXF1ZXN0IGJvZHk6ICR7c3RyaW5naWZ5KGJvZHkpfWAKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJXZWJTb2NrZXRSZXF1ZXN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFJwY1JlcXVlc3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBib2R5LCBlcnJvciwgdXJsIH0pIHsKICAgICAgICAgIHN1cGVyKCJSUEMgUmVxdWVzdCBmYWlsZWQuIiwgewogICAgICAgICAgICBjYXVzZTogZXJyb3IsCiAgICAgICAgICAgIGRldGFpbHM6IGVycm9yLm1lc3NhZ2UsCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogW2BVUkw6ICR7Z2V0VXJsKHVybCl9YCwgYFJlcXVlc3QgYm9keTogJHtzdHJpbmdpZnkoYm9keSl9YF0sCiAgICAgICAgICAgIG5hbWU6ICJScGNSZXF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FibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMQogICAgICB9KTsKICAgICAgSW52YWxpZFBhcmFtc1JwY0Vycm9yID0gY2xhc3MgX0ludmFsaWRQYXJhbXNScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludmFsaWRQYXJhbXNScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiBbCiAgICAgICAgICAgICAgIkludmFsaWQgcGFyYW1ldGVycyB3ZXJlIHByb3ZpZGVkIHRvIHRoZSBSUEMgbWV0aG9kLiIsCiAgICAgICAgICAgICAgIkRvdWJsZSBjaGVjayB5b3UgaGF2ZSBwcm92aWRlZCB0aGUgY29ycmVjdCBwYXJhbWV0ZXJzLiIKICAgICAgICAgICAgXS5qb2luKCJcbiIpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnZhbGlkUGFyYW1zUnBjRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiAtMzI2MDIKICAgICAgfSk7CiAgICAgIEludGVybmFsUnBjRXJyb3IgPSBjbGFzcyBfSW50ZXJuYWxScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludGVybmFsUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkludGVybmFsUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBpbnRlcm5hbCBlcnJvciB3YXMgcmVjZWl2ZWQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoSW50ZXJuYWxScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMwogICAgICB9KTsKICAgICAgSW52YWxpZElucHV0UnBjRXJyb3IgPSBjbGFzcyBfSW52YWxpZElucHV0UnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9JbnZhbGlkSW5wdXRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZElucHV0UnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IFsKICAgICAgICAgICAgICAiTWlzc2luZyBvciBpbnZhbGlkIHBhcmFtZXRlcnMuIiwKICAgICAgICAgICAgICAiRG91YmxlIGNoZWNrIHlvdSBoYXZlIHByb3ZpZGVkIHRoZSBjb3JyZWN0IHBhcmFtZXRlcnMuIgogICAgICAgICAgICBdLmpvaW4oIlxuIikKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEludmFsaWRJbnB1dFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgIC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mlkZXJEaXNjb25uZWN0ZWRFcnJvciBleHRlbmRzIFByb3ZpZGVyUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlKSB7CiAgICAgICAgICBzdXBlcihjYXVzZSwgewogICAgICAgICAgICBjb2RlOiBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlRoZSBQcm92aWRlciBpcyBkaXNjb25uZWN0ZWQgZnJvbSBhbGwgY2hhaW5zLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAwCiAgICAgIH0pOwogICAgICBDaGFpbkRpc2Nvbm5lY3RlZEVycm9yID0gY2xhc3MgX0NoYWluRGlzY29ubmVjdGVkRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0NoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkNoYWluRGlzY29ubmVjdGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJUaGUgUHJvdmlkZXIgaXMgbm90IGNvbm5lY3RlZCB0byB0aGUgcmVxdWVzdGVkIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KENoYWluRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAxCiAgICAgIH0pOwogICAgICBTd2l0Y2hDaGFpbkVycm9yID0gY2xhc3MgX1N3aXRjaENoYWluRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX1N3aXRjaENoYWluRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlN3aXRjaENoYWluRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBlcnJvciBvY2N1cnJlZCB3aGVuIGF0dGVtcHRpbmcgdG8gc3dpdGNoIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFN3aXRjaENoYWluRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAyCiAgICAgIH0pOwogICAgICBVbmtub3duUnBjRXJyb3IgPSBjbGFzcyBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgbmFtZTogIlVua25vd25ScGNFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIkFuIHVua25vd24gUlBDIGVycm9yIG9jY3VycmVkLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICA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BeIGEgJiBjIF4gYiAmIGM7CiAgICAgIEhhc2hNRCA9IGNsYXNzIGV4dGVuZHMgSGFzaCB7CiAgICAgICAgY29uc3RydWN0b3IoYmxvY2tMZW4sIG91dHB1dExlbiwgcGFkT2Zmc2V0LCBpc0xFMikgewogICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgIHRoaXMuYmxvY2tMZW4gPSBibG9ja0xlbjsKICAgICAgICAgIHRoaXMub3V0cHV0TGVuID0gb3V0cHV0TGVuOwogICAgICAgICAgdGhpcy5wYWRPZmZzZXQgPSBwYWRPZmZzZXQ7CiAgICAgICAgICB0aGlzLmlzTEUgPSBpc0xFMjsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSBmYWxzZTsKICAgICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICAgIHRoaXMucG9zID0gMDsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICB0aGlzLmJ1ZmZlciA9IG5ldyBVaW50OEFycmF5KGJsb2NrTGVuKTsKICAgICAgICAgIHRoaXMudmlldyA9IGNyZWF0ZVZpZXcodGhpcy5idWZmZXIpOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyB2aWV3LCBidWZmZXI6IGJ1ZmZlcjIsIGJsb2NrTGVuIH0gPSB0aGlzOwogICAgICAgICAgZGF0YSA9IHRvQnl0ZXMyKGRhdGEpOwogICAgICAgICAgY29uc3QgbGVuID0gZGF0YS5sZW5ndGg7CiAgICAgICAgICBmb3IgKGxldCBwb3MgPSAwOyBwb3MgPCBsZW47ICkgewogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvcywgbGVuIC0gcG9zKTsKICAgICAgICAgICAgaWYgKHRha2UgPT09IGJsb2NrTGVuKSB7CiAgICAgICAgICAgICAgY29uc3QgZGF0YVZpZXcgPSBjcmVhdGVWaWV3KGRhdGEpOwogICAgICAgICAgICAgIGZvciAoOyBibG9ja0xlbiA8PSBsZW4gLSBwb3M7IHBvcyArPSBibG9ja0xlbikKICAgICAgICAgICAgICAgIHRoaXMucHJvY2VzcyhkYXRhVmlldywgcG9zKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIyLnNldChkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgdGFrZSksIHRoaXMucG9zKTsKICAgICAgICAgICAgdGhpcy5wb3MgKz0gdGFrZTsKICAgICAgICAgICAgcG9zICs9IHRha2U7CiAgICAgICAgICAgIGlmICh0aGlzLnBvcyA9PT0gYmxvY2tMZW4pIHsKICAgICAgICAgICAgICB0aGlzLnByb2Nlc3ModmlldywgMCk7CiAgICAgICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmxlbmd0aCArPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIHRoaXMucm91bmRDbGVhbigpOwogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdEludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcyk7CiAgICAgICAgICBvdXRwdXQob3V0LCB0aGlzKTsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSB0cnVlOwogICAgICAgICAgY29uc3QgeyBidWZmZXI6IGJ1ZmZlcjIsIHZpZXcsIGJsb2NrTGVuLCBpc0xFOiBpc0xFMiB9ID0gdGhpczsKICAgICAgICAgIGxldCB7IHBvcyB9ID0gdGhpczsKICAgICAgICAgIGJ1ZmZlcjJbcG9zKytdID0gMTI4OwogICAgICAgICAgdGhpcy5idWZmZXIuc3ViYXJyYXkocG9zKS5maWxsKDApOwogICAgICAgICAgaWYgKHRoaXMucGFkT2Zmc2V0ID4gYmxvY2tMZW4gLSBwb3MpIHsKICAgICAgICAgICAgdGhpcy5wcm9jZXNzKHZpZXcsIDApOwogICAgICAgICAgICBwb3MgPSAwOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChsZXQgaSA9IHBvczsgaSA8IGJsb2NrTGVuOyBpKyspCiAgICAgICAgICAgIGJ1ZmZlcjJbaV0gPSAwOwogICAgICAgICAgc2V0QmlnVWludDY0KHZpZXcsIGJsb2NrTGVuIC0gOCwgQmlnSW50KHRoaXMubGVuZ3RoICogOCksIGlzTEUyKTsKICAgICAgICAgIHRoaXMucHJvY2Vzcyh2aWV3LCAwKTsKICAgICAgICAgIGNvbnN0IG92aWV3ID0gY3JlYXRlVmlldyhvdXQpOwogICAgICAgICAgY29uc3QgbGVuID0gdGhpcy5vdXRwdXRMZW47CiAgICAgICAgICBpZiAobGVuICUgNCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIHNob3VsZCBiZSBhbGlnbmVkIHRvIDMyYml0Iik7CiAgICAgICAgICBjb25zdCBvdXRMZW4gPSBsZW4gLyA0OwogICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLmdldCgpOwogICAgICAgICAgaWYgKG91dExlbiA+IHN0YXRlLmxlbmd0aCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIGJpZ2dlciB0aGFuIHN0YXRlIik7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG91dExlbjsgaSsrKQogICAgICAgICAgICBvdmlldy5zZXRVaW50MzIoNCAqIGksIHN0YXRlW2ldLCBpc0xFMik7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdCgpIHsKICAgICAgICAgIGNvbnN0IHsgYnVmZmVyOiBidWZmZXIyLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8oYnVmZmVyMik7CiAgICAgICAgICBjb25zdCByZXMgPSBidWZmZXIyLnNsaWNlKDAsIG91dHB1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mV3IFVpbnQzMkFycmF5KFsKICAgICAgICAxMTE2MzUyNDA4LAogICAgICAgIDE4OTk0NDc0NDEsCiAgICAgICAgMzA0OTMyMzQ3MSwKICAgICAgICAzOTIxMDA5NTczLAogICAgICAgIDk2MTk4NzE2MywKICAgICAgICAxNTA4OTcwOTkzLAogICAgICAgIDI0NTM2MzU3NDgsCiAgICAgICAgMjg3MDc2MzIyMSwKICAgICAgICAzNjI0MzgxMDgwLAogICAgICAgIDMxMDU5ODQwMSwKICAgICAgICA2MDcyMjUyNzgsCiAgICAgICAgMTQyNjg4MTk4NywKICAgICAgICAxOTI1MDc4Mzg4LAogICAgICAgIDIxNjIwNzgyMDYsCiAgICAgICAgMjYxNDg4ODEwMywKICAgICAgICAzMjQ4MjIyNTgwLAogICAgICAgIDM4MzUzOTA0MDEsCiAgICAgICAgNDAyMjIyNDc3NCwKICAgICAgICAyNjQzNDcwNzgsCiAgICAgICAgNjA0ODA3NjI4LAogICAgICAgIDc3MDI1NTk4MywKICAgICAgICAxMjQ5MTUwMTIyLAogICAgICAgIDE1NTUwODE2OTIsCiAgICAgICAgMTk5NjA2NDk4NiwKICAgICAgICAyNTU0MjIwODgyLAogICAgICAgIDI4MjE4MzQzNDksCiAgICAgICAgMjk1Mjk5NjgwOCwKICAgICAgICAzMjEwMzEzNjcxLAogICAgICAgIDMzMzY1NzE4OTEsCiAgICAgICAgMzU4NDUyODcxMSwKICAgICAgICAxMTM5MjY5OTMsCiAgICAgICAgMzM4MjQxODk1LAogICAgICAgIDY2NjMwNzIwNSwKICAgICAgICA3NzM1Mjk5MTIsCiAgICAgICAgMTI5NDc1NzM3MiwKICAgICAgICAxMzk2MTgyMjkxLAogICAgICAgIDE2OTUxODM3MDAsCiAgICAgICAgMTk4NjY2MTA1MSwKICAgICAgICAyMTc3MDI2MzUwLAogICAgICAgIDI0NTY5NTYwMzcsCiAgICAgICAgMjczMDQ4NTkyMSwKICAgICAgICAyODIwMzAyNDExLAogICAgICAgIDMyNTk3MzA4MDAsCiAgICAgICAgMzM0NTc2NDc3MSwKICAgICAgICAzNTE2MDY1ODE3LAogICAgICAgIDM2MDAzNTI4MDQsCiAgICAgICAgNDA5NDU3MTkwOSwKICAgICAgICAyNzU0MjMzNDQsCiAgICAgICAgNDMwMjI3NzM0LAogICAgICAgIDUwNjk0ODYxNiwKICAgICAgICA2NTkwNjA1NTYsCiAgICAgICAgODgzOTk3ODc3LAogICAgICAgIDk1ODEzOTU3MSwKICAgICAgICAxMzIyODIyMjE4LAogICAgICAgIDE1MzcwMDIwNjMsCiAgICAgICAgMTc0Nzg3Mzc3OSwKICAgICAgICAxOTU1NTYyMjIyLAogICAgICAgIDIwMjQxMDQ4MTUsCiAgICAgICAgMjIyNzczMDQ1MiwKICAgICAgICAyMzYxODUyNDI0LAogICAgICAgIDI0Mjg0MzY0NzQsCiAgICAgICAgMjc1NjczNDE4NywKICAgICAgICAzMjA0MDMxNDc5LAogICAgICAgIDMzMjkzMjUyOTgKICAgICAgXSk7CiAgICAgIFNIQTI1Nl9JViA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoWwogICAgICAgIDE3NzkwMzM3MDMsCiAgICAgICAgMzE0NDEzNDI3NywKICAgICAgICAxMDEzOTA0MjQyLAogICAgICAgIDI3NzM0ODA3NjIsCiAgICAgICAgMTM1OTg5MzExOSwKICAgICAgICAyNjAwODIyOTI0LAogICAgICAgIDUyODczNDYzNSwKICAgICAgICAxNTQxNDU5MjI1CiAgICAgIF0pOwogICAgICBTSEEyNTZfVyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoNjQpOwogICAgICBTSEEyNTYgPSBjbGFzcyBleHRlbmRzIEhhc2hNRCB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcig2NCwgMzIsIDgsIGZhbHNlKTsKICAgICAgICAgIHRoaXMuQSA9IFNIQTI1Nl9JVlswXSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBTSEEyNTZfSVZbMV0gfCAwOwogICAgICAgICAgdGhpcy5DID0gU0hBMjU2X0lWWzJdIHwgMDsKICAgICAgICAgIHRoaXMuRCA9IFNIQTI1Nl9JVlszXSB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBTSEEyNTZfSVZbNF0gfCAwOwogICAgICAgICAgdGhpcy5GID0gU0hBMjU2X0lWWzVdIHwgMDsKICAgICAgICAgIHRoaXMuRyA9IFNIQTI1Nl9JVls2XSB8IDA7CiAgICAgICAgICB0aGlzLkggPSBTSEEyNTZfSVZbN10gfCAwOwogICAgICAgIH0KICAgICAgICBnZXQoKSB7CiAgICAgICAgICBjb25zdCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICByZXR1cm4gW0EsIEIsIEMsIEQsIEUsIEYsIEcsIEhdOwogICAgICAgIH0KICAgICAgICAvLyBwcmV0dGllci1pZ25vcmUKICAgICAgICBzZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCkgewogICAgICAgICAgdGhpcy5BID0gQSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBCIHwgMDsKICAgICAgICAgIHRoaXMuQyA9IEMgfCAwOwogICAgICAgICAgdGhpcy5EID0gRCB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBFIHwgMDsKICAgICAgICAgIHRoaXMuRiA9IEYgfCAwOwogICAgICAgICAgdGhpcy5HID0gRyB8IDA7CiAgICAgICAgICB0aGlzLkggPSBIIHwgMDsKICAgICAgICB9CiAgICAgICAgcHJvY2Vzcyh2aWV3LCBvZmZzZXQpIHsKICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMTY7IGkrKywgb2Zmc2V0ICs9IDQpCiAgICAgICAgICAgIFNIQTI1Nl9XW2ldID0gdmlldy5nZXRVaW50MzIob2Zmc2V0LCBmYWxzZSk7CiAgICAgICAgICBmb3IgKGxldCBpID0gMTY7IGkgPCA2NDsgaSsrKSB7CiAgICAgICAgICAgIGNvbnN0IFcxNSA9IFNIQTI1Nl9XW2kgLSAxNV07CiAgICAgICAgICAgIGNvbnN0IFcyID0gU0hBMjU2X1dbaSAtIDJdOwogICAgICAgICAgICBjb25zdCBzMCA9IHJvdHIoVzE1LCA3KSBeIHJvdHIoVzE1LCAxOCkgXiBXMTUgPj4+IDM7CiAgICAgICAgICAgIGNvbnN0IHMxID0gcm90cihXMiwgMTcpIF4gcm90cihXMiwgMTkpIF4gVzIgPj4+IDEwOwogICAgICAgICAgICBTSEEyNTZfV1tpXSA9IHMxICsgU0hBMjU2X1dbaSAtIDddICsgczAgKyBTSEEyNTZfV1tpIC0gMTZdIHwgMDsKICAgICAgICAgIH0KICAgICAgICAgIGxldCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDY0OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc2lnbWExID0gcm90cihFLCA2KSBeIHJvdHIoRSwgMTEpIF4gcm90cihFLCAyNSk7CiAgICAgICAgICAgIGNvbnN0IFQxID0gSCArIHNpZ21hMSArIENoaShFLCBGLCBHKSArIFNIQTI1Nl9LW2ldICsgU0hBMjU2X1dbaV0gfCAwOwogICAgICAgICAgICBjb25zdCBzaWdtYTAgPSByb3RyKEEsIDIpIF4gcm90cihBLCAxMykgXiByb3RyKEEsIDIyKTsKICAgICAgICAgICAgY29uc3QgVDIgPSBzaWdtYTAgKyBNYWooQSwgQiwgQykgfCAwOwogICAgICAgICAgICBIID0gRzsKICAgICAgICAgICAgRyA9IEY7CiAgICAgICAgICAgIEYgPSBFOwogICAgICAgICAgICBFID0gRCArIFQxIHwgMDsKICAgICAgICAgICAgRCA9IEM7CiAgICAgICAgICAgIEMgPSBCOwogICAgICAgICAgICBCID0gQTsKICAgICAgICAgICAgQSA9IFQxICsgVDIgfCAwOwogICAgICAgICAgfQogICAgICAgICAgQSA9IEEgKyB0aGlzLkEgfCAwOwogICAgICAgICAgQiA9IEIgKyB0aGlzLkIgfCAwOwogICAgICAgICAgQyA9IEMgKyB0aGlzLkMgfCAwOwogICAgICAgICAgRCA9IEQgKyB0aGlzLkQgfCAwOwogICAgICAgICAgRSA9IEUgKyB0aGlzLkUgfCAwOwogICAgICAgICAgRiA9IEYgKyB0aGlzLkYgfCAwOwogICAgICAgICAgRyA9IEcgKyB0aGlzLkcgfCAwOwogICAgICAgICAgSCA9IEggKyB0aGlzLkggfCAwOwogICAgICAgICAgdGhpcy5zZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCk7CiAgICAgICAgfQogICAgICAgIHJvdW5kQ2xlYW4oKSB7CiAgICAgICAgICBTSEEyNTZfVy5maWxsKDApOwogICAgICAgIH0KICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgdGhpcy5zZXQoMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCk7CiAgICAgICAgICB0aGlzLmJ1ZmZlci5maWxsKDApOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2hhMjU2ID0gLyogQF9fUFVSRV9fICovIHdyYXBDb25zdHJ1Y3RvcigoKSA9PiBuZXcgU0hBMjU2KCkpOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2hhc2hlc0AxLjUuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2hhc2hlcy9lc20vaG1hYy5qcwogIHZhciBITUFDLCBobWFjOwogIHZhciBpbml0X2htYWMgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStoYXNoZXNAMS41LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9oYXNoZXMvZXNtL2htYWMuanMiKCkgewogICAgICBpbml0X2Fzc2VydCgpOwogICAgICBpbml0X3V0aWxzMigpOwogICAgICBITUFDID0gY2xhc3MgZXh0ZW5kcyBIYXNoIHsKICAgICAgICBjb25zdHJ1Y3RvcihoYXNoMywgX2tleSkgewogICAgICAgICAgc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aC51cGRhdGUocGFkMik7CiAgICAgICAgICBwYWQyLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIHVwZGF0ZShidWYpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIHRoaXMuaUhhc2gudXBkYXRlKGJ1Zik7CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIGJ5dGVzKG91dCwgdGhpcy5vdXRwdXRMZW4pOwogICAgICAgICAgdGhpcy5maW5pc2hlZCA9IHRydWU7CiAgICAgICAgICB0aGlzLmlIYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMub0hhc2gudXBkYXRlKG91dCk7CiAgICAgICAgICB0aGlzLm9IYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMuZGVzdHJveSgpOwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICBjb25zdCBvdXQgPSBuZXcgVWludDhBcnJheSh0aGlzLm9IYXNoLm91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHJldHVybiBvdXQ7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIHRvIHx8ICh0byA9IE9iamVjdC5jcmVhdGUoT2JqZWN0LmdldFByb3RvdHlwZU9mKHRoaXMpLCB7fSkpOwogICAgICAgICAgY29uc3QgeyBvSGFzaCwgaUhhc2gsIGZpbmlzaGVkLCBkZXN0cm95ZWQsIGJsb2NrTGVuLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0byA9IHRvOwogICAgICAgICAgdG8uZmluaXNoZWQgPSBmaW5pc2hlZDsKICAgICAgICAgIHRvLmRlc3Ryb3llZCA9IGRlc3Ryb3llZDsKICAgICAgICAgIHRvLmJsb2NrTGVuID0gYmxvY2tMZW47CiAgICAgICAgICB0by5vdXRwdXRMZW4gPSBvdXRwdXRMZW47CiAgICAgICAgICB0by5vSGFzaCA9IG9IYXNoLl9jbG9uZUludG8odG8ub0hhc2gpOwogICAgICAgICAgdG8uaUhhc2ggPSBpSGFzaC5fY2xvbmVJbnRvKHRvLmlIYXNoKTsKICAgICAgICAgIHJldHVybiB0bzsKICAgICAgICB9CiAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgIHRoaXMub0hhc2guZGVzdHJveSgpOwogICAgICAgICAgdGhpcy5pSGFzaC5kZXN0cm95KCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBobWFjID0gKGhhc2gzLCBrZXksIG1lc3NhZ2UpID0+IG5ldyBITUFDKGhhc2gzLCBrZXkpLnVwZGF0ZShtZXNzYWdlKS5kaWdlc3QoKTsKICAgICAgaG1hYy5jcmVhdGUgPSAoaGFzaDMsIGtleSkgPT4gbmV3IEhNQUMoaGFzaDMsIGtleSk7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby9Abm9ibGUrY3VydmVzQDEuNi4wL25vZGVfbW9kdWxlcy9Abm9ibGUvY3VydmVzL2VzbS9hYnN0cmFjdC91dGlscy5qcwogIHZhciB1dGlsc19leHBvcnRzID0ge307CiAgX19leHBvcnQodXRpbHNfZXhwb3J0cywgewogICAgYUluUmFuZ2U6ICgpID0+IGFJblJhbmdlLAogICAgYWJvb2w6ICgpID0+IGFib29sLAogICAgYWJ5dGVzOiAoKSA9PiBhYnl0ZXMsCiAgICBiaXRHZXQ6ICgpID0+IGJpdEdldCwKICAgIGJpdExlbjogKCkgPT4gYml0TGVuLAogICAgYml0TWFzazogKCkgPT4gYml0TWFzaywKICAgIGJpdFNldDogKCkgPT4gYml0U2V0LAogICAgYnl0ZXNUb0hleDogKCkgPT4gYnl0ZXNUb0hleDIsCiAgICBieXRlc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ORSwgWiksIFEpOwogICAgICBsZXQgeCA9IEZwMi5wb3cobiwgUTFkaXYyKTsKICAgICAgbGV0IGIgPSBGcDIucG93KG4sIFEpOwogICAgICB3aGlsZSAoIUZwMi5lcWwoYiwgRnAyLk9ORSkpIHsKICAgICAgICBpZiAoRnAyLmVxbChiLCBGcDIuWkVSTykpCiAgICAgICAgICByZXR1cm4gRnAyLlpFUk87CiAgICAgICAgbGV0IG0gPSAxOwogICAgICAgIGZvciAobGV0IHQyID0gRnAyLnNxcihiKTsgbSA8IHI7IG0rKykgewogICAgICAgICAgaWYgKEZwMi5lcWwodDIsIEZwMi5PTkUpKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIHQyID0gRnAyLnNxcih0Mik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGdlID0gRnAyLnBvdyhnLCBfMW4zIDw8IEJpZ0ludChyIC0gbSAtIDEpKTsKICAgICAgICBnID0gRnAyLnNxcihnZSk7CiAgICAgICAgeCA9IEZwMi5tdWwoeCwgZ2UpOwogICAgICAgIGIgPSBGcDIubXVsKGIsIGcpOwogICAgICAgIHIgPSBtOwogICAgICB9CiAgICAgIHJldHVybiB4OwogICAgfTsKICB9CiAgZnVuY3Rpb24gRnBTcXJ0KFApIHsKICAgIGlmIChQICUgXzRuID09PSBfM24pIHsKICAgICAgY29uc3QgcDFkaXY0ID0gKFAgKyBfMW4zKSAvIF80bjsKICAgICAgcmV0dXJuIGZ1bmN0aW9uIHNxcnQzbW9kNChGcDIsIG4pIHsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5wb3cobiwgcDFkaXY0KTsKICAgICAgICBpZiAoIUZwMi5lcWwoRnAyLnNxcihyb290MiksIG4pKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgZmluZCBzcXVhcmUgcm9vdCIpOwogICAgICAgIHJldHVybiByb290MjsKICAgICAgfTsKICAgIH0KICAgIGlmIChQICUgXzhuID09PSBfNW4pIHsKICAgICAgY29uc3QgYzEgPSAoUCAtIF81bikgLyBfOG47CiAgICAgIHJldHVybiBmdW5jdGlvbiBzcXJ0NW1vZDgoRnAyLCBuKSB7CiAgICAgICAgY29uc3QgbjIgPSBGcDIubXVsKG4sIF8ybjMpOwogICAgICAgIGNvbnN0IHYgPSBGcDIucG93KG4yLCBjMSk7CiAgICAgICAgY29uc3QgbnYgPSBGcDIubXVsKG4sIHYpOwogICAgICAgIGNvbnN0IGkgPSBGcDIubXVsKEZwMi5tdWwobnYsIF8ybjMpLCB2KTsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5tdWwobnYsIEZwMi5zdWIoaSwgRnAyLk9ORSkpOwogICAgICAgIGlmICghRnAyLmVxbChGcDIuc3FyKHJvb3QyKSwgbikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgICAgcmV0dXJuIHJvb3QyOwogICAgICB9OwogICAgfQogICAgaWYgKFAgJSBfMTZuID09PSBfOW4pIHsKICAgIH0KICAgIHJldHVybiB0b25lbGxpU2hhbmtzKFApOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZUZpZWxkKGZpZWxkKSB7CiAgICBjb25zdCBpbml0aWFsID0gewogICAgICBPUkRFUjogImJpZ2ludCIsCiAgICAgIE1BU0s6ICJiaWdpbnQiLAogICAgICBCWVRFUzogImlzU2FmZUludGVnZXIiLAogICAgICBCSVRTOiAiaXNTYWZlSW50ZWdlciIKICAgIH07CiAgICBjb25zdCBvcHRzID0gRklFTERfRklFTERTLnJlZHVjZSgobWFwLCB2YWwpID0+IHsKICAgICAgbWFwW3ZhbF0gPSAiZnVuY3Rpb24iOwogICAgICByZXR1cm4gbWFwOwogICAgfSwgaW5pdGlhbCk7CiAgICByZXR1cm4gdmFsaWRhdGVPYmplY3QoZmllbGQsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBGcFBvdyhmMiwgbnVtMiwgcG93ZXIpIHsKICAgIGlmIChwb3dlciA8IF8wbjMpCiAgICAgIHRocm93IG5ldyBFcnJvcigiRXhwZWN0ZWQgcG93ZXIgPiAwIik7CiAgICBpZiAocG93ZXIgPT09IF8wbjMpCiAgICAgIHJldHVybiBmMi5PTkU7CiAgICBpZiAocG93ZXIgPT09IF8xbjMpCiAgICAgIHJldHVybiBudW0yOwogICAgbGV0IHAgPSBmMi5PTkU7CiAgICBsZXQgZCA9IG51bTI7CiAgICB3aGlsZSAocG93ZXIgPiBfMG4zKSB7CiAgICAgIGlmIChwb3dlciAmIF8xbjMpCiAgICAgICAgcCA9IGYyLm11bChwLCBkKTsKICAgICAgZCA9IGYyLnNxcihkKTsKICAgICAgcG93ZXIgPj49IF8xbjM7CiAgICB9CiAgICByZXR1cm4gcDsKICB9CiAgZnVuY3Rpb24gRnBJbnZlcnRCYXRjaChmMiwgbnVtcykgewogICAgY29uc3QgdG1wID0gbmV3IEFycmF5KG51bXMubGVuZ3RoKTsKICAgIGNvbnN0IGxhc3RNdWx0aXBsaWVkID0gbnVtcy5yZWR1Y2UoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGFjYzsKICAgICAgcmV0dXJuIGYyLm11bChhY2MsIG51bTIpOwogICAgfSwgZjIuT05FKTsKICAgIGNvbnN0IGludmVydGVkID0gZjIuaW52KGxhc3RNdWx0aXBsaWVkKTsKICAgIG51bXMucmVkdWNlUmlnaHQoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGYyLm11bChhY2MsIHRtcFtpXSk7CiAgICAgIHJldHVybiBmMi5tdWwoYWNjLCBudW0yKTsKICAgIH0sIGludmVydGVkKTsKICAgIHJldHVybiB0bXA7CiAgfQogIGZ1bmN0aW9uIG5MZW5ndGgobiwgbkJpdExlbmd0aCkgewogICAgY29uc3Qg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CBiaWdpbnQsIGdvdCAke3R5cGVvZiBudW0yfWApOwogICAgICAgIHJldHVybiBfMG4zIDw9IG51bTIgJiYgbnVtMiA8IE9SREVSOwogICAgICB9LAogICAgICBpczA6IChudW0yKSA9PiBudW0yID09PSBfMG4zLAogICAgICBpc09kZDogKG51bTIpID0+IChudW0yICYgXzFuMykgPT09IF8xbjMsCiAgICAgIG5lZzogKG51bTIpID0+IG1vZCgtbnVtMiwgT1JERVIpLAogICAgICBlcWw6IChsaHMsIHJocykgPT4gbGhzID09PSByaHMsCiAgICAgIHNxcjogKG51bTIpID0+IG1vZChudW0yICogbnVtMiwgT1JERVIpLAogICAgICBhZGQ6IChsaHMsIHJocykgPT4gbW9kKGxocyArIHJocywgT1JERVIpLAogICAgICBzdWI6IChsaHMsIHJocykgPT4gbW9kKGxocyAtIHJocywgT1JERVIpLAogICAgICBtdWw6IChsaHMsIHJocykgPT4gbW9kKGxocyAqIHJocywgT1JERVIpLAogICAgICBwb3c6IChudW0yLCBwb3dlcikgPT4gRnBQb3coZjIsIG51bTIsIHBvd2VyKSwKICAgICAgZGl2OiAobGhzLCByaHMpID0+IG1vZChsaHMgKiBpbnZlcnQocmhzLCBPUkRFUiksIE9SREVSKSwKICAgICAgLy8gU2FtZSBhcyBhYm92ZSwgYnV0IGRvZXNuJ3Qgbm9ybWFsaXplCiAgICAgIHNxck46IChudW0yKSA9PiBudW0yICogbnVtMiwKICAgICAgYWRkTjogKGxocywgcmhzKSA9PiBsaHMgKyByaHMsCiAgICAgIHN1Yk46IChsaHMsIHJocykgPT4gbGhzIC0gcmhzLAogICAgICBtdWxOOiAobGhzLCByaHMpID0+IGxocyAqIHJocywKICAgICAgaW52OiAobnVtMikgPT4gaW52ZXJ0KG51bTIsIE9SREVSKSwKICAgICAgc3FydDogcmVkZWYuc3FydCB8fCAoKG4pID0+IHNxcnRQKGYyLCBuKSksCiAgICAgIGludmVydEJhdGNoOiAobHN0KSA9PiBGcEludmVydEJhdGNoKGYyLCBsc3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sYXIuanMiKCkgewogICAgICBpbml0X3V0aWxzNCgpOwogICAgICBfMG4zID0gQmlnSW50KDApOwogICAgICBfMW4zID0gQmlnSW50KDEpOwogICAgICBfMm4zID0gQmlnSW50KDIpOwogICAgICBfM24gPSBCaWdJbnQoMyk7CiAgICAgIF80biA9IEJpZ0ludCg0KTsKICAgICAgXzVuID0gQmlnSW50KDUpOwogICAgICBfOG4gPSBCaWdJbnQoOCk7CiAgICAgIF85biA9IEJpZ0ludCg5KTsKICAgICAgXzE2biA9IEJpZ0ludCgxNik7CiAgICAgIEZJRUxEX0ZJRUxEUyA9IFsKICAgICAgICAiY3JlYXRlIiwKICAgICAgICAiaXNWYWxpZCIsCiAgICAgICAgImlzMCIsCiAgICAgICAgIm5lZyIsCiAgICAgICAgImludiIsCiAgICAgICAgInNxcnQiLAogICAgICAgICJzcXIiLAogICAgICAgICJlcWwiLAogICAgICAgICJhZGQiLAogICAgICAgICJzdWIiLAogICAgICAgICJtdWwiLAogICAgICAgICJwb3ciLAogICAgICAgICJkaXYiLAogICAgICAgICJhZGROIiwKICAgICAgICAic3ViTiIsCiAgICAgICAgIm11bE4iLAogICAgICAgICJzcXJOIgogICAgICBdOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2N1cnZlc0AxLjYuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2N1cnZlcy9lc20vYWJzdHJhY3QvY3VydmUuanMKICBmdW5jdGlvbiB3TkFGKGMsIGJpdHMpIHsKICAgIGNvbnN0IGNvbnN0VGltZU5lZ2F0ZSA9IChjb25kaXRpb24sIGl0ZW0pID0+IHsKICAgICAgY29uc3QgbmVnID0gaXRlbS5uZWdhdGUoKTsKICAgICAgcmV0dXJuIGNvbmRpdGlvbiA/IG5lZyA6IGl0ZW07CiAgICB9OwogICAgY29uc3QgdmFsaWRhdGVXID0gKFcpID0+IHsKICAgICAgaWYgKCFOdW1iZXIuaXNTYWZlSW50ZWdlcihXKSB8fCBXIDw9IDAgfHwgVyA+IGJpdHMpCiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBXcm9uZyB3aW5kb3cgc2l6ZT0ke1d9LCBzaG91bGQgYmUgWzEuLiR7Yml0c31dYCk7CiAgICB9OwogICAgY29uc3Qgb3B0cyA9IChXKSA9PiB7CiAgICAgIHZhbGlkYXRlVyhXKTsKICAgICAgY29uc3Qgd2luZG93cyA9IE1hdGguY2VpbChiaXRzIC8gVykgKyAxOwogICAgICBjb25zdCB3aW5kb3dTaXplID0gMiAqKiAoVyAtIDEpOwogICAgICByZXR1cm4geyB3aW5kb3dzLCB3aW5kb3dTaXplIH07CiAgICB9OwogICAgcmV0dXJuIHsKICAgICAgY29uc3RUaW1lTmVnYXRlLAogICAgICAvLyBub24tY29uc3QgdGltZSBtdWx0aXBsaWNhdGlvbiBsYWRkZXIKICAgICAgdW5zYWZlTGFkZGVyKGVsbSwgbikgewogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBkID0gZWxtOwogICAgICAgIHdoaWxlIChuID4gXzBuNCkgewogICAgICAgICAgaWYgKG4gJiBfMW40KQogICAgICAgICAgICBwID0gcC5hZGQoZCk7CiAgICAgICAgICBkID0gZC5kb3VibGUoKTsKICAgICAgICAgIG4gPj49IF8xbjQ7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwOwogICAgICB9LAogICAgICAvKioKICAgICAgICogQ3JlYXRlcyBhIHdOQUYgcHJlY29tcHV0YXRpb24gd2luZG93LiBVc2VkIGZvciBjYWNoaW5nLgogICAgICAgKiBEZWZhdWx0IHdpbmRvdyBzaXplIGlzIHNldCBieSBgdXRpbHMucHJlY29tcHV0ZSgpYCBhbmQgaXMgZXF1YWwgdG8gOC4KICAgICAgICogTnVtYmVyIG9mIHByZWNvbXB1dGVkIHBvaW50cyBkZXBlbmRzIG9uIHRoZSBjdXJ2ZSBzaXplOgogICAgICAgKiAyXijwnZGK4oiSMSkgKiAoTWF0aC5jZWlsKPCdkZsgLyDwnZGKKSArIDEpLCB3aGVyZToKICAgICAgICogLSDwnZGKIGlzIHRoZSB3aW5kb3cgc2l6ZQogICAgICAgKiAtIPCdkZsgaXMgdGhlIGJpdGxlbmd0aCBvZiB0aGUgY3VydmUgb3JkZXIuCiAgICAgICAqIEZvciBhIDI1Ni1iaXQgY3VydmUgYW5kIHdpbmRvdyBzaXplIDgsIHRoZSBudW1iZXIgb2YgcHJlY29tcHV0ZWQgcG9pbnRzIGlzIDEyOCAqIDMzID0gNDIyNC4KICAgICAgICogQHJldHVybnMgcHJlY29tcHV0ZWQgcG9pbnQgdGFibGVzIGZsYXR0ZW5lZCB0byBhIHNpbmdsZSBhcnJheQogICAgICAgKi8KICAgICAgcHJlY29tcHV0ZVdpbmRvdyhlbG0sIFcpIHsKICAgICAgICBjb25zdCB7IHdpbmRvd3MsIHdpbmRvd1NpemUgfSA9IG9wdHMoVyk7CiAgICAgICAgY29uc3QgcG9pbnRzID0gW107CiAgICAgICAgbGV0IHAgPSBlbG07CiAgICAgICAgbGV0IGJhc2UyID0gcDsKICAgICAgICBmb3IgKGxldCB3aW5kb3cyID0gMDsgd2luZG93MiA8IHdpbmRvd3M7IHdpbmRvdzIrKykgewogICAgICAgICAgYmFzZTIgPSBwOwogICAgICAgICAgcG9pbnRzLnB1c2goYmFzZTIpOwogICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCB3aW5kb3dTaXplOyBpKyspIHsKICAgICAgICAgICAgYmFzZTIgPSBiYXNlMi5hZGQocCk7CiAgICAgICAgICAgIHBvaW50cy5wdXNoKGJhc2UyKTsKICAgICAgICAgIH0KICAgICAgICAgIHAgPSBiYXNlMi5kb3VibGUoKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBvaW50czsKICAgICAgfSwKICAgICAgLyoqCiAgICAgICAqIEltcGxlbWVudHMgZWMgbXVsdGlwbGljYXRpb24gdXNpbmcgcHJlY29tcHV0ZWQgdGFibGVzIGFuZCB3LWFyeSBub24tYWRqYWNlbnQgZm9ybS4KICAgICAgICogQHBhcmFtIFcgd2luZG93IHNpemUKICAgICAgICogQHBhcmFtIHByZWNvbXB1dGVzIHByZWNvbXB1dGVkIHRhYmxlcwogICAgICAgKiBAcGFyYW0gbiBzY2FsYXIgKHdlIGRvbid0IGNoZWNrIGhlcmUsIGJ1dCBzaG91bGQgYmUgbGVzcyB0aGFuIGN1cnZlIG9yZGVyKQogICAgICAgKiBAcmV0dXJucyByZWFsIGFuZCBmYWtlIChmb3IgY29uc3QtdGltZSkgcG9pbnRzCiAgICAgICAqLwogICAgICB3TkFGKFcsIHByZWNvbXB1dGVzLCBuKSB7CiAgICAgICAgY29uc3QgeyB3aW5kb3dzLCB3aW5kb3dTaXplIH0gPSBvcHRzKFcpOwogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBmMiA9IGMuQkFTRTsKICAgICAgICBjb25zdCBtYXNrID0gQmlnSW50KDIgKiogVyAtIDEpOwogICAgICAgIGNvbnN0IG1heE51bWJlciA9IDIgKiogVzsKICAgICAgICBjb25zdCBzaGlmdEJ5ID0gQmlnSW50KFcpOwogICAgICAgIGZvciAobGV0IHdpbmRvdzIgPSAwOyB3aW5kb3cyIDwgd2luZG93czsgd2luZG93MisrKSB7CiAgICAgICAgICBjb25zdCBvZmZzZXQgPSB3aW5kb3cyICogd2luZG93U2l6ZTsKICAgICAgICAgIGxldCB3Yml0cyA9IE51bWJlcihuICYgbWFzayk7CiAgICAgICAgICBuID4+PSBzaGlmdEJ5OwogICAgICAgICAgaWYgKHdiaXRzID4gd2luZG93U2l6ZSkgewogICAgICAgICAgICB3Yml0cyAtPSBtYXhOdW1iZXI7CiAgICAgICAgICAgIG4gKz0gXzFuNDsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG9mZnNldDEgPSBvZmZzZXQ7CiAgICAgICAgICBjb25zdCBvZmZzZXQyID0gb2Zmc2V0ICsgTWF0aC5hYnMod2JpdHMpIC0gMTsKICAgICAgICAgIGNvbnN0IGNvbmQxID0gd2luZG93MiAlIDIgIT09IDA7CiAgICAgICAgICBjb25zdCBjb25kMiA9IHdiaXRzIDwgMDsKICAgICAgICAgIGlmICh3Yml0cyA9PT0gMCkgewogICAgICAgICAgICBmMiA9IGYyLmFkZChjb25zdFRpbWVOZWdhdGUoY29uZDEsIHByZWNvbXB1dGVzW29mZnNldDFdKSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwID0gcC5hZGQoY29uc3RUaW1lTmVnYXRlKGNvbmQyLCBwcmVjb21wdXRlc1tvZmZzZXQyXSkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4geyBwLCBmOiBmMiB9OwogICAgICB9LAogICAgICB3TkFGQ2FjaGVkKFAsIG4sIHRyYW5zZm9ybSkgewogICAgICAgIGNvbnN0IFcgPSBwb2ludFdpbmRvd1NpemVzLmdldChQKSB8fCAxOwogICAgICAgIGxldCBjb21wID0gcG9pbnRQcmVjb21wdXRlcy5nZXQoUCk7CiAgICAgICAgaWYgKCFjb21wKSB7CiAgICAgICAgICBjb21wID0gdGhpcy5wcmVjb21wdXRlV2luZG93KFAsIFcpOwogICAgICAgICAgaWYgKFcgIT09IDEpCiAgICAgICAgICAgIHBvaW50UHJlY29tcHV0ZXMuc2V0KFAsIHRyYW5zZm9ybShjb21wKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLndOQUYoVywgY29tcCwgbik7CiAgICAgIH0sCiAgICAgIC8vIFdlIGNhbGN1bGF0ZSBwcmVjb21wdXRlcyBmb3IgZWxsaXB0aWMgY3VydmUgcG9pbnQgbXVsdGlwbGljYXRpb24KICAgICAgLy8gdXNpbmcgd2luZG93ZWQgbWV0aG9kLiBUaGlzIHNwZWNpZmllcyB3aW5kb3cgc2l6ZSBhbmQKICAgICAgLy8gc3RvcmVzIHByZWNvbXB1dGVkIHZhbHVlcy4gVXN1YWxseSBvbmx5IGJhc2UgcG9pbnQgd291bGQgYmUgcHJlY29tcHV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SA9PT0gImJpZ2ludCIgPyBrZXkgOiBieXRlc1RvTnVtYmVyQkUoZW5zdXJlQnl0ZXMoInByaXZhdGUga2V5Iiwga2V5LCBuQnl0ZUxlbmd0aCkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIHRocm93IG5ldyBFcnJvcihgcHJpdmF0ZSBrZXkgbXVzdCBiZSAke25CeXRlTGVuZ3RofSBieXRlcywgaGV4IG9yIGJpZ2ludCwgbm90ICR7dHlwZW9mIGtleX1gKTsKICAgICAgfQogICAgICBpZiAod3JhcFByaXZhdGVLZXkpCiAgICAgICAgbnVtMiA9IG1vZChudW0yLCBOKTsKICAgICAgYUluUmFuZ2UoInByaXZhdGUga2V5IiwgbnVtMiwgXzFuNSwgTik7CiAgICAgIHJldHVybiBudW0yOwogICAgfQogICAgZnVuY3Rpb24gYXNzZXJ0UHJqUG9pbnQob3RoZXIpIHsKICAgICAgaWYgKCEob3RoZXIgaW5zdGFuY2VvZiBQb2ludDIpKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiUHJvamVjdGl2ZVBvaW50IGV4cGVjdGVkIik7CiAgICB9CiAgICBjb25zdCB0b0FmZmluZU1lbW8gPSBtZW1vaXplZCgocCwgaXopID0+IHsKICAgICAgY29uc3QgeyBweDogeCwgcHk6IHksIHB6OiB6IH0gPSBwOwogICAgICBpZiAoRnAyLmVxbCh6LCBGcDIuT05FKSkKICAgICAgICByZXR1cm4geyB4LCB5IH07CiAgICAgIGNvbnN0IGlzMCA9IHAuaXMwKCk7CiAgICAgIGlmIChpeiA9PSBudWxsKQogICAgICAgIGl6ID0gaXMwID8gRnAyLk9ORSA6IEZwMi5pbnYoeik7CiAgICAgIGNvbnN0IGF4ID0gRnAyLm11bCh4LCBpeik7CiAgICAgIGNvbnN0IGF5ID0gRnAyLm11bCh5LCBpeik7CiAgICAgIGNvbnN0IHp6ID0gRnAyLm11bCh6LCBpeik7CiAgICAgIGlmIChpczApCiAgICAgICAgcmV0dXJuIHsgeD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Hg7CiAgICAgICAgdGhpcy5weSA9IHB5OwogICAgICAgIHRoaXMucHogPSBwejsKICAgICAgICBpZiAocHggPT0gbnVsbCB8fCAhRnAyLmlzVmFsaWQocHgpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJ4IHJlcXVpcmVkIik7CiAgICAgICAgaWYgKHB5ID09IG51bGwgfHwgIUZwMi5pc1ZhbGlkKHB5KSkKICAgICAgICAgIHRocm93IG5ldyBFcnJvcigieSByZXF1aXJlZCIpOwogICAgICAgIGlmIChweiA9PSBudWxsIHx8ICFGcDIuaXNWYWxpZChweikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInogcmVxdWlyZWQiKTsKICAgICAgICBPYmplY3QuZnJlZXplKHRoaXMpOwogICAgICB9CiAgICAgIC8vIERvZXMgbm90IHZhbGlkYXRlIGlmIHRoZSBwb2ludCBpcyBvbi1jdXJ2ZS4KICAgICAgLy8gVXNlIGZyb21IZXggaW5zdGVhZCwgb3IgY2FsbCBhc3NlcnRWYWxpZGl0eSgpIGxhdGVyLgogICAgICBzdGF0aWMgZnJvbUFmZmluZShwKSB7CiAgICAgICAgY29uc3QgeyB4LCB5IH0gPSBwIHx8IHt9OwogICAgICAgIGlmICghcCB8fCAhRnAyLmlzVmFsaWQoeCkgfHwgIUZwMi5pc1ZhbGlkKHkpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJpbnZhbGlkIGFmZmluZSBwb2ludCIpOwogICAgICAgIGlmIChwIGluc3RhbmNlb2YgUG9pbnQyKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJwcm9qZWN0aXZlIHBvaW50IG5vdCBhbGxvd2VkIik7CiAgICAgICAgY29uc3QgaXMwID0gKGkpID0+IEZwMi5lcWwoaSwgRnAyLlpFUk8pOwogICAgICAgIGlmIChpczAoeCkgJiYgaXMwKHkpKQogICAgICAgICAgcmV0dXJuIFBvaW50Mi5aRVJPOwogICAgICAgIHJldHVybiBuZXcgUG9pbnQyKH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11bChiLCBfM24yKTsKICAgICAgICBjb25zdCB7IHB4OiBYMSwgcHk6IFkxLCBwejogWjEgfSA9IHRoaXM7CiAgICAgICAgbGV0IFgzID0gRnAyLlpFUk8sIFkzID0gRnAyLlpFUk8sIFozID0gRnAyLlpFUk87CiAgICAgICAgbGV0IHQwID0gRnAyLm11bChYMSwgWDEpOwogICAgICAgIGxldCB0MSA9IEZwMi5tdWwoWTEsIFkxKTsKICAgICAgICBsZXQgdDIgPSBGcDIubXVsKFoxLCBaMSk7CiAgICAgICAgbGV0IHQzID0gRnAyLm11bChYMSwgWTEpOwogICAgICAgIHQzID0gRnAyLmFkZCh0MywgdDMpOwogICAgICAgIFozID0gRnAyLm11bChYMSwgWjEpOwogICAgICAgIFozID0gRnAyLmFkZChaMywgWjMpOwogICAgICAgIFgzID0gRnAyLm11bChhLCBaMyk7CiAgICAgICAgWTMgPSBGcDIubXVsKGIzMiwgdDIpOwogICAgICAgIFkzID0gRnAyLmFkZChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLnN1Yih0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLmFkZCh0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLm11bChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLm11bCh0MywgWDMpOwogICAgICAgIFozID0gRnAyLm11bChiMzIsIFozKTsKICAgICAgICB0MiA9IEZwMi5tdWwoYSwgdDIpOwogICAgICAgIHQzID0gRnAyLnN1Yih0MCwgdDIpOwogICAgICAgIHQzID0gRnAyLm11bChhLCB0Myk7CiAgICAgICAgdDMgPSBGcDIuYWRkKHQzLCBaMyk7CiAgICAgICAgWjMgPSBGcDIuYWRkKHQwLCB0MCk7CiAgICAgICAgdDAgPSBGcDIuYWRkKFozLCB0MCk7CiAgICAgICAgdDAgPSBGcDIuYWRkKHQwLCB0Mik7CiAgICAgICAgdDAgPSBGcDIubXVsKHQwLCB0Myk7CiAgICAgICAgWTMgPSBGcDIuYWRkKFkzLCB0MCk7CiAgICAgICAg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GcDIuYWRkKHQxLCB0Mik7CiAgICAgICAgdDIgPSBGcDIuc3ViKHQwLCB0Mik7CiAgICAgICAgdDIgPSBGcDIubXVsKGEsIHQyKTsKICAgICAgICB0NCA9IEZwMi5hZGQodDQsIHQyKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDEsIHQ0KTsKICAgICAgICBZMyA9IEZwMi5hZGQoWTMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDUsIHQ0KTsKICAgICAgICBYMyA9IEZwMi5tdWwodDMsIFgzKTsKICAgICAgICBYMyA9IEZwMi5zdWIoWDMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDMsIHQxKTsKICAgICAgICBaMyA9IEZwMi5tdWwodDUsIFozKTsKICAgICAgICBaMyA9IEZwMi5hZGQoWjMsIHQwKTsKICAgICAgICByZXR1cm4gbmV3IFBvaW50MihYMywgWTMsIFozKTsKICAgICAgfQogICAgICBzdWJ0cmFjdChvdGhlcikgewogICAgICAgIHJldHVybiB0aGlzLmFkZChvdGhlci5uZWdhdGUoKSk7CiAgICAgIH0KICAgICAgaXMwKCkgewogICAgICAgIHJldHVybiB0aGlzLmVxdWFscyhQb2ludDIuWkVSTyk7CiAgICAgIH0KICAgICAgd05BRihuKSB7CiAgICAgICAgcmV0dXJuIHduYWYud05BRkNhY2hlZCh0aGlzLCBuLCBQb2ludDIubm9ybWFsaXplWik7CiAgICAgIH0KICAgICAgLyoqCiAgICAgICAqIE5vbi1jb25zdGFudC10aW1lIG11bHRpcGxpY2F0aW9uLiBVc2VzIGRvdWJsZS1hbmQtYWRkIGFsZ29yaXRobS4KICAgICAgICogSXQncyBmYXN0ZXIsIGJ1dCBzaG91bGQgb25seSBiZSB1c2VkIHdoZW4geW91IGRvbid0IGNhcmUgYWJvdXQKICAgICAgICogYW4gZXhwb3NlZCBwcml2YXRlIGtleSBlLmcuIHNpZyB2ZXJpZmljYXRpb24sIHdoaWNoIHdvcmtzIG92ZXIgKnB1YmxpYyoga2V5cy4KICAgICAgICovCiAgICAgIG11bHRpcGx5VW5zYWZlKHNjKSB7CiAgICAgICAgYUluUmFuZ2UoInNjYWxhciIsIHNjLCBfMG41LCBDVVJWRS5uKTsKICAgICAgICBjb25zdCBJID0gUG9pbnQyLlpFUk87CiAgICAgICAgaWYgKHNjID09PSBfMG41KQogICAgICAgICAgcmV0dXJuIEk7CiAgICAgICAgaWYgKHNjID09PSBfMW41KQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgY29uc3QgeyBlbmRvIH0gPSBDVVJWRTsKICAgICAgICBpZiAoIWVuZG8pCiAgICAgICAgICByZXR1cm4gd25hZi51bnNhZmVMYWRkZXIodGhpcywgc2MpOwogICAgICAgIGxldCB7IGsxbmVnLCBrMSwgazJuZWcsIGsyIH0gPSBlbmRvLnNwbGl0U2NhbGFyKHNjKTsKICAgICAgICBsZXQgazFwID0gSTsKICAgICAgICBsZXQgazJwID0gSTsKICAgICAgICBsZXQgZCA9IHRoaXM7CiAgICAgICAgd2hpbGUgKGsxID4gXzBuNSB8fCBrMiA+IF8wbjUpIHsKICAgICAgICAgIGlmIChrMSAmIF8xbjUpCiAgICAgICAgICAgIGsxcCA9IGsxcC5hZGQoZCk7CiAgICAgICAgICBpZiAoazIgJiBfMW41KQogICAgICAgICAgICBrMnAgPSBrMnAuYWRkKGQpOwogICAgICAgICAgZCA9IGQuZG91YmxlKCk7CiAgICAgICAgICBrMSA+Pj0gXzFuNTsKICAgICAgICAgIGsyID4+PSBfMW41OwogICAgICAgIH0KICAgICAgICBpZiAoazFuZWcpCiAgICAgICAgICBrMXAgPSBrMXAubmVnYXRlKCk7CiAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgazJwID0gazJwLm5lZ2F0ZSgpOwogICAgICAgIGsycCA9IG5ldyBQb2ludDIoRnAyLm11bChrMnAucHgsIGVuZG8uYmV0YSksIGsycC5weSwgazJwLnB6KTsKICAgICAgICByZXR1cm4gazFwLmFkZChrMnApOwogICAgICB9Ci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wgazJwLnB5LCBrMnAucHopOwogICAgICAgICAgcG9pbnQgPSBrMXAuYWRkKGsycCk7CiAgICAgICAgICBmYWtlID0gZjFwLmFkZChmMnApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCB7IHAsIGY6IGYyIH0gPSB0aGlzLndOQUYoc2NhbGFyKTsKICAgICAgICAgIHBvaW50ID0gcDsKICAgICAgICAgIGZha2UgPSBmMjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIFBvaW50Mi5ub3JtYWxpemVaKFtwb2ludCwgZmFrZV0pWzBdOwogICAgICB9CiAgICAgIC8qKgogICAgICAgKiBFZmZpY2llbnRseSBjYWxjdWxhdGUgYGFQICsgYlFgLiBVbnNhZmUsIGNhbiBleHBvc2UgcHJpdmF0ZSBrZXksIGlmIHVzZWQgaW5jb3JyZWN0bHkuCiAgICAgICAqIE5vdCB1c2luZyBTdHJhdXNzLVNoYW1pciB0cmljazogcHJlY29tcHV0YXRpb24gdGFibGVzIGFyZSBmYXN0ZXIuCiAgICAgICAqIFRoZSB0cmljayBjb3VsZCBiZSB1c2VmdWwgaWYgYm90aCBQIGFuZCBRIGFyZSBub3QgRyAobm90IGluIG91ciBjYXNlKS4KICAgICAgICogQHJldHVybnMgbm9uLXplcm8gYWZmaW5lIHBvaW50CiAgICAgICAqLwogICAgICBtdWx0aXBseUFuZEFkZFVuc2FmZShRLCBhLCBiKSB7CiAgICAgICAgY29uc3QgRyA9IFBvaW50Mi5CQVNFOwogICAgICAgIGNvbnN0IG11bCA9IChQLCBhMikgPT4gYTIgPT09IF8wbjUgfHwgYTIgPT09IF8xbjUgfHwgIVAuZXF1YWxzKEcpID8gUC5tdWx0aXBseVVuc2FmZShhMikgOiBQLm11bHRpcGx5KGEyKTsKICAgICAgICBjb25zdCBzdW0gPSBtdWwodGhpcywgYSkuYWRkKG11bChRLCBiKSk7CiAgICAgICAgcmV0dXJuIHN1bS5pczAoKSA/IHZvaWQgMCA6IHN1bTsKICAgICAgf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b21wcmVzc2VkKTsKICAgICAgICBpZiAoaXNDb21wcmVzc2VkKSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbcG9pbnQuaGFzRXZlblkoKSA/IDIgOiAzXSksIHgpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbNF0pLCB4LCBGcDIudG9CeXRlcyhhLnkpKTsKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGZyb21CeXRlcyhieXRlczIpIHsKICAgICAgICBjb25zdCBsZW4gPSBieXRlczIubGVuZ3RoOwogICAgICAgIGNvbnN0IGhlYWQgPSBieXRlczJbMF07CiAgICAgICAgY29uc3QgdGFpbCA9IGJ5dGVzMi5zdWJhcnJheSgxKTsKICAgICAgICBpZiAobGVuID09PSBjb21wcmVzc2VkTGVuICYmIChoZWFkID09PSAyIHx8IGhlYWQgPT09IDMpKSB7CiAgICAgICAgICBjb25zdCB4ID0gYnl0ZXNUb051bWJlckJFKHRhaWwpOwogICAgICAgICAgaWYgKCFpblJhbmdlKHgsIF8xbjUsIEZwMi5PUkRFUikpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiUG9pbnQgaXMgbm90IG9uIGN1cnZlIik7CiAgICAgICAgICBjb25zdCB5MiA9IHdlaWVyc3RyYXNzRXF1YXRpb24oeCk7CiAgICAgICAgICBsZXQgeTsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHkgPSBGcDIuc3FydCh5Mik7CiAgICAgICAgICB9IGNhdGNoIChzcXJ0RXJyb3IpIHsKICAgICAgICAgICAgY29uc3Qgc3VmZml4ID0gc3FydEVycm9yIGluc3RhbmNlb2YgRXJyb3IgPyAiOiAiICsgc3FydEVycm9yLm1lc3NhZ2UgOiAiIjsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJQb2ludCBpcyBub3Qgb24gY3VydmUiICsgc3VmZml4KTsKICAgICAgICAgIH0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wogICAgICB9CiAgICAgIGFzc2VydFZhbGlkaXR5KCkgewogICAgICAgIGFJblJhbmdlKCJyIiwgdGhpcy5yLCBfMW41LCBDVVJWRV9PUkRFUik7CiAgICAgICAgYUluUmFuZ2UoInMiLCB0aGlzLnMsIF8xbjUsIENVUlZFX09SREVSKTsKICAgICAgfQogICAgICBhZGRSZWNvdmVyeUJpdChyZWNvdmVyeSkgewogICAgICAgIHJldHVybiBuZXcgU2lnbmF0dXJlKHRoaXMuciwgdGhpcy5zLCByZWNvdmVyeSk7CiAgICAgIH0KICAgICAgcmVjb3ZlclB1YmxpY0tleShtc2dIYXNoKSB7CiAgICAgICAgY29uc3QgeyByLCBzLCByZWNvdmVyeTogcmVjIH0gPSB0aGlzOwogICAgICAgIGNvbnN0IGggPSBiaXRzMmludF9tb2ROKGVuc3VyZUJ5dGVzKCJtc2dIYXNoIiwgbXNnSGFzaCkpOwogICAgICAgIGlmIChyZWMgPT0gbnVsbCB8fCAhWzAsIDEsIDIsIDNdLmluY2x1ZGVzKHJlYykpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInJlY292ZXJ5IGlkIGludmFsaWQiKTsKICAgICAgICBjb25zdCByYWRqID0gcmVjID09PSAyIHx8IHJlYyA9PT0gMyA/IHIgKyBDVVJWRS5uIDogcjsKICAgICAgICBpZiAocmFkaiA+PSBGcDIuT1JERVIpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInJlY292ZXJ5IGlkIDIgb3IgMyBpbnZhbGlkIik7CiAgICAgICAgY29uc3QgcHJlZml4ID0gKHJlYyAmIDEpID09PSAwID8gIjAyIiA6ICIwMyI7CiAgICAgICAgY29uc3QgUiA9IFBvaW50Mi5mcm9tSGV4KHByZWZpeCArIG51bVRvTkJ5dGVTdHIocmFkaikpOwogICAgICAgIGNvbnN0IGlyID0gaW52TihyYWRqKTsKICAgICAgICBjb25zdCB1MSA9IG1vZE4yKC1oICogaXIpOwogICAgICAgIGNvbnN0IHUyID0gbW9kT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NlKSB7CiAgICAgICAgY29uc3QgZSA9IGVudCA9PT0gdHJ1ZSA/IHJhbmRvbUJ5dGVzMihGcDIuQllURVMpIDogZW50OwogICAgICAgIHNlZWRBcmdzLnB1c2goZW5zdXJlQnl0ZXMoImV4dHJhRW50cm9weSIsIGUpKTsKICAgICAgfQogICAgICBjb25zdCBzZWVkID0gY29uY2F0Qnl0ZXMzKC4uLnNlZWRBcmdzKTsKICAgICAgY29uc3QgbSA9IGgxaW50OwogICAgICBmdW5jdGlvbiBrMnNpZyhrQnl0ZXMpIHsKICAgICAgICBjb25zdCBrID0gYml0czJpbnQoa0J5dGVzKTsKICAgICAgICBpZiAoIWlzV2l0aGluQ3VydmVPcmRlcihrKSkKICAgICAgICAgIHJldHVybjsKICAgICAgICBjb25zdCBpayA9IGludk4oayk7CiAgICAgICAgY29uc3QgcSA9IFBvaW50Mi5CQVNFLm11bHRpcGx5KGspLnRvQWZmaW5lKCk7CiAgICAgICAgY29uc3QgciA9IG1vZE4yKHEueCk7CiAgICAgICAgaWYgKHIgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgY29uc3QgcyA9IG1vZE4yKGlrICogbW9kTjIobSArIHIgKiBkKSk7CiAgICAgICAgaWYgKHMgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgbGV0IHJlY292ZXJ5ID0gKHEueCA9PT0gciA/IDAgOiAyKSB8IE51bWJlcihxLnkgJiBfMW41KTsKICAgICAgICBsZXQgbm9ybVMgPSBzOwogICAgICAgIGlmIChsb3dTICYmIGlzQmlnZ2VyVGhhbkhhbGZPcmRlcihzKSkgewogICAgICAgICAgbm9ybVMgPSBub3JtYWxpemVTKHMpOwogICAgICAgICAgcmVjb3ZlcnkgXj0gMTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG5ldyBTaWduYXR1cmUociwgbm9ybVMsIHJlY292ZXJ5KTsKICAgICAgfQogICAgICByZXR1cm4geyBzZWVkLCBrMnNpZyB9OwogIC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2b2lkIDA7CiAgICAgIGxldCBQOwogICAgICB0cnkgewogICAgICAgIGlmICh0eXBlb2Ygc2cgPT09ICJzdHJpbmciIHx8IGlzQnl0ZXMyKHNnKSkgewogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgX3NpZyA9IFNpZ25hdHVyZS5mcm9tREVSKHNnKTsKICAgICAgICAgIH0gY2F0Y2ggKGRlckVycm9yKSB7CiAgICAgICAgICAgIGlmICghKGRlckVycm9yIGluc3RhbmNlb2YgREVSLkVycikpCiAgICAgICAgICAgICAgdGhyb3cgZGVyRXJyb3I7CiAgICAgICAgICAgIF9zaWcgPSBTaWduYXR1cmUuZnJvbUNvbXBhY3Qoc2cpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNnID09PSAib2JqZWN0IiAmJiB0eXBlb2Ygc2cuciA9PT0gImJpZ2ludCIgJiYgdHlwZW9mIHNnLnMgPT09ICJiaWdpbnQiKSB7CiAgICAgICAgICBjb25zdCB7IHI6IHIyLCBzOiBzMiB9ID0gc2c7CiAgICAgICAgICBfc2lnID0gbmV3IFNpZ25hdHVyZShyMiwgczIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBBUlNFIik7CiAgICAgICAgfQogICAgICAgIFAgPSBQb2ludDIuZnJvbUhleChwdWJsaWNLZXkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChlcnJvci5tZXNzYWdlID09PSAiUEFSU0UiKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzaWduYXR1cmUgbXVzdCBiZSBTaWduYXR1cmUgaW5zdGFuY2UsIFVpbnQ4QXJyYXkgb3IgaGV4IHN0cmluZ2ApOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobG93UyAmJiBfc2lnLmhhc0hpZ2hTKCkpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAocHJlaGFzaCkKICAgICAgICBtc2dIYXNoID0gQ1VSVkUuaGFzaChtc2dIYXNoKTsKICAgICAgY29uc3QgeyByLCBzIH0gPSBfc2lnOwogICAgICBjb25zdCBoID0gYml0czJpbnRfbW9kTihtc2dIYXNoKTsKICAgICAgY29uc3QgaXMgPSBpbnZOKHMpOwogICAgICBjb25zdCB1MSA9IG1vZE4yKGggKiBpcyk7CiAgICAgIGNvbnN0IHUyID0gbW9kTjIociAqIGlzKTsKICAgICAgY29uc3QgUiA9IFBvaW50Mi5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFAsIHUxLCB1Mik/LnRvQWZmaW5lKCk7CiAgICAgIGlmICghUikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGNvbnN0IHYgPSBtb2ROMihSLngpOwogICAgICByZXR1cm4gdiA9PT0gcjsKICAgIH0KICAgIHJldHVybiB7CiAgICAgIENVUlZFLAogICAgICBnZXRQdWJsaWNLZXksCiAgICAgIGdldFNoYXJlZFNlY3JldCwKICAgICAgc2lnbjogc2lnbjIsCiAgICAgIHZlcmlmeSwKICAgICAgUHJvamVjdGl2ZVBvaW50OiBQb2ludDIsCiAgICAgIFNpZ25hdHVyZSwKICAgICAgdXRpbHMKICAgIH07CiAgfQogIGZ1bmN0aW9uIFNXVUZwU3FydFJhdGlvKEZwMiwgWikgewogICAgY29uc3QgcSA9IEZwMi5PUkRFUjsKICAgIGxldCBsID0gXzBuNTsKICAgIGZvciAobGV0IG8gPSBxIC0gXzFuNTsgbyAlIF8ybjQgPT09IF8wbjU7IG8gLz0gXzJuNCkKICAgICAgbCArPSBfMW41OwogICAgY29uc3QgYzEgPSBsOwogICAgY29uc3QgXzJuX3Bvd19jMV8xID0gXzJuNCA8PCBjMSAtIF8xbjUgLSBfMW41OwogICAgY29uc3QgXzJuX3Bvd19jMSA9IF8ybl9wb3dfYzFfMSAqIF8ybjQ7CiAgICBjb25zdCBjMiA9IChxIC0gXzFuNSkgLyBfMm5fcG93X2MxOwogICAgY29uc3QgYzMgPSAoYzIgLSBfMW41KSAvIF8ybjQ7CiAgICBjb25zdCBjNCA9IF8ybl9wb3dfYzEgLSBfMW41OwogICAgY29uc3QgYzUgPSBfMm5fcG93X2MxXzE7CiAgICBjb25zdCBjNiA9IEZwMi5wb3coWiwgYzIpOwogICAgY29uc3QgYzcgPSBGcDIucG93KFosIChjMiArIF8xbjUpIC8gXzJuNCk7CiAgICBsZXQgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgbGV0IHR2MSA9IGM2OwogICAgICBsZXQgdHYyID0gRnAyLnBvdyh2LCBjNCk7CiAgICAgIGxldCB0djMgPSBGcDIuc3FyKHR2Mik7CiAgICAgIHR2MyA9IEZwMi5tdWwodHYzLCB2KTsKICAgICAgbGV0IHR2NSA9IEZwMi5tdWwodSwgdHYzKTsKICAgICAgdHY1ID0gRnAyLnBvdyh0djUsIGMzKTsKICAgICAgdHY1ID0gRnAyLm11bCh0djUsIHR2Mik7CiAgICAgIHR2MiA9IEZwMi5tdWwodHY1LCB2KTsKICAgICAgdHYzID0gRnAyLm11bCh0djUsIHUpOwogICAgICBsZXQgdHY0ID0gRnAyLm11bCh0djMsIHR2Mik7CiAgICAgIHR2NSA9IEZwMi5wb3codHY0LCBjNSk7CiAgICAgIGxldCBpc1FSID0gRnAyLmVxbCh0djUsIEZwMi5PTkUpOwogICAgICB0djIgPSBGcDIubXVsKHR2MywgYzcpOwogICAgICB0djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgdHYzID0gRnAyLmNtb3YodHYyLCB0djMsIGlzUVIpOwogICAgICB0djQgPSBGcDIuY21vdih0djUsIHR2NCwgaXNRUik7CiAgICAgIGZvciAobGV0IGkgPSBjMTsgaSA+IF8xbjU7IGktLSkgewogICAgICAgIGxldCB0djUyID0gaSAtIF8ybjQ7CiAgICAgICAgdHY1MiA9IF8ybjQgPDwgdHY1MiAtIF8xbjU7CiAgICAgICAgbGV0IHR2djUgPSBGcDIucG93KHR2NCwgdHY1Mik7CiAgICAgICAgY29uc3QgZTEgPSBGcDIuZXFsKHR2djUsIEZwMi5PTkUpOwogICAgICAgIHR2MiA9IEZwMi5tdWwodHYzLCB0djEpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djEpOwogICAgICAgIHR2djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgICB0djMgPSBGcDIuY21vdih0djIsIHR2MywgZTEpOwogICAgICAgIHR2NCA9IEZwMi5jbW92KHR2djUsIHR2NCwgZTEpOwogICAgICB9CiAgICAgIHJldHVybiB7IGlzVmFsaWQ6IGlzUVIsIHZhbHVlOiB0djMgfTsKICAgIH07CiAgICBpZiAoRnAyLk9SREVSICUgXzRuMiA9PT0gXzNuMikgewogICAgICBjb25zdCBjMTIgPSAoRnAyLk9SREVSIC0gXzNuMikgLyBfNG4yOwogICAgICBjb25zdCBjMjIgPSBGcDIuc3FydChGcDIubmVnKFopKTsKICAgICAgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgICBsZXQgdHYxID0gRnAyLnNxcih2KTsKICAgICAgICBjb25zdCB0djIgPSBGcDIubXVsKHUsIHYpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djIpOwogICAgICAgIGxldCB5MSA9IEZwMi5wb3codHYxLCBjMTIpOwogICAgICAgIHkxID0gRnAyLm11bCh5MSwgdHYyKTsKICAgICAgICBjb25zdCB5MiA9IEZwMi5tdWwoeTEsIGMyMik7CiAgICAgICAgY29uc3QgdHYzID0gRnAyLm11bChGcDIuc3FyKHkxKSwgdik7CiAgICAgICAgY29uc3QgaXNRUiA9IEZwMi5lcWwodHYzLCB1KTsKICAgICAgICBsZXQgeSA9IEZwMi5jbW92KHkyLCB5MSwgaXNRUik7CiAgICAgICAgcmV0dXJuIHsgaXNWYWxpZDogaXNRUiwgdmFsdWU6IHkgfTsKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBzcXJ0UmF0aW87CiAgfQogIGZ1bmN0aW9uI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uMSBERVIgZW5jb2RpbmcgdXRpbHMKICAgICAgICBFcnI6IGNsYXNzIERFUkVyciBleHRlbmRzIEVycm9yIHsKICAgICAgICAgIGNvbnN0cnVjdG9yKG0gPSAiIikgewogICAgICAgICAgICBzdXBlcihtKTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIEJhc2ljIGJ1aWxkaW5nIGJsb2NrIGlzIFRMViAoVGFnLUxlbmd0aC1WYWx1ZSkKICAgICAgICBfdGx2OiB7CiAgICAgICAgICBlbmNvZGU6ICh0YWcsIGRhdGEpID0+IHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgaWYgKHRhZyA8IDAgfHwgdGFnID4gMjU2KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZW5jb2RlOiB3cm9uZyB0YWciKTsKICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoICYgMSkKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogdW5wYWRkZWQgZGF0YSIpOwogICAgICAgICAgICBjb25zdCBkYXRhTGVuID0gZGF0YS5sZW5ndGggLyAyOwogICAgICAgICAgICBjb25zdCBsZW4gPSBudW1iZXJUb0hleFVucGFkZGVkKGRhdGFMZW4pOwogICAgICAgICAgICBpZiAobGVuLmxlbmd0aCAvIDIgJiAxMjgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5lbmNvZGU6IGxvbmcgZm9ybSBsZW5ndGggdG9vIGJpZyIpOwogICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBkYXRhTGVuID4gMTI3ID8gbnVtYmVyVG9IZXhVbnBhZGRlZChsZW4ubGVuZ3RoIC8gMiB8IDEyOCkgOiAiIjsKICAgICAgICAgICAgcmV0dXJuIGAke251bWJlclRvSGV4VW5wYWRkZWQodGFnKX0ke2xlbkxlbn0ke2xlbn0ke2RhdGF9YDsKICAgICAgICAgIH0sCiAgICAgICAgICAvLyB2IC0gdmFsdWUsIGwgLSBsZWZ0IGJ5dGVzICh1bnBhcnNlZCkKICAgICAgICAgIGRlY29kZSh0YWcsIGRhdGEpIHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgIGlmICh0YWcgPCAwIHx8IHRhZyA+IDI1NikKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogd3JvbmcgdGFnIik7CiAgICAgICAgICAgIGlmIChkYXRhLmxlbmd0aCA8IDIgfHwgZGF0YVtwb3MrK10gIT09IHRhZykKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZTogd3JvbmcgdGx2Iik7CiAgICAgICAgICAgIGNvbnN0IGZpcnN0ID0gZGF0YVtwb3MrK107CiAgICAgICAgICAgIGNvbnN0IGlzTG9uZyA9ICEhKGZpcnN0ICYgMTI4KTsKICAgICAgICAgICAgbGV0IGxlbmd0aCA9IDA7CiAgICAgICAgICAgIGlmICghaXNMb25nKQogICAgICAgICAgICAgIGxlbmd0aCA9IGZpcnN0OwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBmaXJzdCAmIDEyNzsKICAgICAgICAgICAgICBpZiAoIWxlbkxlbikKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBpbmRlZmluaXRlIGxlbmd0aCBub3Qgc3VwcG9ydGVkIik7CiAgICAgICAgICAgICAgaWYgKGxlbkxlbiA+IDQpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogYnl0ZSBsZW5ndGggaXMgdG9vIGJpZyIpOwogICAgICAgICAgICAgIGNvbnN0IGxlbmd0aEJ5dGVzID0gZGF0YS5zdWJhcnJheShwb3MsIHBvcyArIGxlbkxlbik7CiAgICAgICAgICAgICAgaWYgKGxl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UgZW1wdHk6CiAgICAgICAgLy8gLSBhZGQgemVybyBieXRlIGlmIGV4aXN0cwogICAgICAgIC8vIC0gaWYgbmV4dCBieXRlIGRvZXNuJ3QgaGF2ZSBhIGZsYWcsIGxlYWRpbmcgemVybyBpcyBub3QgYWxsb3dlZCAobWluaW1hbCBlbmNvZGluZykKICAgICAgICBfaW50OiB7CiAgICAgICAgICBlbmNvZGUobnVtMikgewogICAgICAgICAgICBjb25zdCB7IEVycjogRSB9ID0gREVSOwogICAgICAgICAgICBpZiAobnVtMiA8IF8wbjUpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoImludGVnZXI6IG5lZ2F0aXZlIGludGVnZXJzIGFyZSBub3QgYWxsb3dlZCIpOwogICAgICAgICAgICBsZXQgaGV4ID0gbnVtYmVyVG9IZXhVbnBhZGRlZChudW0yKTsKICAgICAgICAgICAgaWYgKE51bWJlci5wYXJzZUludChoZXhbMF0sIDE2KSAmIDgpCiAgICAgICAgICAgICAgaGV4ID0gIjAwIiArIGhleDsKICAgICAgICAgICAgaWYgKGhleC5sZW5ndGggJiAxKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ1bmV4cGVjdGVkIGFzc2VydGlvbiIpOwogICAgICAgICAgICByZXR1cm4gaGV4OwogICAgICAgICAgfSwKICAgICAgICAgIGRlY29kZShkYXRhKSB7CiAgICAgICAgICAgIGNvbnN0IHsgRXJyOiBFIH0gPSBERVI7CiAgICAgICAgICAgIGlmIChkYXRhWzBdICYgMTI4KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJJbnZhbGlkIHNpZ25hdHVyZSBpbnRlZ2VyOiBuZWdhdGl2ZSIpOwogICAgICAgICAgICBpZiAoZGF0YVswXSA9PT0gMCAmJiAhKGRhdGFbMV0gJiAxMjgpKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJJbnZhbGlkIHNpZ25hdHVyZSBpbnRlZ2VyOiB1bm5lY2Vzc2FyeSBsZWFkaW5nIHplcm8iKTsKICA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ucywgewogICAgICBEU1Q6ICJzdHJpbmdPclVpbnQ4QXJyYXkiLAogICAgICBwOiAiYmlnaW50IiwKICAgICAgbTogImlzU2FmZUludGVnZXIiLAogICAgICBrOiAiaXNTYWZlSW50ZWdlciIsCiAgICAgIGhhc2g6ICJoYXNoIgogICAgfSk7CiAgICBjb25zdCB7IHAsIGssIG0sIGhhc2g6IGhhc2gzLCBleHBhbmQsIERTVDogX0RTVCB9ID0gb3B0aW9uczsKICAgIGFieXRlcyhtc2cpOwogICAgYW51bShjb3VudCk7CiAgICBjb25zdCBEU1QgPSB0eXBlb2YgX0RTVCA9PT0gInN0cmluZyIgPyB1dGY4VG9CeXRlczIoX0RTVCkgOiBfRFNUOwogICAgY29uc3QgbG9nMnAgPSBwLnRvU3RyaW5nKDIpLmxlbmd0aDsKICAgIGNvbnN0IEwgPSBNYXRoLmNlaWwoKGxvZzJwICsgaykgLyA4KTsKICAgIGNvbnN0IGxlbl9pbl9ieXRlcyA9IGNvdW50ICogbSAqIEw7CiAgICBsZXQgcHJiOwogICAgaWYgKGV4cGFuZCA9PT0gInhtZCIpIHsKICAgICAgcHJiID0gZXhwYW5kX21lc3NhZ2VfeG1kKG1zZywgRFNULCBsZW5faW5fYnl0ZXMsIGhhc2gzKTsKICAgIH0gZWxzZSBpZiAoZXhwYW5kID09PSAieG9mIikgewogICAgICBwcmIgPSBleHBhbmRfbWVzc2FnZV94b2YobXNnLCBEU1QsIGxlbl9pbl9ieXRlcywgaywgaGFzaDMpOwogICAgfSBlbHNlIGlmIChleHBhbmQgPT09ICJfaW50ZXJuYWxfcGFzcyIpIHsKICAgICAgcHJiID0gbXNnOwogICAgfSBlbHNlIHsKICAgICAgdGhyb3cgbmV3IEVycm9yKCdleHBhbmQgbXVzdCBiZSAieG1kIiBvciAieG9mIicpOwogICAgfQogICAgY29uc3QgdSA9IG5ldyBBcnJheShjb3VudCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyBpKyspIHsKICAgICAg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jcDI1NmsxTjsKICAgICAgICAgICAgY29uc3QgYTEgPSBCaWdJbnQoIjB4MzA4NmQyMjFhN2Q0NmJjZGU4NmM5MGU0OTI4NGViMTUiKTsKICAgICAgICAgICAgY29uc3QgYjEgPSAtXzFuNiAqIEJpZ0ludCgiMHhlNDQzN2VkNjAxMGU4ODI4NmY1NDdmYTkwYWJmZTRjMyIpOwogICAgICAgICAgICBjb25zdCBhMiA9IEJpZ0ludCgiMHgxMTRjYTUwZjdhOGUyZjNmNjU3YzExMDhkOWQ0NGNmZDgiKTsKICAgICAgICAgICAgY29uc3QgYjIgPSBhMTsKICAgICAgICAgICAgY29uc3QgUE9XXzJfMTI4ID0gQmlnSW50KCIweDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMCIpOwogICAgICAgICAgICBjb25zdCBjMSA9IGRpdk5lYXJlc3QoYjIgKiBrLCBuKTsKICAgICAgICAgICAgY29uc3QgYzIgPSBkaXZOZWFyZXN0KC1iMSAqIGssIG4pOwogICAgICAgICAgICBsZXQgazEgPSBtb2QoayAtIGMxICogYTEgLSBjMiAqIGEyLCBuKTsKICAgICAgICAgICAgbGV0IGsyID0gbW9kKC1jMSAqIGIxIC0gYzIgKiBiMiwgbik7CiAgICAgICAgICAgIGNvbnN0IGsxbmVnID0gazEgPiBQT1dfMl8xMjg7CiAgICAgICAgICAgIGNvbnN0IGsybmVnID0gazIgPiBQT1dfMl8xMjg7CiAgICAgICAgICAgIGlmIChrMW5lZykKICAgICAgICAgICAgICBrMSA9IG4gLSBrMTsKICAgICAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgICAgIGsyID0gbiAtIGsyOwogICAgICAgICAgICBpZiAoazEgPiBQT1dfMl8xMjggfHwgazIgPiBQT1dfMl8xMjgpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInNwbGl0U2NhbGFyOiBFbmRvbW9ycGhpc20gZmFpbGVkLCBrPSIgKyBrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4geyBrMW5lZywgazEsIGsybmVnLCBrMiB9OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSwgc2hhMjU2KTsKICAgICAgXzBuNiA9IEJpZ0ludCgwKTsKICAgICAgVEFHR0VEX0hBU0hfUFJFRklYRVMgPSB7fTsKICAgICAgcG9pbnRUb0J5dGVzID0gKHBvaW50KSA9PiBwb2ludC50b1Jhd0J5dGVzKHRydWUpLnNsaWNlKDEpOwogICAgICBudW1UbzMyYiA9IChuKSA9PiBudW1iZXJUb0J5dGVzQkUobiwgMzIpOwogICAgICBtb2RQID0gKHgpID0+IG1vZCh4LCBzZWNwMjU2azFQKTsKICAgICAgbW9kTiA9ICh4KSA9PiBtb2QoeCwgc2VjcDI1NmsxTik7CiAgICAgIFBvaW50ID0gc2VjcDI1NmsxLlByb2plY3RpdmVQb2ludDsKICAgICAgR211bEFkZCA9IChRLCBhLCBiKSA9PiBQb2ludC5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFEsIGEsIGIpOwogICAgICBudW0gPSBieXRlc1RvTnVtYmVyQkU7CiAgICAgIHNjaG5vcnIgPSAvKiBAX19QVVJFX18gKi8gKCgpID0+ICh7CiAgICAgICAgZ2V0UHVibGljS2V5OiBzY2hub3JyR2V0UHVibGljS2V5LAogICAgICAgIHNpZ246IHNjaG5vcnJTaWduLAogICAgICAgIHZlcmlmeTogc2Nobm9yclZlcmlmeSwKICAgICAgICB1dGlsczogewogICAgICAgICAgcmFuZG9tUHJpdmF0ZUtleTogc2VjcDI1NmsxLnV0aWxzLnJhbmRvbVByaXZhdGVLZXksCiAgICAgICAgICBsaWZ0X3gsCiAgICAgICAgICBwb2ludFRvQnl0ZXMsCiAgICAgICAgICBudW1iZXJUb0J5dGVzQkUsCiAgICAgICAgICBieXRlc1RvTnVtYmVyQkUsCiAgICAgICAgICB0YWdnZWRIYXNoLAogICAgICAgICAgbW9kCiAgICAgICAgfQogICAgICB9KSkoKTsKICAgICAg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bWF4VWludDEwNCwgbWF4VWludDExMiwgbWF4VWludDEyMCwgbWF4VWludDEyOCwgbWF4VWludDEzNiwgbWF4VWludDE0NCwgbWF4VWludDE1MiwgbWF4VWludDE2MCwgbWF4VWludDE2OCwgbWF4VWludDE3NiwgbWF4VWludDE4NCwgbWF4VWludDE5MiwgbWF4VWludDIwMCwgbWF4VWludDIwOCwgbWF4VWludDIxNiwgbWF4VWludDIyNCwgbWF4VWludDIzMiwgbWF4VWludDI0MCwgbWF4VWludDI0OCwgbWF4VWludDI1NjsKICB2YXIgaW5pdF9udW1iZXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NvbnN0YW50cy9udW1iZXIuanMiKCkgewogICAgICBtYXhJbnQ4ID0gMm4gKiogKDhuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDE2ID0gMm4gKiogKDE2biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQyNCA9IDJuICoqICgyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MzIgPSAybiAqKiAoMzJuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDQwID0gMm4gKiogKDQwbiAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ0OCA9IDJuICoqICg0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50NTYgPSAybiAqKiAoNTZuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDY0ID0gMm4gKiogKDY0biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ3MiA9IDJuICoqICg3Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50ODAgPSAybiAqKiAoODBuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDg4ID0gMm4gKiogKDg4biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ5NiA9IDJuICoqICg5Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTA0ID0gMm4gKiogKDEwNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTEyID0gMm4gKiogKDExMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTIwID0gMm4gKiogKDEyMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTI4ID0gMm4gKiogKDEyOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTM2ID0gMm4gKiogKDEzNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTQ0ID0gMm4gKiogKDE0NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTUyID0gMm4gKiogKDE1Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTYwID0gMm4gKiogKDE2MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTY4ID0gMm4gKiogKDE2OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTc2ID0gMm4gKiogKDE3Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTg0ID0gMm4gKiogKDE4NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTkyID0gMm4gKiogKDE5Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjAwID0gMm4gKiogKDIwMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjA4ID0gMm4gKiogKDIwOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjE2ID0gMm4gKiogKDIxNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjI0ID0gMm4gKiogKDIyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjMyID0gMm4gKiogKDIzMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQwID0gMm4gKiogKDI0MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQ4ID0gMm4gKiogKDI0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjU2ID0gMm4gKiogKDI1Nm4gLSAxbikgLSAxbjsKICAgICAgbWluSW50OCA9IC0oMm4gKiogKDhuIC0gMW4pKTsKICAgICAgbWluSW50MTYgPSAtKDJuICoqICgxNm4gLSAxbikpOwogICAgICBtaW5JbnQyNCA9IC0oMm4gKiogKDI0biAtIDFuKSk7CiAgICAgIG1pbkludDMyID0gLSgybiAqKiAoMzJuIC0gMW4pKTsKICAgICAgbWluSW50NDAgPSAtKDJuICoqICg0MG4gLSAxbikpOwogICAgICBtaW5JbnQ0OCA9IC0oMm4gKiogKDQ4biAtIDFuKSk7CiAgICAgIG1pbkludDU2ID0gLSgybiAqKiAoNTZuIC0gMW4pKTsKICAgICAgbWluSW50NjQgPSAtKDJuICoqICg2NG4gLSAxbikpOwogICAgICBtaW5JbnQ3MiA9IC0oMm4gKiogKDcybiAtIDFuKSk7CiAgICAgIG1pbkludDgwID0gLSgybiAqKiAoODBuIC0gMW4pKTsKICAgICAgbWluSW50ODggPSAtKDJuICoqICg4OG4gLSAxbikpOwogICAgICBtaW5JbnQ5NiA9IC0oMm4gKiogKDk2biAtIDFuKSk7CiAgICAgIG1pbkludDEwNCA9IC0oMm4gKiogKDEwNG4gLSAxbikpOwogICAgICBtaW5JbnQxMTIgPSAtKDJuICoqICgxMTJuIC0gMW4pKTsKICAgICAgbWluSW50MTIwID0gLSgybiAqKiAoMTIwbiAtIDFuKSk7CiAgICAgIG1pbkludDEyOCA9IC0oMm4gKiogKDEyOG4gLSAxbikpOwogICAgICBtaW5JbnQxMzYgPSAtKDJuICoqICgxMzZuIC0gMW4pKTsKICAgICAgbWluSW50MTQ0ID0gLSgybiAqKiAoMTQ0biAtIDFuKSk7CiAgICAgIG1pbkludDE1MiA9IC0oMm4gKiogKDE1Mm4gLSAxbikpOwogICAgICBtaW5JbnQxNjAgPSAtKDJuICoqICgxNjBuIC0gMW4pKTsKICAgICAgbWluSW50MTY4ID0gLSgybiAqKiAoMTY4biAtIDFuKSk7CiAgICAgIG1pbkludDE3NiA9IC0oMm4gKiogKDE3Nm4gLSAxbikpOwogICAgICBtaW5JbnQxODQgPSAtKDJuICoqICgxODRuIC0gMW4pKTsKICAgICAgbWluSW50MTkyID0gLSgybiAqKiAoMTkybiAtIDFuKSk7CiAgICAgIG1pbkludDIwMCA9IC0oMm4gKiogKDIwMG4gLSAxbikpOwogICAgICBtaW5JbnQyMDggPSAtKDJuICoqICgyMDhuIC0gMW4pKTsKICAgICAgbWluSW50MjE2ID0gLSgybiAqKiAoMjE2biAtIDFuKSk7CiAgICAgIG1pbkludDIyNCA9IC0oMm4gKiogKDIyNG4gLSAxbikpOwogICAgICBtaW5JbnQyMzIgPSAtKDJuICoqICgyMzJuIC0gMW4pKTsKICAgICAgbWluSW50MjQwID0gLSgybiAqKiAoMjQwbiAtIDFuKSk7CiAgICAgIG1pbkludDI0OCA9IC0oMm4gKiogKDI0OG4gLSAxbikpOwogICAgICBtaW5JbnQyNTYgPSAtKDJuICoqICgyNTZuIC0gMW4pKTsKICAgICAgbWF4VWludDggPSAybiAqKiA4biAtIDFuOwogICAgICBtYXhVaW50MTYgPSAybiAqKiAxNm4gLSAxbjsKICAgICAgbWF4VWludDI0ID0gMm4gKiogMjRuIC0gMW47CiAgICAgIG1heFVpbnQzMiA9IDJuICoqIDMybiAtIDFuOwogICAgICBtYXhVaW50NDAgPSAybiAqKiA0MG4gLSAxbjsKICAgICAgbWF4VWludDQ4ID0gMm4gKiogNDhuIC0gMW47CiAgICAgIG1heFVpbnQ1NiA9IDJuICoqIDU2biAtIDFuOwogICAgICBtYXhVaW50NjQgPSAybiAqKiA2NG4gLSAxbjsKICAgICAgbWF4VWludDcyID0gMm4gKiogNzJuIC0gMW47CiAgICAgIG1heFVpbnQ4MCA9IDJuICoqIDgwbiAtIDFuOwogICAgICBtYXhVaW50ODggPSAybiAqKiA4OG4gLSAxbjsKICAgICAgbWF4VWludDk2ID0gMm4gKiogOTZuIC0gMW47CiAgICAgIG1heFVpbnQxMDQgPSAybiAqKiAxMDRuIC0gMW47CiAgICAgIG1heFVpbnQxMTIgPSAybiAqKiAxMTJuIC0gMW47CiAgICAgIG1heFVpbnQ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21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJ0YXJnZXQiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJhbGxvd0ZhaWx1cmUiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJjYWxsRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJjYWxscyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiYWdncmVnYXRlMyIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdWNjZXNzIiwKICAgICAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJyZXR1cm5EYXRhIiwKICAgICAgICAgICAgICB0eXBlOiAidHVwbGVbXSIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0KICAgICAgXTsKICAgICAgdW5pdmVyc2FsUmVzb2x2ZXJFcnJvcnMgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG5hbWU6ICJSZXNvbHZlck5vdEZvdW5kIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBuYW1lOiAiUmVzb2x2ZXJXaWxkY2FyZE5vdFN1cHBvcnRlZCIsCiAgICAgICAgICB0eXBlOiAiZXJyb3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyTm90Q29udHJhY3QiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyRXJyb3IiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdGF0dXMiLAogICAgICAgICAgICAgICAgICB0eXBlOiAidWludDE2IgogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgbmFtZTogIm1lc3NhZ2UiLAogICAgICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgbmFtZTogImVycm9ycyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiSHR0cEVycm9yIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmVzb2x2ZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmVzb2x2ZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlcyIgfSwKICAgICAgICAgICAgeyBuYW1lOiAiZGF0YSIsIHR5cGU6ICJieXRlcyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJyZXNvbHZlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7IG5hbWU6ICJuYW1lIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJkYXRhIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJnYXRld2F5cyIsIHR5cGU6ICJzdHJpbmdbXSIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmV2ZXJzZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmV2ZXJzZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFt7IHR5cGU6ICJieXRlcyIsIG5hbWU6ICJyZXZlcnNlTmFtZSIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogInN0cmluZyIsIG5hbWU6ICJyZXNvbHZlZE5hbWUiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmVzb2x2ZWRBZGRyZXNzIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJldmVyc2VSZXNvbHZlciIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlciIgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgbmFtZTogInJldmVyc2UiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogImJ5dGVzIiwgbmFtZTogInJldmVyc2VOYW1lIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJzdHJpbmdbXSIsIG5hbWU6ICJnYXRld2F5cyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyB0eXBlOiAic3RyaW5nIiwgbmFtZTogInJlc29sdmVkTmFtZSIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlZEFkZHJlc3MiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmV2ZXJzZVJlc29sdmVyIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJlc29sdmVyIiB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICB0ZXh0UmVzb2x2ZXJBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgbmFtZTogInRleHQiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfSwKICAgICAgICAgICAgeyBuYW1lOiAia2V5IiwgdHlwZTogInN0cmluZyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgIH0KICAgICAgXTsKICAgICAgYWRkcmVzc1Jlc29sdmVyQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJhZGRyIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbeyBuYW1lOiAiIiwgdHlwZTogImFkZHJlc3MiIH1dCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAiYWRkciIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJjb2luVHlwZSIsIHR5cGU6ICJ1aW50MjU2IiB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJieXRlcyIgfV0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFNpZ25hdHVyZVZhbGlkYXRvckFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiY29uc3RydWN0b3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiaXNWYWxpZFNpZyIKICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzIwQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic3ltYm9sIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXIiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICBlcmMyMEFiaV9ieXRlczMyID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJieXRlczMyIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYnl0ZXMzMiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0b3RhbFN1cHBseSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmVjaXBpZW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhbW91bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzcyMUFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZXZlbnQiLAogICAgICAgICAgbmFtZTogIkFwcHJvdmFsIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImV2ZW50IiwKICAgICAgICAgIG5hbWU6ICJBcHByb3ZhbEZvckFsbCIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm9wZXJhdG9yIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhcHByb3ZlZCIsCiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRva2VuSWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImFwcHJvdmUiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAicGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiZ2V0QXBwcm92ZWQiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImlzQXBwcm92ZWRGb3JBbGwiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAibmFtZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogIm93bmVyT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic2FmZVRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJwYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImZyb20iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNhZmVUcmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiaWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImRhdGEiLAogICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNldEFwcHJvdmFsRm9yQWxsIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFwcHJvdmVkIiwKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImluZGV4IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJpbmRleCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG9rZW5JZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG9rZW5VUkkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRva2VJZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbXQogICAgICAgIH0KICAgICAgXTsKICAgICAgZXJjNDYyNkFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiRGVwb3NpdCIsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiV2l0aGRyYXciLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImFsbG93YW5jZSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJhcHByb3ZlIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogImFzc2V0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldFRva2VuQWRkcmVzcyIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJjb252ZXJ0VG9Bc3NldHMiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiY29udmVydFRvU2hhcmVzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJkZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJjYWxsZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heERlcG9zaXQiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm1heEFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImNhbGxlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAibWF4TWludCIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFJlZGVlbSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFdpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJtYXhBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJtaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdEZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdNaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdSZWRlZW0iLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicHJldmlld1dpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicmVkZWVtIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsQXNzZXRzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b3RhbE1hbmFnZWRBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsU3VwcGx5IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiZnJvbSIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG8iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAid2l0aGRyYXciLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICA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tjaGFpbi5pZH0gXHUyMDEzICR7Y2hhaW4ubmFtZX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDaGFpbk1pc21hdGNoRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIENoYWluTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICAgICAgICJObyBjaGFpbiB3YXMgcHJvdmlkZWQgdG8gdGhlIHJlcXVlc3QuIiwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgY2hhaW4gd2l0aCB0aGUgYGNoYWluYCBhcmd1bWVudCBvbiB0aGUgQWN0aW9uLCBvciBieSBzdXBwbHlpbmcgYSBgY2hhaW5gIHRvIFdhbGxldENsaWVudC4iCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkNoYWluTm90Rm91bmRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ2xpZW50Q2hhaW5Ob3RDb25maWd1cmVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoIk5vIGNoYWluIHdhcyBwcm92aWRlZCB0byB0aGUgQ2xpZW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIkNsaWVudENoYWluTm90Q29uZmlndXJlZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkQ2hhaW5JZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IGNoYWluSWQgfSkgewogICAgICAgICAgc3VwZXIodHlwZW9mIGNoYWluSWQgPT09ICJudW1iZXIiID8gYENo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MKHMpOiIsCiAgICAgICAgICAgICAgICAuLi51cmxzLm1hcCgodXJsKSA9PiBgICAgICR7Z2V0VXJsKHVybCl9YCkKICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIGAgIFNlbmRlcjogJHtzZW5kZXJ9YCwKICAgICAgICAgICAgICBgICBEYXRhOiAke2RhdGF9YCwKICAgICAgICAgICAgICBgICBDYWxsYmFjayBzZWxlY3RvcjogJHtjYWxsYmFja1NlbGVjdG9yfWAsCiAgICAgICAgICAgICAgYCAgRXh0cmEgZGF0YTogJHtleHRyYURhdGF9YAogICAgICAgICAgICBdLmZsYXQoKSwKICAgICAgICAgICAgbmFtZTogIk9mZmNoYWluTG9va3VwRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwUmVzcG9uc2VNYWxmb3JtZWRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyByZXN1bHQsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiT2ZmY2hhaW4gZ2F0ZXdheSByZXNwb25zZSBpcyBtYWxmb3JtZWQuIFJlc3BvbnNlIGRhdGEgbXVzdCBiZSBhIGhleCB2YWx1ZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBHYXRld2F5IFVSTDogJHtnZXRVcmwodXJsKX1gLAogICAgICAgICAgICAgIGBSZXNwb25zZTogJHtzdHJpbmdpZnkocmVzdWx0KX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cFJlc3BvbnNlTWFsZm9ybWVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwU2VuZGVyTWlzbWF0Y2hFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAg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ICAgICAgIHJlc3VsdCA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICB9CiAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgZXJyb3IgPSBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgIGRldGFpbHM6IHJlc3VsdD8uZXJyb3IgPyBzdHJpbmdpZnkocmVzdWx0LmVycm9yKSA6IHJlc3BvbnNlLnN0YXR1c1RleHQsCiAgICAgICAgICAgIGhlYWRlcnM6IHJlc3BvbnNlLmhlYWRlcnMsCiAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICghaXNIZXgocmVzdWx0KSkgewogICAgICAgICAgZXJyb3IgPSBuZXcgT2ZmY2hhaW5Mb29rdXBSZXNwb25zZU1hbGZvcm1lZEVycm9yKHsKICAgICAgICAgICAgcmVzdWx0LAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgIGVycm9yID0gbmV3IEh0dHBSZXF1ZXN0RXJyb3IoewogICAgICAgICAgYm9keSwKICAgICAgICAgIGRldGFpbHM6IGVyci5tZXNzYWdlLAogICAgICAgICAgdXJsCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIHRocm93IGVycm9yOwogIH0KICB2YXIgb2ZmY2hhaW5Mb29rdXBTaWduYXR1cmUsIG9mZmNoYWluTG9va3VwQWJpSXRlbTsKICB2YXIgaW5pdF9jY2lwMiA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2NpcC5qcyIoKSB7CiAgICAgIGluaXRfY2FsbCgpOwogICAgICBpbml0X2NjaXAoKTsKICAgICAgaW5pdF9yZXF1ZXN0KCk7CiAgICAgIGluaXRfZGVjb2RlRXJyb3JSZXN1bHQoKTsKICAgICAgaW5pdF9lbmNvZGVBYmlQYXJhbWV0ZXJzKCk7CiAgICAgIGluaXRfaXNBZGRyZXNzRXF1YWwoKTsKICAgICAgaW5pdF9jb25jYXQoKTsKICAgICAgaW5pdF9pc0hleCgpOwogICAgICBpbml0X3N0cmluZ2lmeSgpOwogICAgICBvZmZjaGFpbkxvb2t1cFNpZ25hdHVyZSA9ICIweDU1NmYxODMwIjsKICAgICAgb2ZmY2hhaW5Mb29rdXBBYmlJdGVtID0gewogICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cCIsCiAgICAgICAgdHlwZTogImVycm9yIiwKICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInVybHMiLAogICAgICAgICAgICB0eXBlOiAic3RyaW5nW10iCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbERhdGEiLAogICAgICAgICAgICB0eXBlOiAiYnl0ZXMiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbGJhY2tGdW5jdGlvbiIsCiAgICAgICAgICAgIHR5cGU6ICJieXRlczQiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiZXh0cmFEYXRhIiwKICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgfQogICAgICAgIF0KICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVs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GxBZGRyZXNzKSB7CiAgICAgIGlmICghY2xpZW50LmNoYWluKQogICAgICAgIHRocm93IG5ldyBDbGllbnRDaGFpbk5vdENvbmZpZ3VyZWRFcnJvcigpOwogICAgICBtdWx0aWNhbGxBZGRyZXNzID0gZ2V0Q2hhaW5Db250cmFjdEFkZHJlc3MoewogICAgICAgIGJsb2NrTnVtYmVyLAogICAgICAgIGNoYWluOiBjbGllbnQuY2hhaW4sCiAgICAgICAgY29udHJhY3Q6ICJtdWx0aWNhbGwzIgogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGJsb2NrTnVtYmVySGV4ID0gYmxvY2tOdW1iZXIgPyBudW1iZXJUb0hleChibG9ja051bWJlcikgOiB2b2lkIDA7CiAgICBjb25zdCBibG9jayA9IGJsb2NrTnVtYmVySGV4IHx8IGJsb2NrVGFnOwogICAgY29uc3QgeyBzY2hlZHVsZSB9ID0gY3JlYXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICBpZDogYCR7Y2xpZW50LnVpZH0uJHtibG9ja31gLAogICAgICB3YWl0OiB3YWl0MiwKICAgICAgc2hvdWxkU3BsaXRCYXRjaChhcmdzMikgewogICAgICAgIGNvbnN0IHNpemUzID0gYXJnczIucmVkdWNlKChzaXplNCwgeyBkYXRhOiBkYXRhMiB9KSA9PiBzaXplNCArIChkYXRhMi5sZW5ndGggLSAyKSwgMCk7CiAgICAgICAgcmV0dXJuIHNpemUzID4gYmF0Y2hTaXplICogMjsKICAgICAgfSwKICAgICAgZm46IGFzeW5jIChyZXF1ZXN0cykgPT4gewogICAgICAgIGNvbnN0IGNhbGxzID0gcmVxdWVzdHMubWFwKChyZXF1ZXN0KSA9PiAoewogICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgY2FsbERhdGE6IHJlcXVlc3QuZGF0YSwKICAgICAgICAgIHRhcmdldDogcmVxdWVzdC50bwogICAgICAgIH0pKTsKICAgICAgICBjb25zdCBjYWxsZGF0YSA9IGVuY29kZUZ1bmN0aW9uRGF0YSh7CiAgICAgICAgICBhYmk6IG11bHRpY2FsbDNBYmksCiAgICAgICAgICBhcmdzOiBbY2FsbHNdLAogICAgICAgICAgZnVuY3Rpb25OYW1lOiAiYWdncmVnYXRlMyIKICAgICAgICB9KTsKICAgICAgICBjb25zdCBkYXRhMiA9IGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgIG1ldGhvZDogImV0aF9jYWxsIiwKICAgICAgICAgIHBhcmFtczogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgZGF0YTogY2FsbGRhdGEsCiAgICAgICAgICAgICAgdG86IG11bHRpY2FsbEFkZHJlc3MKICAgICAgICAgICAgfSwKICAgICAgICAgICAgYmxvY2sKICAgICAgICAgIF0KICAgICAgICB9KTsKICAgICAgICByZXR1cm4gZGVjb2RlRnVuY3Rpb25SZXN1bHQoewogICAgICAgICAgYWJpOiBtdWx0aWNhbGwzQWJpLAogICAgICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgICAgIGZ1bmN0aW9uTmFtZTogImFnZ3JlZ2F0ZTMiLAogICAgICAgICAgZGF0YTogZGF0YTIgfHwgIjB4IgogICAgICAgIH0pOwogICAgICB9CiAgICB9KTsKICAgIGNvbnN0IFt7IHJldHVybkRhdGEsIHN1Y2Nlc3MgfV0gPSBhd2FpdCBzY2hlZHVsZSh7IGRhdGEsIHRvIH0pOwogICAgaWYgKCFzdWNjZXNzKQogICAgICB0aHJvdyBuZXcgUmF3Q29udHJhY3RFcnJvcih7IGRhdGE6IHJldHVybkRhdGEgfSk7CiAgICBpZiAocmV0dXJuRGF0YSA9PT0gIjB4IikKICAgICAgcmV0dXJuIHsgZGF0YTogdm9pZCAwIH07CiAgICByZXR1cm4geyBkYXRhOiByZXR1cm5EYXRhIH07CiAgfQogIGZ1bmN0aW9uIHRvRGVwbG95bGVzc0NhbGxWaWFCeXRlY29kZURhdGEocGFyYW1ldGVycykgewogICAgY29uc3QgeyBjb2RlLCBkYXRhIH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YXhJbnQxMDQ6ICgpID0+IG1heEludDEwNCwKICAgIG1heEludDExMjogKCkgPT4gbWF4SW50MTEyLAogICAgbWF4SW50MTIwOiAoKSA9PiBtYXhJbnQxMjAsCiAgICBtYXhJbnQxMjg6ICgpID0+IG1heEludDEyOCwKICAgIG1heEludDEzNjogKCkgPT4gbWF4SW50MTM2LAogICAgbWF4SW50MTQ0OiAoKSA9PiBtYXhJbnQxNDQsCiAgICBtYXhJbnQxNTI6ICgpID0+IG1heEludDE1MiwKICAgIG1heEludDE2OiAoKSA9PiBtYXhJbnQxNiwKICAgIG1heEludDE2MDogKCkgPT4gbWF4SW50MTYwLAogICAgbWF4SW50MTY4OiAoKSA9PiBtYXhJbnQxNjgsCiAgICBtYXhJbnQxNzY6ICgpID0+IG1heEludDE3NiwKICAgIG1heEludDE4NDogKCkgPT4gbWF4SW50MTg0LAogICAgbWF4SW50MTkyOiAoKSA9PiBtYXhJbnQxOTIsCiAgICBtYXhJbnQyMDA6ICgpID0+IG1heEludDIwMCwKICAgIG1heEludDIwODogKCkgPT4gbWF4SW50MjA4LAogICAgbWF4SW50MjE2OiAoKSA9PiBtYXhJbnQyMTYsCiAgICBtYXhJbnQyMjQ6ICgpID0+IG1heEludDIyNCwKICAgIG1heEludDIzMjogKCkgPT4gbWF4SW50MjMyLAogICAgbWF4SW50MjQ6ICgpID0+IG1heEludDI0LAogICAgbWF4SW50MjQwOiAoKSA9PiBtYXhJbnQyNDAsCiAgICBtYXhJbnQyNDg6ICgpID0+IG1heEludDI0OCwKICAgIG1heEludDI1NjogKCkgPT4gbWF4SW50MjU2LAogICAgbWF4SW50MzI6ICgpID0+IG1heEludDMyLAogICAgbWF4SW50NDA6ICgpID0+IG1heEludDQwLAogICAgbWF4SW50NDg6ICgpID0+IG1heEludDQ4LAogICAgbWF4SW50NTY6ICgpID0+IG1heEludDU2LAogICAgbWF4SW50NjQ6ICgpID0+IG1heEludDY0LAogICAgbWF4SW50NzI6ICgpID0+IG1heEludDcyLAogICAgbWF4SW50ODogKCkgPT4gbWF4SW50OCwKICAgIG1heEludDgwOiAoKSA9PiBtYXhJbnQ4MCwKICAgIG1heEludDg4OiAoKSA9PiBtYXhJbnQ4OCwKICAgIG1heEludDk2OiAoKSA9PiBtYXhJbnQ5NiwKICAgIG1heFVpbnQxMDQ6ICgpID0+IG1heFVpbnQxMDQsCiAgICBtYXhVaW50MTEyOiAoKSA9PiBtYXhVaW50MTEyLAogICAgbWF4VWludDEyMDogKCkgPT4gbWF4VWludDEyMCwKICAgIG1heFVpbnQxMjg6ICgpID0+IG1heFVpbnQxMjgsCiAgICBtYXhVaW50MTM2OiAoKSA9PiBtYXhVaW50MTM2LAogICAgbWF4VWludDE0NDogKCkgPT4gbWF4VWludDE0NCwKICAgIG1heFVpbnQxNTI6ICgpID0+IG1heFVpbnQxNTIsCiAgICBtYXhVaW50MTY6ICgpID0+IG1heFVpbnQxNiwKICAgIG1heFVpbnQxNjA6ICgpID0+IG1heFVpbnQxNjAsCiAgICBtYXhVaW50MTY4OiAoKSA9PiBtYXhVaW50MTY4LAogICAgbWF4VWludDE3NjogKCkgPT4gbWF4VWludDE3NiwKICAgIG1heFVpbnQxODQ6ICgpID0+IG1heFVpbnQxODQsCiAgICBtYXhVaW50MTkyOiAoKSA9PiBtYXhVaW50MTkyLAogICAgbWF4VWludDIwMDogKCkgPT4gbWF4VWludDIwMCwKICAgIG1heFVpbnQyMDg6ICgpID0+IG1heFVpbnQyMDgsCiAgICBtYXhVaW50MjE2OiAoKSA9PiBtYXhVaW50MjE2LAogICAgbWF4VWludDIyNDogKCkgPT4gbWF4VWludDIyNCwKICAgIG1heFVpbnQyMzI6ICgpID0+IG1heFVpbnQyMzIsCiAgICBtYXhVaW50MjQ6ICgpID0+IG1heFVpbnQyNCwKICAgIG1heFVpbnQyNDA6ICgpID0+IG1heFVpbnQyNDAsCiAgICBtYXhVaW50MjQ4OiAoKSA9PiBtYXhVaW50MjQ4LAogICAgbWF4VWludDI1NjogKCkgPT4gbWF4VWludDI1NiwKICAgIG1heFVpbnQzMjogKCkgPT4gbWF4VWludDMyLAogICAgbWF4VWludDQwOiAoKSA9PiBtYXhVaW50NDAsCiAgICBtYXhVaW50NDg6ICgpID0+IG1heFVpbnQ0OCwKICAgIG1heFVpbnQ1NjogKCkgPT4gbWF4VWludDU2LAogICAgbWF4VWludDY0OiAoKSA9PiBtYXhVaW50NjQsCiAgICBtYXhVaW50NzI6ICgpID0+IG1heFVpbnQ3MiwKICAgIG1heFVpbnQ4OiAoKSA9PiBtYXhVaW50OCwKICAgIG1heFVpbnQ4MDogKCkgPT4gbWF4VWludDgwLAogICAgbWF4VWludDg4OiAoKSA9PiBtYXhVaW50ODgsCiAgICBtYXhVaW50OTY6ICgpID0+IG1heFVpbnQ5NiwKICAgIG1pbkludDEwNDogKCkgPT4gbWluSW50MTA0LAogICAgbWluSW50MTEyOiAoKSA9PiBtaW5JbnQxMTIsCiAgICBtaW5JbnQxMjA6ICgpID0+IG1pbkludDEyMCwKICAgIG1pbkludDEyODogKCkgPT4gbWluSW50MTI4LAogICAgbWluSW50MTM2OiAoKSA9PiBtaW5JbnQxMzYsCiAgICBtaW5JbnQxNDQ6ICgpID0+IG1pbkludDE0NCwKICAgIG1pbkludDE1MjogKCkgPT4gbWluSW50MTUyLAogICAgbWluSW50MTY6ICgpID0+IG1pbkludDE2LAogICAgbWluSW50MTYwOiAoKSA9PiBtaW5JbnQxNjAsCiAgICBtaW5JbnQxNjg6ICgpID0+IG1pbkludDE2OCwKICAgIG1pbkludDE3NjogKCkgPT4gbWluSW50MTc2LAogICAgbWluSW50MTg0OiAoKSA9PiBtaW5JbnQxODQsCiAgICBtaW5JbnQxOTI6ICgpID0+IG1pbkludDE5MiwKICAgIG1pbkludDIwMDogKCkgPT4gbWluSW50MjAwLAogICAgbWluSW50MjA4OiAoKSA9PiBtaW5JbnQyMDgsCiAgICBtaW5JbnQyMTY6ICgpID0+IG1pbkludDIxNiwKICAgIG1pbkludDIyNDogKCkgPT4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pY3QsIHRvQmxvY2sgfSA9IHBhcmFtZXRlcnM7CiAgICBjb25zdCBnZXRSZXF1ZXN0ID0gY3JlYXRlRmlsdGVyUmVxdWVzdFNjb3BlKGNsaWVudCwgewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIgogICAgfSk7CiAgICBjb25zdCB0b3BpY3MgPSBldmVudE5hbWUgPyBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lCiAgICB9KSA6IHZvaWQgMDsKICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgdG9waWNzCiAgICAgICAgfQogICAgICBdCiAgICB9KTsKICAgIHJldHVybiB7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lLAogICAgICBpZCwKICAgICAgcmVxdWVzdDogZ2V0UmVxdWVzdChpZCksCiAgICAgIHN0cmljdDogQm9vbGVhbihzdHJpY3QpLAogICAgICB0eXBlOiAiZXZlbnQiCiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL2VzdGltYXRlQ29udHJhY3RHYXMuanMKICBpbml0X3BhcnNlQWNjb3VudCgpOwogIGluaXRf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WxfZXN0aW1hdGVNYXhQcmlvcml0eUZlZVBlckdhcyhjbGllbnQsIGFyZ3MpIHsKICAgIGNvbnN0IHsgYmxvY2s6IGJsb2NrXywgY2hhaW4gPSBjbGllbnQuY2hhaW4sIHJlcXVlc3QgfSA9IGFyZ3MgfHwge307CiAgICB0cnkgewogICAgICBjb25zdCBtYXhQcmlvcml0eUZlZVBlckdhcyA9IGNoYWluPy5mZWVzPy5tYXhQcmlvcml0eUZlZVBlckdhcyA/PyBjaGFpbj8uZmVlcz8uZGVmYXVsdFByaW9yaXR5RmVlOwogICAgICBpZiAodHlwZW9mIG1heFByaW9yaXR5RmVlUGVyR2FzID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgY29uc3QgYmxvY2sgPSBibG9ja18gfHwgYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHt9KTsKICAgICAgICBjb25zdCBtYXhQcmlvcml0eUZlZVBlckdhc18gPSBhd2FpdCBtYXhQcmlvcml0eUZlZVBlckdhcyh7CiAgICAgICAgICBibG9jaywKICAgICAgICAgIGNsaWVudCwKICAgICAgICAgIHJlcXVlc3QKICAgICAgICB9KTsKICAgICAgICBpZiAobWF4UHJpb3JpdHlGZWVQZXJHYXNfID09PSBudWxsKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCk7CiAgICAgICAgcmV0dXJuIG1heFByaW9yaXR5RmVlUGVyR2FzXzsKICAgICAgfQogICAgICBpZiAodHlwZW9mIG1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZpbmVkIikKICAgICAgICByZXR1cm4gbWF4UHJpb3JpdHlGZWVQZXJHYXM7CiAgICAgIGNvbnN0IG1heFByaW9yaXR5RmVlUGVyR2FzSGV4ID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9tYXhQcmlvcml0eUZlZVBlckdhcyIKICAgICAgfSk7CiAgICAgIHJldHVybiBoZX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KQogICAgICB0aHJvdyBuZXcgQmxvYlNpemVUb29MYXJnZUVycm9yKHsKICAgICAgICBtYXhTaXplOiBtYXhCeXRlc1BlclRyYW5zYWN0aW9uLAogICAgICAgIHNpemU6IHNpemVfCiAgICAgIH0pOwogICAgY29uc3QgYmxvYnMgPSBbXTsKICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgbGV0IHBvc2l0aW9uID0gMDsKICAgIHdoaWxlIChhY3RpdmUpIHsKICAgICAgY29uc3QgYmxvYiA9IGNyZWF0ZUN1cnNvcihuZXcgVWludDhBcnJheShieXRlc1BlckJsb2IpKTsKICAgICAgbGV0IHNpemUzID0gMDsKICAgICAgd2hpbGUgKHNpemUzIDwgZmllbGRFbGVtZW50c1BlckJsb2IpIHsKICAgICAgICBjb25zdCBieXRlczIgPSBkYXRhLnNsaWNlKHBvc2l0aW9uLCBwb3NpdGlvbiArIChieXRlc1BlckZpZWxkRWxlbWVudCAtIDEpKTsKICAgICAgICBibG9iLnB1c2hCeXRlKDApOwogICAgICAgIGJsb2IucHVzaEJ5dGVzKGJ5dGVzMik7CiAgICAgICAgaWYgKGJ5dGVzMi5sZW5ndGggPCAzMSkgewogICAgICAgICAgYmxvYi5wdXNoQnl0ZSgxMjgpOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgc2l6ZTMrKzsKICAgICAgICBwb3NpdGlvbiArPSAzMTsKICAgICAgfQogICAgICBibG9icy5wdXNoKGJsb2IpOwogICAgfQogICAgcmV0dXJuIHRvID09PSAiYnl0ZXMiID8gYmxvYnMubWFwKCh4KSA9PiB4LmJ5dGVzKSA6IGJsb2JzLm1hcCgoeCkgPT4gYnl0ZXNUb0hleCh4LmJ5dGVzKSk7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvYmxvYi90b0Jsb2JTaWRlY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zKHsKICAgICAgICAgIGNvbW1pdG1lbnRzLAogICAgICAgICAgdG86ICJoZXgiCiAgICAgICAgfSk7CiAgICAgICAgcmVxdWVzdC5ibG9iVmVyc2lvbmVkSGFzaGVzID0gdmVyc2lvbmVkSGFzaGVzOwogICAgICB9CiAgICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJzaWRlY2FycyIpKSB7CiAgICAgICAgY29uc3QgcHJvb2ZzID0gYmxvYnNUb1Byb29mcyh7IGJsb2JzLCBjb21taXRtZW50cywga3pnIH0pOwogICAgICAgIGNvbnN0IHNpZGVjYXJzID0gdG9CbG9iU2lkZWNhcnMoewogICAgICAgICAgYmxvYnMsCiAgICAgICAgICBjb21taXRtZW50cywKICAgICAgICAgIHByb29mcywKICAgICAgICAgIHRvOiAiaGV4IgogICAgICAgIH0pOwogICAgICAgIHJlcXVlc3Quc2lkZWNhcnMgPSBzaWRlY2FyczsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImNoYWluSWQiKSkKICAgICAgcmVxdWVzdC5jaGFpbklkID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJub25jZSIpICYmIHR5cGVvZiBub25jZSA9PT0gInVuZGVmaW5lZCIgJiYgYWNjb3VudCkgewogICAgICBpZiAobm9uY2VNYW5hZ2VyMikgewogICAgICAgIGNvbnN0IGNoYWluSWQyID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgICAgICByZXF1ZXN0Lm5vbmNlID0gYXdhaXQgbm9uY2VNYW5hZ2VyMi5jb25zdW1lKHsKICAgICAgICAgIGFkZHJlc3M6IGFjY291bnQuYWRkcmVzcywKICAgICAgICAgIGNoYWluSWQ6IGNoYWluSWQyLAogICAgICAgICAgY2xpZW50CiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmVxdWVzdC5ub25jZSA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uQ291bnQsICJnZXRUcmFuc2FjdGlvbkNvdW50IikoewogICAgICAgICAgYWRkcmVzczogYWNjb3VudC5hZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBpZiAoKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSB8fCBwYXJhbWV0ZXJzLmluY2x1ZGVzKCJ0eXBlIikpICYmIHR5cGVvZiB0eXBlID09PSAidW5kZWZpbmVkIikgewogICAgICB0cnkgewogICAgICAgIHJlcXVlc3QudHlwZSA9IGdldFRyYW5zYWN0aW9uVHlwZShyZXF1ZXN0KTsKICAgICAgfSBjYXRjaCB7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgcmVxdWVzdC50eXBlID0gdHlwZW9mIGJsb2NrMj8uYmFzZUZlZVBlckdhcyA9PT0gImJpZ2ludCIgPyAiZWlwMTU1OSIgOiAibGVnYWN5IjsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSkgewogICAgICBpZiAocmVxdWVzdC50eXBlICE9PSAibGVnYWN5IiAmJiByZXF1ZXN0LnR5cGUgIT09ICJlaXAyOTMwIikgewogICAgICAgIGlmICh0eXBlb2YgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiByZXF1ZXN0Lm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgICBjb25zdCB7IG1heEZlZVBlckdhcywgbWF4UHJpb3JpdHlGZWVQZXJHYXMgfSA9IGF3YWl0IGludGVybmFsX2VzdGltYXRlRmVlc1BlckdhcyhjbGllbnQsIHsKICAgICAgICAgICAgYmxvY2s6IGJsb2NrMiwKICAgICAgICAgICAgY2hhaW4sCiAgICAgICAgICAgIHJlcXVlc3QKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIiAmJiBhcmdzLm1heEZlZVBlckdhcyAmJiBhcmdzLm1heEZlZVBlckdhcyA8IG1heFByaW9yaXR5RmVlUGVyR2FzKQogICAgICAgICAgICB0aHJvdyBuZXcgTWF4RmVlUGVyR2FzVG9vTG93RXJyb3IoewogICAgICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzCiAgICAgICAgICAgIH0pOwogICAgICAgICAgcmVxdWVzdC5tYXhQcmlvcml0eUZlZVBlckdhcyA9IG1heFByaW9yaXR5RmVlUGVyR2FzOwogICAgICAgICAgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPSBtYXhGZWVQZXJHYXM7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICh0eXBlb2YgYXJncy5tYXhGZWVQZXJHYXMgIT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZpbmVkIikKICAgICAgICAgIHRocm93IG5ldyBFaXAxNTU5RmVlc05vdFN1cHBvcnRlZEVycm9yKCk7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgY29uc3QgeyBnYXNQcmljZTogZ2FzUHJpY2VfIH0gPSBhd2FpdCBpbnRlcm5hbF9lc3RpbWF0ZUZlZXNQZXJHYXMoY2xpZW50LCB7CiAgICAgICAgICBibG9jazogYmxvY2syLAogICAgICAgICAgY2hhaW4sCiAgICAgICAgICByZXF1ZXN0LAogICAgICAgICAgdHlwZTogImxlZ2FjeSIKICAgICAgICB9KTsKICAgICAgICByZXF1ZXN0Lmdhc1ByaWNlID0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i5yZXN0IH0gPSBhd2FpdCBwcmVwYXJlVHJhbnNhY3Rpb25SZXF1ZXN0KGNsaWVudCwgewogICAgICAgIC4uLmFyZ3MsCiAgICAgICAgcGFyYW1ldGVyczogKAogICAgICAgICAgLy8gU29tZSBSUEMgUHJvdmlkZXJzIGRvIG5vdCBjb21wdXRlIHZlcnNpb25lZCBoYXNoZXMgZnJvbSBibG9icy4gV2Ugd2lsbCBuZWVkCiAgICAgICAgICAvLyB0byBjb21wdXRlIHRoZW0uCiAgICAgICAgICBhY2NvdW50Py50eXBlID09PSAibG9jYWwiID8gdm9pZCAwIDogWyJibG9iVmVyc2lvbmVkSGFzaGVzIl0KICAgICAgICApCiAgICAgIH0pOwogICAgICBjb25zdCBibG9ja051bWJlckhleCA9IGJsb2NrTnVtYmVyID8gbnVtYmVyVG9IZXgoYmxvY2tOdW1iZXIpIDogdm9pZCAwOwogICAgICBjb25zdCBibG9jayA9IGJsb2NrTnVtYmVySGV4IHx8IGJsb2NrVGFnOwogICAgICBjb25zdCBycGNTdGF0ZU92ZXJyaWRlID0gc2VyaWFsaXplU3RhdGVPdmVycmlkZShzdGF0ZU92ZXJyaWRlKTsKICAgICAgY29uc3QgdG8gPSBhd2FpdCAoYXN5bmMgKCkgPT4gewogICAgICAgIGlmIChyZXN0LnRvKQogICAgICAgICAgcmV0dXJuIHJlc3QudG87CiAgICAgICAgaWYgKGF1dGhvcml6YXRpb25MaXN0ICYmIGF1dGhvcml6YXRpb25MaXN0Lmxlbmd0aCA+IDApCiAgICAgICAgICByZXR1cm4gYXdhaXQgcmVjb3ZlckF1dGhvcml6YXRpb25BZGRyZXNzKHsKICAgICAgICAgICAgYXV0aG9yaXphdGlvbjogYXV0aG9yaXphdGlvbkxpc3RbMF0KICAgICAgICAgIH0pLmNhdGNoKCgpID0+IHsKICAgICAgICAgICAgdGhyb3cgbmV3IEJhc2VFcnJvcjIoImB0b2AgaXMgcmVxdWlyZWQuIENvdWxkIG5vdCBpbmZlciBmcm9tIG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jb25zdCB2YWx1ZTIgPSBhd2FpdCBnZXRCYWxhbmNlKGNsaWVudCwgeyBhZGRyZXNzOiByZXF1ZXN0LmZyb20gfSk7CiAgICAgICAgY29uc3QgZXN0aW1hdGVzID0gYXdhaXQgUHJvbWlzZS5hbGwoYXV0aG9yaXphdGlvbkxpc3QubWFwKGFzeW5jIChhdXRob3JpemF0aW9uKSA9PiB7CiAgICAgICAgICBjb25zdCB7IGNvbnRyYWN0QWRkcmVzcyB9ID0gYXV0aG9yaXphdGlvbjsKICAgICAgICAgIGNvbnN0IGVzdGltYXRlMiA9IGF3YWl0IGVzdGltYXRlR2FzX3JwYyh7CiAgICAgICAgICAgIGJsb2NrLAogICAgICAgICAgICByZXF1ZXN0OiB7CiAgICAgICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3Q6IHZvaWQgMCwKICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgIGZyb206IGFjY291bnQ/LmFkZHJlc3MsCiAgICAgICAgICAgICAgdG86IGNvbnRyYWN0QWRkcmVzcywKICAgICAgICAgICAgICB2YWx1ZTogbnVtYmVyVG9IZXgodmFsdWUyKQogICAgICAgICAgICB9LAogICAgICAgICAgICBycGNTdGF0ZU92ZXJyaWRlCiAgICAgICAgICB9KS5jYXRjaCgoKSA9PiAxMDAwMDBuKTsKICAgICAgICAgIHJldHVybiAybiAqIEJpZ0ludChlc3RpbWF0ZTIpOwogICAgICAgIH0pKTsKICAgICAgICBlc3RpbWF0ZSArPSBlc3RpbWF0ZXMucmVkdWNlKChhY2MsIGN1cnIpID0+IGFjYyArIGN1cnIsIDBuKTsKICAgICAgfQogICAgICByZXR1cm4gZXN0aW1hdGU7CiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgdGhyb3cgZ2V0RXN0aW1hdGVHYXNFcnJvcihlcnIsIHsKICAgICAgICAuLi5hcmdzLAogICAgICAgIGFjY291bnQsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbgogICAgICB9KTsKICAgIH0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AgICAgICAgICBwYXJhbQogICAgICAgIH0pOwogICAgICBhcmdzW2lzVW5uYW1lZCA/IGkgOiBwYXJhbS5uYW1lIHx8IGldID0gZGVjb2RlVG9waWMoeyBwYXJhbSwgdmFsdWU6IHRvcGljIH0pOwogICAgfQogICAgY29uc3Qgbm9uSW5kZXhlZElucHV0cyA9IGlucHV0cy5maWx0ZXIoKHgpID0+ICEoImluZGV4ZWQiIGluIHggJiYgeC5pbmRleGVkKSk7CiAgICBpZiAobm9uSW5kZXhlZElucHV0cy5sZW5ndGggPiAwKSB7CiAgICAgIGlmIChkYXRhICYmIGRhdGEgIT09ICIweCIpIHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgZGVjb2RlZERhdGEgPSBkZWNvZGVBYmlQYXJhbWV0ZXJzKG5vbkluZGV4ZWRJbnB1dHMsIGRhdGEpOwogICAgICAgICAgaWYgKGRlY29kZWREYXRhKSB7CiAgICAgICAgICAgIGlmIChpc1VubmFtZWQpCiAgICAgICAgICAgICAgYXJncyA9IFsuLi5hcmdzLCAuLi5kZWNvZGVkRGF0YV07CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbm9uSW5kZXhlZElucHV0cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgYXJnc1tub25JbmRleGVkSW5wdXRzW2ldLm5hbWVdID0gZGVjb2RlZERhdGFbaV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICBpZiAoc3RyaWN0KSB7CiAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBBYmlEZWNvZGluZ0RhdGFTaXplVG9vU21hbGxFcnJvciB8fCBlcnIgaW5zdGFuY2VvZiBQb3NpdGlvbk91dE9mQm91bmRzRXJyb3IpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ0RhdGFNaXNtYXRjaCh7CiAgICAgICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgIHBhcmFtczogbm9uSW5kZXhlZElucHV0cywKICAgICAgICAgICAgICAgIHNpemU6IHNpemUoZGF0YSkKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChzdHJpY3QpIHsKICAgICAgICB0aHJvdyBuZXcgRGVjb2RlTG9nRGF0YU1pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBkYXRhOiAiMHgiLAogICAgICAgICAgcGFyYW1zOiBub25JbmRleGVkSW5wdXRzLAogICAgICAgICAgc2l6ZTogMAogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBldmVudE5hbWU6IG5hbWUsCiAgICAgIGFyZ3M6IE9iamVjdC52YWx1ZXMoYXJncykubGVuZ3RoID4gMCA/IGFyZ3MgOiB2b2lkIDAKICAgIH07CiAgfQogIGZ1bmN0aW9uIGRlY29kZVRvcGljKHsgcGFyYW0sIHZhbHVlIH0pIHsKICAgIGlmIChwYXJhbS50eXBlID09PSAic3RyaW5nIiB8fCBwYXJhbS50eXBlID09PSAiYnl0ZXMiIHx8IHBhcmFtLnR5cGUgPT09ICJ0dXBsZSIgfHwgcGFyYW0udHlwZS5tYXRjaCgvXiguKilcWyhcZCspP1xdJC8pKQogICAgICByZXR1cm4gdmFsdWU7CiAgICBjb25zdCBkZWNvZGVkQXJnID0gZGVjb2RlQWJpUGFyYW1ldGVycyhbcGFyYW1dLCB2YWx1ZSkgfHwgW107CiAgICByZXR1cm4gZGVjb2RlZEFyZ1swXTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9hYmkvcGFyc2VFdmVudExvZ3M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7CiAgICAgICAgaWYgKGlucHV0LnR5cGUgPT09ICJhZGRyZXNzIikKICAgICAgICAgIHJldHVybiBpc0FkZHJlc3NFcXVhbCh2YWx1ZSwgYXJnKTsKICAgICAgICBpZiAoaW5wdXQudHlwZSA9PT0gInN0cmluZyIgfHwgaW5wdXQudHlwZSA9PT0gImJ5dGVzIikKICAgICAgICAgIHJldHVybiBrZWNjYWsyNTYodG9CeXRlcyh2YWx1ZSkpID09PSBhcmc7CiAgICAgICAgcmV0dXJuIHZhbHVlID09PSBhcmc7CiAgICAgIH0gY2F0Y2ggewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgfQogICAgaWYgKEFycmF5LmlzQXJyYXkoYXJncykgJiYgQXJyYXkuaXNBcnJheShtYXRjaEFyZ3MpKSB7CiAgICAgIHJldHVybiBtYXRjaEFyZ3MuZXZlcnkoKHZhbHVlLCBpbmRleDIpID0+IHsKICAgICAgICBpZiAodmFsdWUgPT09IG51bGwgfHwgdmFsdWUgPT09IHZvaWQgMCkKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzW2luZGV4Ml07CiAgICAgICAgaWYgKCFpbnB1dCkKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICBjb25zdCB2YWx1ZV8gPSBBcnJheS5pc0FycmF5KHZhbHVlKSA/IHZhbHVlIDogW3ZhbHVlXTsKICAgICAgICByZXR1cm4gdmFsdWVfLnNvbWUoKHZhbHVlMikgPT4gaXNFcXVhbChpbnB1dCwgdmFsdWUyLCBhcmdzW2luZGV4Ml0pKTsKICAgICAgfSk7CiAgICB9CiAgICBpZiAodHlwZW9mIGFyZ3MgPT09ICJvYmplY3QiICYmICFBcnJheS5pc0FycmF5KGFyZ3MpICYmIHR5cGVvZiBtYXRjaEFyZ3MgPT09ICJvYmplY3QiICYmICFBcnJheS5pc0FycmF5KG1hdGNoQXJncykpCiAgICAgIHJldHVybiBPYmplY3QuZW50cmllc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AgbGV0IGxvZ3M7CiAgICBpZiAoYmxvY2tIYXNoKSB7CiAgICAgIGxvZ3MgPSBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgbWV0aG9kOiAiZXRoX2dldExvZ3MiLAogICAgICAgIHBhcmFtczogW3sgYWRkcmVzcywgdG9waWNzLCBibG9ja0hhc2ggfV0KICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBsb2dzID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9nZXRMb2dzIiwKICAgICAgICBwYXJhbXM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgdG9waWNzLAogICAgICAgICAgICBmcm9tQmxvY2s6IHR5cGVvZiBmcm9tQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgoZnJvbUJsb2NrKSA6IGZyb21CbG9jaywKICAgICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGZvcm1hdHRlZExvZ3MgPSBsb2dzLm1hcCgobG9nKSA9PiBmb3JtYXRMb2cobG9nKSk7CiAgICBpZiAoIWV2ZW50cykKICAgICAgcmV0dXJuIGZvcm1hdHRlZExvZ3M7CiAgICByZXR1cm4gcGFyc2VFdmVudExvZ3MoewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgbG9nczogZm9ybWF0dGVkTG9ncywKICAgICAgc3RyaWN0CiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL3B1YmxpYy9nZXRDb250cmFjdEV2ZW50cy5qcwogIGFzeW5jIGZ1b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HByb21pc2UuY2xlYXIoKTsKICAgICAgICByZXNwb25zZS5jbGVhcigpOwogICAgICB9LAogICAgICBwcm9taXNlLAogICAgICByZXNwb25zZQogICAgfTsKICB9CiAgYXN5bmMgZnVuY3Rpb24gd2l0aENhY2hlKGZuLCB7IGNhY2hlS2V5OiBjYWNoZUtleTIsIGNhY2hlVGltZSA9IE51bWJlci5QT1NJVElWRV9JTkZJTklUWSB9KSB7CiAgICBjb25zdCBjYWNoZSA9IGdldENhY2hlKGNhY2hlS2V5Mik7CiAgICBjb25zdCByZXNwb25zZSA9IGNhY2hlLnJlc3BvbnNlLmdldCgpOwogICAgaWYgKHJlc3BvbnNlICYmIGNhY2hlVGltZSA+IDApIHsKICAgICAgY29uc3QgYWdlID0gKC8qIEBfX1BVUkVfXyAqLyBuZXcgRGF0ZSgpKS5nZXRUaW1lKCkgLSByZXNwb25zZS5jcmVhdGVkLmdldFRpbWUoKTsKICAgICAgaWYgKGFnZSA8IGNhY2hlVGltZSkKICAgICAgICByZXR1cm4gcmVzcG9uc2UuZGF0YTsKICAgIH0KICAgIGxldCBwcm9taXNlID0gY2FjaGUucHJvbWlzZS5nZXQoKTsKICAgIGlmICghcHJvbWlzZSkgewogICAgICBwcm9taXNlID0gZm4oKTsKICAgICAgY2FjaGUucHJvbWlzZS5zZXQocHJvbWlzZSk7CiAgICB9CiAgICB0cnkgewogICAgICBjb25zdCBkYXRhID0gYXdhaXQgcHJvbWlzZTsKICAgICAgY2FjaGUucmVzcG9uc2Uuc2V0KHsgY3JlYXRlZDogLyogQF9fUFVSRV9fICovIG5ldyBEYXRlKCksIGRhdGEgfSk7CiAgICAgIHJldHVybiBkYXRhOwogICAgfSBmaW5hbGx5IHsKICAgICAgY2FjaGUucHJvbWlzZS5jbGVhcigpOwogICAgfQogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL2dld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ICh0eXBlb2YgZnJvbUJsb2NrID09PSAiYmlnaW50IikKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAoY2xpZW50LnRyYW5zcG9ydC50eXBlID09PSAiZmFsbGJhY2siICYmIGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0c1swXS5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0pKCk7CiAgICBjb25zdCBwb2xsQ29udHJhY3RFdmVudCA9ICgpID0+IHsKICAgICAgY29uc3Qgc3RyaWN0ID0gc3RyaWN0XyA/PyBmYWxzZTsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQ29udHJhY3RFdmVudCIsCiAgICAgICAgYWRkcmVzcywKICAgICAgICBhcmdzLAogICAgICAgIGJhdGNoLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZXZlbnROYW1lLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBzdHJpY3QsCiAgICAgICAgZnJvbUJsb2NrCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uTG9ncywgb25FcnJvciB9LCAoZW1pdCkgPT4gewogICAgICAgIGxldCBwcmV2aW91c0Jsb2NrTnVtYmVyOwogICAgICAgIGlmIChmcm9tQmxvY2sgIT09IHZvaWQgMCkKICAgICAgICAgIHByZXZpb3VzQmxvY2tOdW1iZXIgPSBmcm9tQmxvY2sgLSAxbjsKICAgICAgICBsZXQgZmlsdGVyOwogICAgICAgIGxldCBpbml0aWFsaXplZCA9IGZhbHNlOwogICAgICAgIGNvbnN0IHVud2F0Y2ggPSBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmICghaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBmaWx0ZXIgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyLCAiY3JlYXRlQ29udHJhY3RFdmVudEZpbHRlciIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciA8IGJsb2NrTnVtYmVyKSB7CiAgICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICAgIGZyb21CbG9jazogcHJldmlvdXNCbG9ja051bWJlciArIDFuLAogICAgICAgICAgICAgICAgICB0b0Jsb2NrOiBibG9ja051bWJlciwKICAgICAgICAgICAgICAgICAgc3RyaWN0CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUNvbnRyYWN0RXZlbnQgPSAoKSA9PiB7CiAgICAgIGNvbnN0IHN0cmljdCA9IHN0cmljdF8gPz8gZmFsc2U7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaENvbnRyYWN0RXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50TmFtZSwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgc3RyaWN0CiAgICAgIF0pOwogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgOwogICAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQgPSAoKCkgPT4gewogICAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHMuZmluZCgodHJhbnNwb3J0MykgPT4gdHJhbnNwb3J0My5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpOwogICAgICAgICAgICAgICAgaWYgKCF0cmFuc3BvcnQyKQogICAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIHJldHVybiB0cmFuc3BvcnQyLnZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgY29uc3QgdG9waWNzID0gZXZlbnROYW1lID8gZW5jb2RlRXZlbnRUb3BpY3MoewogICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgYXJncwogICAgICAgICAgICB9KSA6IFtdOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJsb2dzIiwgeyBhZGRyZXNzLCB0b3BpY3MgfV0sCiAgICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBjb25zdCBsb2cgPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgIGNvbnN0IHsgZXZlbnROYW1lOiBldmVudE5hbWUyLCBhcmdzOiBhcmdzMiB9ID0gZGVjb2RlRXZlbnRMb2coewogICAgICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgICB0b3BpY3M6IGxvZy50b3BpY3MsCiAgICAgICAgICAgICAgICAgICAgc3RyaWN0OiBzdHJpY3RfCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBjb25zdCBmb3JtYXR0ZWQgPSBmb3JtYXRMb2cobG9nLCB7CiAgICAgICAgICAgICAgICAgICAgYXJnczogYXJnczIsCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgICAgbGV0IGV2ZW50TmFtZTI7CiAgICAgICAgICAgICAgICAgIGxldCBpc1VubmFtZWQ7CiAgICAgICAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dEYXRhTWlzbWF0Y2ggfHwgZXJyIGluc3RhbmNlb2YgRGVjb2RlTG9nVG9waWNzTWlzbWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBldmVudE5hbWUyID0gZXJyLmFiaUl0ZW0ubmFtZTsKICAgICAgICAgICAgICAgICAgICBpc1VubmFtZWQgPSBlcnIuYWJpSXRlbS5pbnB1dHM/LnNvbWUoKHgpID0+ICEoIm5hbWUiIGluIHggJiYgeC5uYW1lKSk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgewogICAgICAgICAgICAgICAgICAgIGFyZ3M6IGlzVW5uYW1lZCA/IFtdIDoge30sCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgICAgf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5kZWZpbmVkIikKICAgICAgdGhyb3cgbmV3IEFjY291bnROb3RGb3VuZEVycm9yKHsKICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2FjdGlvbnMvd2FsbGV0L3NlbmRUcmFuc2FjdGlvbiIKICAgICAgfSk7CiAgICBjb25zdCBhY2NvdW50ID0gYWNjb3VudF8gPyBwYXJzZUFjY291bnQoYWNjb3VudF8pIDogbnVsbDsKICAgIHRyeSB7CiAgICAgIGFzc2VydFJlcXVlc3QocGFyYW1ldGVycyk7CiAgICAgIGNvbnN0IHRvID0gYXdhaXQgKGFzeW5jICgpID0+IHsKICAgICAgICBpZiAocGFyYW1ldGVycy50bykKICAgICAgICAgIHJldHVybiBwYXJhbWV0ZXJzLnRvOwogICAgICAgIGlmIChhdXRob3JpemF0aW9uTGlzdCAmJiBhdXRob3JpemF0aW9uTGlzdC5sZW5ndGggPiAwKQogICAgICAgICAgcmV0dXJuIGF3YWl0IHJlY292ZXJBdXRob3JpemF0aW9uQWRkcmVzcyh7CiAgICAgICAgICAgIGF1dGhvcml6YXRpb246IGF1dGhvcml6YXRpb25MaXN0WzBdCiAgICAgICAgICB9KS5jYXRjaCgoKSA9PiB7CiAgICAgICAgICAgIHRocm93IG5ldyBCYXNlRXJyb3IyKCJgdG9gIGlzIHJlcXVpcmVkLiBDb3VsZCBub3QgaW5mZXIgZnJvbSBgYXV0aG9yaXphdGlvbkxpc3RgLiIpOwogICAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgfSkoKTsKICAgICAgaWYgKGFjY291bnQ/LnR5cGUgPT09ICJqc29uLXJwYyIgfHwgYWNjb3VudCA9PT0gbnVsbCkgewogICAgICAgIGxldCBjaGFpbklkOwogICAgICAgIGlmIChjaGFpbiAhPT0gbnVsbCkgewogICAgICAgICAgY2hhaW5JZCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldENoYWluSWQsICJnZXRDaGFpbklkIikoe30pOwogICAgICAgICAgYXNz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GlvbiI7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHJldHVybiBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgcGFyYW1zOiBbcmVxdWVzdF0KICAgICAgICAgIH0sIHsgcmV0cnlDb3VudDogMCB9KTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgICAgICBpZiAoZXJyb3IubmFtZSA9PT0gIkludmFsaWRJbnB1dFJwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiTWV0aG9kTm90Rm91bmRScGNFcnJvciIgfHwgZXJyb3IubmFtZSA9PT0gIk1ldGhvZE5vdFN1cHBvcnRlZFJwY0Vycm9yIikKICAgICAgICAgICAgcmV0dXJuIGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBtZXRob2Q6ICJ3YWxsZXRfc2VuZFRyYW5zYWN0aW9uIiwKICAgICAgICAgICAgICBwYXJhbXM6IFtyZXF1ZXN0XQogICAgICAgICAgICB9LCB7IHJldHJ5Q291bnQ6IDAgfSkudGhlbigoaGFzaDMpID0+IHsKICAgICAgICAgICAgICBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5zZXQoY2xpZW50LnVpZCwgdHJ1ZSk7CiAgICAgICAgICAgICAgcmV0dXJuIGhhc2gzOwogICAgICAgICAgICB9KTsKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gImxvY2FsIikgewogICAgICAgIGNvbnN0IHJlcXVlc3QgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBwcmVwYXJlVHJhbnNhY3Rpb25SZXF1ZXN0LCAicHJlcGFyZVRyYW5zYWN0aW9uUmVxdWVzdCIpKHsKICAgICAgICAgIGFjY291bnQsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3QsCiAgICAgICAgICBibG9icywKICAgICAgICAgIGNoYWluLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGdhcywKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgbWF4RmVlUGVyQmxvYkdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBub25jZU1hbmFnZXI6IGFjY291bnQubm9uY2VNYW5hZ2VyLAogICAgICAgICAgcGFyYW1ldGVyczogWy4uLmRlZmF1bHRQYXJhbWV0ZXJzLCAic2lkZWNhcnMiXSwKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgLi4ucmVzdCwKICAgICAgICAgIHRvCiAgICAgICAgfSk7CiAgICAgICAgY29uc3Qgc2VyaWFsaXplciA9IGNoYWluPy5zZXJpYWxpemVycz8udHJhbnNhY3Rpb247CiAgICAgICAgY29uc3Qgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gYXdhaXQgYWNjb3VudC5zaWduVHJhbnNhY3Rpb24ocmVxdWVzdCwgewogICAgICAgICAgc2VyaWFsaXplcgogICAgICAgIH0pOwogICAgICAgIHJldHVybiBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBzZW5kUmF3VHJhbnNhY3Rpb24sICJzZW5kUmF3VHJhbnNhY3Rpb24iKSh7CiAgICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24KICAgICAgICB9KTsKICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gInNtYXJ0IikKICAgICAgICB0aHJvdyBuZXcgQWNjb3VudFR5cGVOb3RTdXBwb3J0ZWRFcnJvcih7CiAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgIkNvbnNpZGVyIHVzaW5nIHRoZSBg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XRhYmlsaXR5ID09PSAicHVyZSIpCiAgICAgICAgICBoYXNSZWFkRnVuY3Rpb24gPSB0cnVlOwogICAgICAgIGVsc2UKICAgICAgICAgIGhhc1dyaXRlRnVuY3Rpb24gPSB0cnVlOwogICAgICBlbHNlIGlmIChpdGVtLnR5cGUgPT09ICJldmVudCIpCiAgICAgICAgaGFzRXZlbnQgPSB0cnVlOwogICAgICBpZiAoaGFzUmVhZEZ1bmN0aW9uICYmIGhhc1dyaXRlRnVuY3Rpb24gJiYgaGFzRXZlbnQpCiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBpZiAoaGFzUHVibGljQ2xpZW50KSB7CiAgICAgIGlmIChoYXNSZWFkRnVuY3Rpb24pCiAgICAgICAgY29udHJhY3QucmVhZCA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgcmVhZENvbnRyYWN0LCAicmVhZENvbnRyYWN0IikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGZ1bmN0aW9uTmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LnNpbXVsYXRlID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCBzaW11bGF0ZUNvbnRyYWN0LCAic2ltdWxhdGVDb250cmFjdCIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBmdW5jdGlvbk5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICBpZiAoaGFzRXZlbnQpIHsKICAgICAgICBjb250cmFjdC5jcmVhdGVFdmVudEZpbHRlciA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGV2ZW50TmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCBhYmlFdmVudCA9IGFiaTIuZmluZCgoeCkgPT4geC50eXBlID09PSAiZXZlbnQiICYmIHgubmFtZSA9PT0gZXZlbnROYW1lKTsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEV2ZW50UGFyYW1ldGVycyhwYXJhbWV0ZXJzLCBhYmlFdmVudCk7CiAgICAgICAgICAgICAgcmV0dXJuIGdldEFjdGlvbihwdWJsaWNDbGllbnQsIGNyZWF0ZUNvbnRyYWN0RXZlbnRGaWx0ZXIsICJjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyIikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgY29udHJhY3QuZ2V0RXZlbnRzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZXZlbnROYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IGFiaUV2ZW50ID0gYWJpMi5maW5kKCh4KSA9PiB4LnR5cGUgPT09ICJldmVudCIgJiYgeC5uYW1lID09PSBldmVudE5hbWUpOwogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RXZlbnRQYXJhbWV0ZXJzKHBhcmFtZXRlcnMsIGFiaUV2ZW50KTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIGNvbnRyYWN0LndhdGNoRXZlbnQgPSBuZXcgUHJveHkoe30sIHsKICAgICAgICAgIGdldChfLCBldmVudE5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuICguLi5wYXJhbWV0ZXJzKSA9PiB7CiAgICAgICAgICAgICAgY29uc3QgYWJpRXZlbnQgPSBhYmkyLmZpbmQoKHgpID0+IHgudHlwZSA9PT0gImV2ZW50IiAmJiB4Lm5hbWUgPT09IGV2ZW50TmFtZSk7CiAgICAgICAgICAgICAgY29uc3QgeyBhcmdzLCBvcHRpb25zIH0gPSBnZXRFdmVudFBhcmFtZXRlcnMocGFyYW1ldGVycywgYWJpRXZlbnQpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCB3YXRjaENvbnRyYWN0RXZlbnQsICJ3YXRjaENvbnRyYWN0RXZlbnQiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfQogICAgfQogICAgaWYgKGhhc1dhbGxldENsaWVudCkgewogICAgICBpZiAoaGFzV3JpdGVGdW5jdGlvbikKICAgICAgICBjb250cmFjdC53cml0ZSA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHdhbGxldENsaWVudCwgd3JpdGVDb250cmFjdCwgIndyaXRlQ29udHJhY3QiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGlmIChoYXNQdWJsaWNDbGllbnQgfHwgaGFzV2FsbGV0Q2xpZW50KSB7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LmVzdGltYXRlR2FzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIGNvbnN0IGNsaWVudDIgPSBwdWJsaWNDbGllbnQgPz8gd2FsbGV0Q2xpZW50OwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24oY2xpZW50MiwgZXN0aW1hdGVDb250cmFjdEdhcywgImVzdGltYXRlQ29udHJhY3RHYXMiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMsCiAgICAgICAgICAgICAgICBhY2NvdW50OiBvcHRpb25zLmFjY291bnQgPz8gd2FsbGV0Q2xpZW50LmFjY291bnQKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGNvbnRyYWN0LmFkZHJlc3MgPSBhZGRyZXNzOwogICAgY29udHJhY3QuYWJpID0gYWJpMjsKICAgIHJldHVybiBjb250cmFjdDsKICB9CiAgZnVuY3Rpb24gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHZhbHVlcykgewogICAgY29uc3QgaGFzQXJncyA9IHZhbHVlcy5sZW5ndGggJiY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gICAgIGZhY3RvcnlEYXRhCiAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGRvbWFpbjogewogICAgICAgICAgbmFtZSwKICAgICAgICAgIHZlcnNpb246IHZlcnNpb24zLAogICAgICAgICAgY2hhaW5JZDogTnVtYmVyKGNoYWluSWQpLAogICAgICAgICAgdmVyaWZ5aW5nQ29udHJhY3QsCiAgICAgICAgICBzYWx0CiAgICAgICAgfSwKICAgICAgICBleHRlbnNpb25zLAogICAgICAgIGZpZWxkcwogICAgICB9OwogICAgfSBjYXRjaCAoZSkgewogICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgIGlmIChlcnJvci5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvbkV4ZWN1dGlvbkVycm9yIiAmJiBlcnJvci5jYXVzZS5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvblplcm9EYXRhRXJyb3IiKSB7CiAgICAgICAgdGhyb3cgbmV3IEVpcDcxMkRvbWFpbk5vdEZvdW5kRXJyb3IoeyBhZGRyZXNzIH0pOwogICAgICB9CiAgICAgIHRocm93IGVycm9yOwogICAgfQogIH0KICB2YXIgYWJpID0gWwogICAgewogICAgICBpbnB1dHM6IFtdLAogICAgICBuYW1lOiAiZWlwNzEyRG9tYWluIiwKICAgICAgb3V0cHV0czogWwogICAgICAgIHsgbmFtZTogImZpZWxkcyIsIHR5cGU6ICJieXRlczEiIH0sCiAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAidmVyc2lvbiIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAiY2hhaW5JZCIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgIHsgbmFtZTogInZlcmlmeWluZ0NvbnRyYWN0IiwgdHlwZTogImFkZHJlc3MiIH0sCiAgICAgICAgeyBuYW1lOiAic2FsdCIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgIHsgbmF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FyYW1ldGVycy5hY2NvdW50KSA6IHZvaWQgMDsKICAgIGNvbnN0IHsgY29uZmlnLCByZXF1ZXN0LCB2YWx1ZSB9ID0gcGFyYW1ldGVycy50cmFuc3BvcnQoewogICAgICBjaGFpbiwKICAgICAgcG9sbGluZ0ludGVydmFsCiAgICB9KTsKICAgIGNvbnN0IHRyYW5zcG9ydCA9IHsgLi4uY29uZmlnLCAuLi52YWx1ZSB9OwogICAgY29uc3QgY2xpZW50ID0gewogICAgICBhY2NvdW50LAogICAgICBiYXRjaCwKICAgICAgY2FjaGVUaW1lLAogICAgICBjY2lwUmVhZCwKICAgICAgY2hhaW4sCiAgICAgIGtleSwKICAgICAgbmFtZSwKICAgICAgcG9sbGluZ0ludGVydmFsLAogICAgICByZXF1ZXN0LAogICAgICB0cmFuc3BvcnQsCiAgICAgIHR5cGUsCiAgICAgIHVpZDogdWlkKCkKICAgIH07CiAgICBmdW5jdGlvbiBleHRlbmQoYmFzZTIpIHsKICAgICAgcmV0dXJuIChleHRlbmRGbikgPT4gewogICAgICAgIGNvbnN0IGV4dGVuZGVkID0gZXh0ZW5kRm4oYmFzZTIpOwogICAgICAgIGZvciAoY29uc3Qga2V5MiBpbiBjbGllbnQpCiAgICAgICAgICBkZWxldGUgZXh0ZW5kZWRba2V5Ml07CiAgICAgICAgY29uc3QgY29tYmluZWQgPSB7IC4uLmJhc2UyLCAuLi5leHRlbmRlZCB9OwogICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNvbWJpbmVkLCB7IGV4dGVuZDogZXh0ZW5kKGNvbWJpbmVkKSB9KTsKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNsaWVudCwgeyBleHRlbmQ6IGV4dGVuZChjbGllbnQpIH0pOwogIH0KICBmdW5jdGlvbiBycGNTY2hlbWEoKSB7CiAgICByZXR1cm4gbnVsbDsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV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5RGVsYXkgPSAxNTAsIHJldHJ5Q291bnQgPSAzLCB1aWQ6IHVpZDIgfSA9IHsKICAgICAgICAuLi5vcHRpb25zLAogICAgICAgIC4uLm92ZXJyaWRlT3B0aW9ucwogICAgICB9OwogICAgICBjb25zdCByZXF1ZXN0SWQgPSBkZWR1cGUgPyBrZWNjYWsyNTYoc3RyaW5nVG9IZXgoYCR7dWlkMn0uJHtzdHJpbmdpZnkoYXJncyl9YCkpIDogdm9pZCAwOwogICAgICByZXR1cm4gd2l0aERlZHVwZSgoKSA9PiB3aXRoUmV0cnkoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICByZXR1cm4gYXdhaXQgcmVxdWVzdChhcmdzKTsKICAgICAgICB9IGNhdGNoIChlcnJfKSB7CiAgICAgICAgICBjb25zdCBlcnIgPSBlcnJfOwogICAgICAgICAgc3dpdGNoIChlcnIuY29kZSkgewogICAgICAgICAgICAvLyAtMzI3MDAKICAgICAgICAgICAgY2FzZSBQYXJzZVJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFBhcnNlUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyNjAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFJlcXVlc3RScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBJbnZhbGlkUmVxdWVzdFJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjYwMQogICAgICAgICAgICBjYXNlIE1ldGhvZE5vdEZvdW5kUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90Rm91bmRScGNFcnJvcihlcnIsIHsgbWV0aG9kOiBhcmdzLm1ldGhvZCB9KTsKICAgICAgICAgICAgLy8gLTMyNjAyCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFBhcmFtc1JwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRQYXJhbXNScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzI2MDMKICAgICAgICAgICAgY2FzZSBJbnRlcm5hbFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludGVybmFsUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZElucHV0UnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZElucHV0UnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAxCiAgICAgICAgICAgIGNhc2UgUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFJlc291cmNlTm90Rm91bmRScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzIwMDIKICAgICAgICAgICAgY2FzZSBSZXNvdXJjZVVuYXZhaWxhYmxlUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgUmVzb3VyY2VVbmF2YWlsYWJsZVJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjAwMwogICAgICAgICAgICBjYXNlIFRyYW5zYWN0aW9uUmVqZWN0ZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA0CiAgICAgICAgICAgIGNhc2UgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IoZXJyLCB7CiAgICAgICAgICAgICAgICBtZXRob2Q6IGFyZ3MubWV0aG9kCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIC8vIC0zMjAwNQogICAgICAgICAgICBjYXNlIExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBMaW1pdEV4Y2VlZGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA2CiAgICAgICAgICAgIGNhc2UgSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpzb25ScGNWZXJzaW9uVW5zdXBwb3J0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MDAxCiAgICAgICAgICAgIGNhc2UgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFVzZXJSZWplY3RlZFJlcXVlc3RFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MTAwCiAgICAgICAgICAgIGNhc2UgVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBVbmF1dGhvcml6ZWRQcm92aWRlckVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQyMDAKICAgICAgICAgICAgY2FzZSBVbnN1cHBvcnRlZFByb3ZpZGVyTWV0aG9kRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRQcm92aWRlck1ldGhvZEVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQ5MDAKICAgICAgICAgICAgY2FzZSBQcm92aWRlckRpc2Nvbm5lY3RlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gNDkwMQogICAgICAgICAgICBjYXNlIENoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2hhaW5EaXNjb25uZWN0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0OTAyCiAgICAgICAgICAgIGNhc2UgU3dpdGNoQ2hhaW5FcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBTd2l0Y2hDaGFpbkVycm9yKGVycik7CiAgICAgICAgICAgIC8vIENBSVAtMjU6IFVzZXIgUmVqZWN0ZWQgRXJyb3IKICAgICAgICAgICAgLy8gaHR0cHM6Ly9kb2NzLndhbGxldGNvbm5lY3QuY29tLzIuMC9zcGVjcy9jbGllbnRzL3NpZ24vZXJyb3ItY29kZXMjcmVqZWN0ZWQtY2FpcC0yNQogICAgICAgICAgICBjYXNlIDVlMzoKICAgICAgICAgICAgICB0aHJvdyBuZXcgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yKGVycik7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGVycl8gaW5zdGFuY2VvZiBCYXNlRXJyb3IyKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyXzsKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5rbm93blJwY0Vycm9yKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9LCB7CiAgICAgICAgZGVsYXk6ICh7IGNvdW50LCBlcnJvciB9KSA9PiB7CiAgICAgICAgICBpZiAoZXJyb3IgJiYgZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yKSB7CiAgICAgICAgICAgIGNvbnN0IHJldHJ5QWZ0ZXIgPSBlcnJvcj8uaGVhZGVycz8uZ2V0KCJSZXRyeS1BZnRlciIpOwogICAgICAgICAgICBpZiAocmV0cnlBZnRlcj8ubWF0Y2goL1xkLykpCiAgICAgICAgICAgICAgcmV0dXJuIE51bWJlci5wYXJzZUludChyZXRyeUFmdGVyKSAqIDFlMzsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB+figxIDw8IGNvdW50KSAqIHJldHJ5RGVsYXk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHNob3VsZFJldHJ5OiAoeyBlcnJvciB9KSA9PiBzaG91bGRSZXRyeShlcnJvcikKICAgICAgfSksIHsgZW5hYmxlZDogZGVkdXBlLCBpZDogcmVxdWVzdElkIH0pOwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkUmV0cnkoZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSAtMSkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLmNvZGUgPT09IExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3IuY29kZSA9PT0gSW50ZXJuYWxScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yICYmIGVycm9yLnN0YXR1cykgewogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDQwOCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNDEzKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MjkpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwMCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNTAyKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA1MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgI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gICAgIGNoYWluLAogICAgICAgICAgICAgIHJldHJ5Q291bnQ6IDAsCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IHRyYW5zcG9ydDIucmVxdWVzdCh7CiAgICAgICAgICAgICAgICBtZXRob2QsCiAgICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBvblJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHJlc3BvbnNlLAogICAgICAgICAgICAgICAgdHJhbnNwb3J0OiB0cmFuc3BvcnQyLAogICAgICAgICAgICAgICAgc3RhdHVzOiAic3VjY2VzcyIKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIG9uUmVzcG9uc2UoewogICAgICAgICAgICAgICAgZXJyb3I6IGVyciwKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHRyYW5zcG9ydDogdHJhbnNwb3J0MiwKICAgICAgICAgICAgICAgIHN0YXR1czogImVycm9yIgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChzaG91bGRUaHJvdyhlcnIpKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgICAgIGlmIChpID09PSB0cmFuc3BvcnRzLmxlbmd0aCAtIDEpCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgcmV0dXJuIGZldGNoMihpICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH07CiAgICAgICAgICByZXR1cm4gZmV0Y2gyKCk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHJldHJ5RGVsYXksCiAgICAgICAgdHlwZTogImZhbGxiYWNrIgogICAgICB9LCB7CiAgICAgICAgb25SZXNwb25zZTogKGZuKSA9PiBvblJlc3BvbnNlID0gZm4sCiAgICAgICAgdHJhbnNwb3J0czogdHJhbnNwb3J0cy5tYXAoKGZuKSA9PiBmbih7IGNoYWluLCByZXRyeUNvdW50OiAwIH0pKQogICAgICB9KTsKICAgICAgaWYgKHJhbmspIHsKICAgICAgICBjb25zdCByYW5rT3B0aW9ucyA9IHR5cGVvZiByYW5rID09PSAib2JqZWN0IiA/IHJhbmsgOiB7fTsKICAgICAgICByYW5rVHJhbnNwb3J0cyh7CiAgICAgICAgICBjaGFpbiwKICAgICAgICAgIGludGVydmFsOiByYW5rT3B0aW9ucy5pbnRlcnZhbCA/PyBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgICBvblRyYW5zcG9ydHM6ICh0cmFuc3BvcnRzXzIpID0+IHRyYW5zcG9ydHMgPSB0cmFuc3BvcnRzXzIsCiAgICAgICAgICBzYW1wbGVDb3VudDogcmFua09wdGlvbnMuc2FtcGxlQ291bnQsCiAgICAgICAgICB0aW1lb3V0OiByYW5rT3B0aW9ucy50aW1lb3V0LAogICAgICAgICAgdHJhbnNwb3J0cywKICAgICAgICAgIHdlaWdodHM6IHJhbmtPcHRpb25zLndlaWdodHMKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm4gdHJhbnNwb3J0OwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkVGhyb3coZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IuY29kZSB8fCBlcnJvci5jb2RlID09PSBVc2VyUmVqZWN0ZWRSZXF1ZXN0RXJyb3IuY29kZSB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hlZHVsZXIoKTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL3JwYy9odHRwLmpzCiAgaW5pdF9yZXF1ZXN0KCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9wcm9taXNlL3dpdGhUaW1lb3V0LmpzCiAgZnVuY3Rpb24gd2l0aFRpbWVvdXQoZm4sIHsgZXJyb3JJbnN0YW5jZSA9IG5ldyBFcnJvcigidGltZWQgb3V0IiksIHRpbWVvdXQsIHNpZ25hbCB9KSB7CiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICA7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgbGV0IHRpbWVvdXRJZDsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgY29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXIoKTsKICAgICAgICAgIGlmICh0aW1lb3V0ID4gMCkgewogICAgICAgICAgICB0aW1lb3V0SWQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgICAgICBjb250cm9sbGVyLmFib3J0KCk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJlamVjdChlcnJvckluc3RhbmNlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sIHRpbWVvdXQpOwogICAgICAgICAgfQogICAgICAgICAgcmVzb2x2ZShhd2FpdCBmbih7IHNpZ25hbDogY29udHJvbGxlcj8uc2lnbmFsIHx8IG51bGwgfSkpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVycj8ubmFtZSA9PT0gIkFib3J0RXJyb3IiKQogICAgICAgICAgICByZWplY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zdCBmZXRjaE9wdGlvbnMgPSB7CiAgICAgICAgICAuLi5vcHRpb25zLmZldGNoT3B0aW9ucyA/PyB7fSwKICAgICAgICAgIC4uLnBhcmFtcy5mZXRjaE9wdGlvbnMgPz8ge30KICAgICAgICB9OwogICAgICAgIGNvbnN0IHsgaGVhZGVycywgbWV0aG9kLCBzaWduYWw6IHNpZ25hbF8gfSA9IGZldGNoT3B0aW9uczsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB3aXRoVGltZW91dChhc3luYyAoeyBzaWduYWwgfSkgPT4gewogICAgICAgICAgICBjb25zdCBpbml0ID0gewogICAgICAgICAgICAgIC4uLmZldGNoT3B0aW9ucywKICAgICAgICAgICAgICBib2R5OiBBcnJheS5pc0FycmF5KGJvZHkpID8gc3RyaW5naWZ5KGJvZHkubWFwKChib2R5MikgPT4gKHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkyLmlkID8/IGlkQ2FjaGUudGFrZSgpLAogICAgICAgICAgICAgICAgLi4uYm9keTIKICAgICAgICAgICAgICB9KSkpIDogc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkuaWQgPz8gaWRDYWNoZS50YWtlKCksCiAgICAgICAgICAgICAgICAuLi5ib2R5CiAgICAgICAgICAgICAgfSksCiAgICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICAgIkNvbnRlbnQtVHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgICAgIC4uLmhlYWRlcnMKICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgIG1ldGhvZDogbWV0aG9kIHx8ICJQT1NUIiwKICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbF8gfHwgKHRpbWVvdXQgPiAwID8gc2lnbmFsIDogbnVsbCkKICAgICAgICAgICAgfTsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdCA9IG5ldyBSZXF1ZXN0KHVybCwgaW5pdCk7CiAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhd2FpdCBvblJlcXVlc3Q/LihyZXF1ZXN0LCBpbml0KSA/PyB7IC4uLmluaXQsIHVybCB9OwogICAgICAgICAgICBjb25zdCByZXNwb25zZTIgPSBhd2FpdCBmZXRjaChhcmdzLnVybCA/PyB1cmwsIGFyZ3MpOwogICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UyOwogICAgICAgICAgfSwgewogICAgICAgICAgICBlcnJvckluc3RhbmNlOiBuZXcgVGltZW91dEVycm9yKHsgYm9keSwgdXJsIH0pLAogICAgICAgICAgICB0aW1lb3V0LAogICAgICAgICAgICBzaWduYWw6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKG9uUmVzcG9uc2UpCiAgICAgICAgICAgIGF3YWl0IG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpCiAgICAgICAgICAgIGRhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgZGF0YSA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBkYXRhID0gSlNPTi5wYXJzZShkYXRhIHx8ICJ7fSIpOwogICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uub2spCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgZGF0YSA9IHsgZXJyb3I6IGRhdGEgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICB0aHJvdyBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBkZXRhaWxzOiBzdHJpbmdpZnkoZGF0YS5lcnJvcikgfHwgcmVzcG9uc2Uuc3RhdHVzVGV4dCwKICAgICAgICAgICAgICBoZWFkZXJzOiByZXNwb25zZS5oZWFkZXJzLAogICAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICAgIHVybAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBkYXRhOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIEh0dHBSZXF1ZXN0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBUaW1lb3V0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIHRocm93IG5ldyBIdHRwUmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgY2F1c2U6IGVyciwKICAgICAgICAgICAgdXJsCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2xpZW50cy90cmFuc3BvcnRzL2h0dHAuanMKICBmdW5jdGlvbiBodHRwKHVybCwgY29uZmlnID0ge30pIHsKICAgIGNvbnN0IHsgYmF0Y2gsIGZldGNoT3B0aW9ucywga2V5ID0gImh0dHAiLCBuYW1lID0gIkhUVFAgSlNPTi1SUEMiLCBvbkZldGNoUmVxdWVzdCwgb25GZXRjaFJlc3BvbnNlLCByZXRyeURlbGF5IH0gPSBjb25maWc7CiAgICByZXR1cm4gKHsgY2hhaW4s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ZXR1cm4gcmVxdWVzdHMubGVuZ3RoID4gYmF0Y2hTaXplOwogICAgICAgICAgICB9LAogICAgICAgICAgICBmbjogKGJvZHkyKSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgICAgYm9keTogYm9keTIKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNvcnQ6IChhLCBiKSA9PiBhLmlkIC0gYi5pZAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCBmbiA9IGFzeW5jIChib2R5MikgPT4gYmF0Y2ggPyBzY2hlZHVsZShib2R5MikgOiBbCiAgICAgICAgICAgIGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBib2R5OiBib2R5MgogICAgICAgICAgICB9KQogICAgICAgICAgXTsKICAgICAgICAgIGNvbnN0IFt7IGVycm9yLCByZXN1bHQgfV0gPSBhd2FpdCBmbihib2R5KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogImh0dHAiCiAgICAgIH0sIHsKICAgICAgICBmZXRjaE9wdGlvbnMsCiAgICAgICAgdXJsOiB1cmxfCiAgICAgIH0pOwogICAgfTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL2Vucy9nZXRFbnNBZGRyZXNzLmpzCiAgaW5pdF9hYmlzKCk7CiAgaW5pdF9kZWNvZGVGdW5jdGlvblJlc3VsdCgpOwog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AgICAgICAuLi5yZWFkQ29udHJhY3RQYXJhbWV0ZXJzLAogICAgICAgIGFyZ3M6IFsuLi5yZWFkQ29udHJhY3RQYXJhbWV0ZXJzLmFyZ3MsIGdhdGV3YXlVcmxzXQogICAgICB9KSA6IGF3YWl0IHJlYWRDb250cmFjdEFjdGlvbihyZWFkQ29udHJhY3RQYXJhbWV0ZXJzKTsKICAgICAgaWYgKHJlc1swXSA9PT0gIjB4IikKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgY29uc3QgYWRkcmVzcyA9IGRlY29kZUZ1bmN0aW9uUmVzdWx0KHsKICAgICAgICBhYmk6IGFkZHJlc3NSZXNvbHZlckFiaSwKICAgICAgICBhcmdzOiBjb2luVHlwZSAhPSBudWxsID8gW25hbWVoYXNoKG5hbWUpLCBCaWdJbnQoY29pblR5cGUpXSA6IHZvaWQgMCwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJhZGRyIiwKICAgICAgICBkYXRhOiByZXNbMF0KICAgICAgfSk7CiAgICAgIGlmIChhZGRyZXNzID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBpZiAodHJpbShhZGRyZXNzKSA9PT0gIjB4MDAiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gYWRkcmVzczsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICBpZiAoc3RyaWN0KQogICAgICAgIHRocm93IGVycjsKICAgICAgaWYgKGlzTnVsbFVuaXZlcnNhbFJlc29sdmVyRXJyb3IoZXJyLCAicmVzb2x2ZSIpKQogICAgICAgIHJldHVybiBudWxsOwogICAgICB0aHJvdyBlcnI7CiAgICB9CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL2Vucy5qcwogIGluaXRfYmFzZSgpOwogIHZhciBFbnNBdmF0YXJJbnZhbGlkTWV0YWRhdGFFcnJvciA9IGNsYXNzIGV4dGVu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gfSk7CiAgICBpZiAoIWNoYWluSUQpCiAgICAgIHRocm93IG5ldyBFbnNBdmF0YXJJbnZhbGlkTmZ0VXJpRXJyb3IoeyByZWFzb246ICJDaGFpbiBJRCBub3QgZm91bmQiIH0pOwogICAgaWYgKCFjb250cmFjdEFkZHJlc3MpCiAgICAgIHRocm93IG5ldyBFbnNBdmF0YXJJbnZhbGlkTmZ0VXJpRXJyb3IoewogICAgICAgIHJlYXNvbjogIkNvbnRyYWN0IGFkZHJlc3Mgbm90IGZvdW5kIgogICAgICB9KTsKICAgIGlmICghdG9rZW5JRCkKICAgICAgdGhyb3cgbmV3IEVuc0F2YXRhckludmFsaWROZnRVcmlFcnJvcih7IHJlYXNvbjogIlRva2VuIElEIG5vdCBmb3VuZCIgfSk7CiAgICBpZiAoIWVyY19uYW1lc3BhY2UpCiAgICAgIHRocm93IG5ldyBFbnNBdmF0YXJJbnZhbGlkTmZ0VXJpRXJyb3IoeyByZWFzb246ICJFUkMgbmFtZXNwYWNlIG5vdCBmb3VuZCIgfSk7CiAgICByZXR1cm4gewogICAgICBjaGFpbklEOiBOdW1iZXIucGFyc2VJbnQoY2hhaW5JRCksCiAgICAgIG5hbWVzcGFjZTogZXJjX25hbWVzcGFjZS50b0xvd2VyQ2FzZSgpLAogICAgICBjb250cmFjdEFkZHJlc3MsCiAgICAgIHRva2VuSUQKICAgIH07CiAgfQogIGFzeW5jIGZ1bmN0aW9uIGdldE5mdFRva2VuVXJpKGNsaWVudCwgeyBuZnQgfSkgewogICAgaWYgKG5mdC5uYW1lc3BhY2UgPT09ICJlcmM3MjEiKSB7CiAgICAgIHJldHVybiByZWFkQ29udHJhY3QoY2xpZW50LCB7CiAgICAgICAgYWRkcmVzczogbmZ0LmNvbnRyYWN0QWRkcmVzcywKICAgICAgICBhYmk6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInRva2VuVVJJIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogInRva2VuSWQiLCB0eXBlOiAidWludDI1NiIgfV0sCiAgICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgICAgfQogICAgICAgIF0sCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidG9rZW5VUkkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIGlmIChuZnQubmFtZXNwYWNlID09PSAiZXJjMTE1NSIpIHsKICAgICAgcmV0dXJuIHJlYWRDb250cmFjdChjbGllbnQsIHsKICAgICAgICBhZGRyZXNzOiBuZnQuY29udHJhY3RBZGRyZXNzLAogICAgICAgIGFiaTogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAidXJpIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIl9pZCIsIHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJzdHJpbmciIH1dCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJ1cmkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBFbnNBdmF0YXJVbnN1cHBvcnRlZE5hbWVzcGFjZUVycm9yKHsgbmFtZXNwYWNlOiBuZnQubmFtZXNwYWNlIH0pOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL2Vucy9hdmF0YXIvcGFyc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ckFkZHJlc3M6IHVuaXZlcnNhbFJlc29sdmVyQWRkcmVzc18gfSkgewogICAgbGV0IHVuaXZlcnNhbFJlc29sdmVyQWRkcmVzcyA9IHVuaXZlcnNhbFJlc29sdmVyQWRkcmVzc187CiAgICBpZiAoIXVuaXZlcnNhbFJlc29sdmVyQWRkcmVzcykgewogICAgICBpZiAoIWNsaWVudC5jaGFpbikKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImNsaWVudCBjaGFpbiBub3QgY29uZmlndXJlZC4gdW5pdmVyc2FsUmVzb2x2ZXJBZGRyZXNzIGlzIHJlcXVpcmVkLiIpOwogICAgICB1bml2ZXJzYWxSZXNvbHZlckFkZHJlc3MgPSBnZXRDaGFpbkNvbnRyYWN0QWRkcmVzcyh7CiAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbiwKICAgICAgICBjb250cmFjdDogImVuc1VuaXZlcnNhbFJlc29sdmVyIgogICAgICB9KTsKICAgIH0KICAgIHRyeSB7CiAgICAgIGNvbnN0IHJlYWRDb250cmFjdFBhcmFtZXRlcnMgPSB7CiAgICAgICAgYWRkcmVzczogdW5pdmVyc2FsUmVzb2x2ZXJBZGRyZXNzLAogICAgICAgIGFiaTogdW5pdmVyc2FsUmVzb2x2ZXJSZXNvbHZlQWJpLAogICAgICAgIGZ1bmN0aW9uTmFtZTogInJlc29sdmUiLAogICAgICAgIGFyZ3M6IFsKICAgICAgICAgIHRvSGV4KHBhY2tldFRvQnl0ZXMobmFtZSkpLAogICAgICAgICAgZW5jb2RlRnVuY3Rpb25EYXRhKHsKICAgICAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgICAgIGZ1bmN0aW9uTmFtZTogInRleHQiLAogICAgICAgICAgICBhcmdzOiBbbmFtZWhhc2gobmFtZSksIGtleV0KICAgICAgICAgIH0pCiAgICAgICAgXSwKICAgICAgICBibG9ja051bWJlciwKICAgICAgICBibG9ja1RhZwogICAgICB9OwogICAgICBjb25zdCByZWFkQ29udHJhY3RBY3Rpb24gPSBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKTsKICAgICAgY29uc3QgcmVzID0gZ2F0ZXdheVVybHMgPyBhd2FpdCByZWFkQ29udHJhY3RBY3Rpb24oewogICAgICAgIC4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMsCiAgICAgICAgYXJnczogWy4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMuYXJncywgZ2F0ZXdheVVybHNdCiAgICAgIH0pIDogYXdhaXQgcmVhZENvbnRyYWN0QWN0aW9uKHJlYWRDb250cmFjdFBhcmFtZXRlcnMpOwogICAgICBpZiAocmVzWzBdID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBjb25zdCByZWNvcmQgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidGV4dCIsCiAgICAgICAgZGF0YTogcmVzWzBdCiAgICAgIH0pOwogICAgICByZXR1cm4gcmVjb3JkID09PSAiIiA/IG51bGwgOiByZWNvcmQ7CiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgaWYgKHN0cmljdCkKICAgICAgICB0aHJvdyBlcnI7CiAgICAgIGlmIChpc051bGxVbml2ZXJzYWxSZXNvbHZlckVycm9yKGVyciwgInJlc29sdmUiKSkKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgdGhyb3cgZXJyOwogICAgfQogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvZW5zL2dldEVuc0F2YXRhci5qcwogIGFzeW5jIGZ1bmN0aW9uIGdldEVuc0F2YXRhcihjbGllbnQsIHsgYmxvY2tOdW1iZXIsIGJsb2NrVGFnLC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ZXdGaWx0ZXIiCiAgICB9KTsKICAgIGxldCB0b3BpY3MgPSBbXTsKICAgIGlmIChldmVudHMpIHsKICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50cy5mbGF0TWFwKChldmVudDIpID0+IGVuY29kZUV2ZW50VG9waWNzKHsKICAgICAgICBhYmk6IFtldmVudDJdLAogICAgICAgIGV2ZW50TmFtZTogZXZlbnQyLm5hbWUsCiAgICAgICAgYXJncwogICAgICB9KSk7CiAgICAgIHRvcGljcyA9IFtlbmNvZGVkXTsKICAgICAgaWYgKGV2ZW50KQogICAgICAgIHRvcGljcyA9IHRvcGljc1swXTsKICAgIH0KICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgLi4udG9waWNzLmxlbmd0aCA/IHsgdG9waWNzIH0gOiB7fQogICAgICAgIH0KICAgICAgXQogICAgfSk7CiAgICByZXR1cm4gewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lOiBldmVudCA/IGV2ZW50Lm5hbWUgOiB2b2lkIDAsCiAgICAgIGZyb21CbG9jaywKICAgICAgaWQsCiAgICAgIHJlcXVlc3Q6IGdldFJlcXVlc3QoaWQpLAogICAgICBzdHJpY3Q6IEJvb2xlYW4oc3RyaWN0KSwKICAgICAgdG9CbG9jaywKICAgICAgdHlwZTogImV2ZW50IgogICAgfTsKICB9CgogIC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AgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybCB9KSk7CiAgICAgICAgICAgICAgcmVxdWVzdHMuY2xlYXIoKTsKICAgICAgICAgICAgICBzdWJzY3JpcHRpb25zLmNsZWFyKCk7CiAgICAgICAgICAgICAgaWYgKHJlY29ubmVjdCAmJiByZWNvbm5lY3RDb3VudCA8IGF0dGVtcHRzKQogICAgICAgICAgICAgICAgc2V0VGltZW91dChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgIHJlY29ubmVjdENvdW50Kys7CiAgICAgICAgICAgICAgICAgIGF3YWl0IHNldHVwKCkuY2F0Y2goY29uc29sZS5lcnJvcik7CiAgICAgICAgICAgICAgICB9LCBkZWxheSk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uRXJyb3IoZXJyb3JfKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSBlcnJvcl87CiAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0IG9mIHJlcXVlc3RzLnZhbHVlcygpKQogICAgICAgICAgICAgICAgcmVxdWVzdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXF1ZXN0cy5jbGVhcigpOwogICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuY2xlYXIoKTsKICAgICAgICAgICAgICBpZiAocmVjb25uZWN0ICYmIHJlY29ubmVjdENvdW50IDwgYXR0ZW1wdHMpCiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGFzeW5jICgpID0+IHsKICAgICAgICAgICAgICAgICAgcmVjb25uZWN0Q291bnQrKzsKICAgICAgICAgICAgICAgICAgYXdhaXQgc2V0dXAoKS5jYXRjaChjb25zb2xlLmVycm9yKTsKICAgICAgICAgICAgICAgIH0sIGRlbGF5KTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25PcGVuKCkgewogICAgICAgICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgICAgICAgIHJlY29ubmVjdENvdW50ID0gMDsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25SZXNwb25zZShkYXRhKSB7CiAgICAgICAgICAgICAgY29uc3QgaXNTdWJzY3JpcHRpb24gPSBkYXRhLm1ldGhvZCA9PT0gImV0aF9zdWJzY3JpcHRpb24iOwogICAgICAgICAgICAgIGNvbnN0IGlkID0gaXNTdWJzY3JpcHRpb24gPyBkYXRhLnBhcmFtcy5zdWJzY3JpcHRpb24gOiBkYXRhLmlkOwogICAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gaXNTdWJzY3JpcHRpb24gPyBzdWJzY3JpcHRpb25zIDogcmVxdWVzdHM7CiAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2sgPSBjYWNoZS5nZXQoaWQpOwogICAgICAgICAgICAgIGlmIChjYWxsYmFjaykKICAgICAgICAgICAgICAgIGNhbGxiYWNrLm9uUmVzcG9uc2UoZGF0YSk7CiAgICAgICAgICAgICAgaWYgKCFpc1N1YnNjcmlwdGlvbikKICAgICAgICAgICAgICAgIGNhY2hlLmRlbGV0ZShpZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgc29ja2V0ID0gcmVzdWx0OwogICAgICAgICAgaWYgKGtlZXBBbGl2ZSkgewogICAgICAgICAgICBpZiAoa2VlcEFsaXZlVGltZXIpCiAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChrZWVwQWxpdmVUaW1lcik7CiAgICAgICAgICAgIGtlZXBBbGl2ZVRpbWVyID0gc2V0SW50ZXJ2YWwoKCkgPT4gc29ja2V0LnBpbmc/LigpLCBrZWVwQWxpdmVJbnRlcnZhbCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0KICAgICAgICBhd2FpdCBzZXR1cCgpOwogICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgIHNvY2tldENsaWVudCA9IHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBrZWVwQWxpdmVUaW1lciAmJiBjbGVhckludGVydmFsKGtlZXBBbGl2ZVRpbWVyKTsKICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7CiAgICAgICAgICAgIHNvY2tldENsaWVudENhY2hlLmRlbGV0ZShgJHtrZXl9OiR7dXJsfWApOwogICAgICAgICAgfSwKICAgICAgICAgIGdldCBzb2NrZXQoKSB7CiAgICAgICAgICAgIHJldHVybiBzb2NrZXQ7CiAgICAgICAgICB9LAogICAgICAgICAgcmVxdWVzdCh7IGJvZHksIG9uRXJyb3IsIG9uUmVzcG9uc2UgfSkgewogICAgICAgICAgICBpZiAoZXJyb3IgJiYgb25FcnJvcikKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKTsKICAgICAgICAgICAgY29uc3QgaWQgPSBib2R5LmlkID8/IGlkQ2FjaGUudGFrZSgpOwogICAgICAgICAgICBjb25zdCBjYWxsYmFjayA9IChyZXNwb25zZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzcG9uc2UuaWQgPT09ICJudW1iZXIiICYmIGlkICE9PSByZXNwb25zZS5pZCkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBpZiAoYm9keS5tZXRob2QgPT09ICJldGhfc3Vic2NyaWJlIiAmJiB0eXBlb2YgcmVzcG9uc2UucmVzdWx0ID09PSAic3RyaW5nIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuc2V0KHJlc3BvbnNlLnJlc3VsdCwgewogICAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiBjYWxsYmFjaywKICAgICAgICAgICAgICAgICAgb25FcnJvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgaWYgKGJvZHkubWV0aG9kID09PSAiZXRoX3Vuc3Vic2NyaWJlIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuZGVsZXRlKGJvZHkucGFyYW1zPy5bMF0pOwogICAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgICB9OwogICAgICAgICAgICByZXF1ZXN0cy5zZXQoaWQsIHsgb25SZXNwb25zZTogY2FsbGJhY2ssIG9uRXJyb3IgfSk7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgc29ja2V0LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBqc29ucnBjOiAiMi4wIiwKICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgIC4uLmJvZHkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yMik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0QXN5bmMoeyBib2R5LCB0aW1lb3V0ID0gMWU0IH0pIHsKICAgICAgICAgICAgcmV0dXJuIHdpdGhUaW1lb3V0KCgpID0+IG5ldyBQcm9taXNlKChvblJlc3BvbnNlLCBvbkVycm9yKSA9PiB0aGlzLnJlcXVlc3QoewogICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgb25FcnJvciwKICAgICAgICAgICAgICBvblJlc3BvbnNlCiAgICAgICAgICAgIH0pKSwgewogICAgICAgICAgICAgIGVycm9ySW5zdGFuY2U6IG5ldyBUaW1lb3V0RXJyb3IoeyBib2R5LCB1cmwgfSksCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0cywKICAgICAgICAgIHN1YnNjcmlwdGlvbnMsCiAg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G9uTWVzc2FnZSk7CiAgICAgICAgICBzb2NrZXQucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbkVycm9yKTsKICAgICAgICAgIHNvY2tldC5yZW1vdmVFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25NZXNzYWdlKHsgZGF0YSB9KSB7CiAgICAgICAgICBvblJlc3BvbnNlKEpTT04ucGFyc2UoZGF0YSkpOwogICAgICAgIH0KICAgICAgICBzb2NrZXQuYWRkRXZlbnRMaXN0ZW5lcigiY2xvc2UiLCBvbkNsb3NlXyk7CiAgICAgICAgc29ja2V0LmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBvbk1lc3NhZ2UpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsIG9uRXJyb3IpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICBpZiAoc29ja2V0LnJlYWR5U3RhdGUgPT09IFdlYlNvY2tldDMuQ09OTkVDVElORykgewogICAgICAgICAgYXdhaXQgbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICBpZiAoIXNvY2tldCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHNvY2tldC5vbm9wZW4gPSByZXNvbHZlOwogICAgICAgICAgICBzb2NrZXQub25lcnJvciA9IHJlamVjdDsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBjb25zdCB7IGNsb3NlOiBjbG9zZV8gfSA9IHNvY2tldDsKICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihzb2NrZXQsIHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBjbG9zZV8uYmluZChzb2NrZXQpKCk7CiAgICAgICAgICAgIG9uQ2xvc2UoKTsKICAgICAgICAgIH0sCiAgICAgICAgICBwaW5nKCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgV2ViU29ja2V0UmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgICBjYXVzZTogbmV3IFNvY2tldENsb3NlZEVycm9yKHsgdXJsOiBzb2NrZXQudXJsIH0pCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBjb25zdCBib2R5ID0gewogICAgICAgICAgICAgICAganNvbnJwYzogIjIuMCIsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICJuZXRfdmVyc2lvbiIsCiAgICAgICAgICAgICAgICBwYXJhbXM6IFtdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICBzb2NrZXQuc2VuZChKU09OLnN0cmluZ2lmeShib2R5KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0KHsgYm9keSB9KSB7CiAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IFdlYlNvY2tldFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgICBib2R5LAogICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgY2F1c2U6IG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybDogc29ja2V0LnVybCB9KQogICAgIC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YW1ldGVycykgewogICAgY29uc3QgeyBkb21haW4gPSB7fSwgbWVzc2FnZSwgcHJpbWFyeVR5cGUgfSA9IHBhcmFtZXRlcnM7CiAgICBjb25zdCB0eXBlcyA9IHsKICAgICAgRUlQNzEyRG9tYWluOiBnZXRUeXBlc0ZvckVJUDcxMkRvbWFpbih7IGRvbWFpbiB9KSwKICAgICAgLi4ucGFyYW1ldGVycy50eXBlcwogICAgfTsKICAgIHZhbGlkYXRlVHlwZWREYXRhKHsKICAgICAgZG9tYWluLAogICAgICBtZXNzYWdlLAogICAgICBwcmltYXJ5VHlwZSwKICAgICAgdHlwZXMKICAgIH0pOwogICAgY29uc3QgcGFydHMgPSBbIjB4MTkwMSJdOwogICAgaWYgKGRvbWFpbikKICAgICAgcGFydHMucHVzaChoYXNoRG9tYWluKHsKICAgICAgICBkb21haW4sCiAgICAgICAgdHlwZXMKICAgICAgfSkpOwogICAgaWYgKHByaW1hcnlUeXBlICE9PSAiRUlQNzEyRG9tYWluIikKICAgICAgcGFydHMucHVzaChoYXNoU3RydWN0KHsKICAgICAgICBkYXRhOiBtZXNzYWdlLAogICAgICAgIHByaW1hcnlUeXBlLAogICAgICAgIHR5cGVzCiAgICAgIH0pKTsKICAgIHJldHVybiBrZWNjYWsyNTYoY29uY2F0KHBhcnRzKSk7CiAgfQogIGZ1bmN0aW9uIGhhc2hEb21haW4oeyBkb21haW4sIHR5cGVzIH0pIHsKICAgIHJldHVybiBoYXNoU3RydWN0KHsKICAgICAgZGF0YTogZG9tYWluLAogICAgICBwcmltYXJ5VHlwZTogIkVJUDcxMkRvbWFpbiIsCiAgICAgIHR5cGVzCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gaGFzaFN0cnVjdCh7IGRhdGEsIHByaW1hcnlUeXBlLCB0eXBlcyB9KSB7CiAgICBjb25zdCBlbmNvZGVkID0gZW5jb2RlRGF0YSh7CiAgICAgIGRhdGEsCiAgICAgIHByaW1hcnlUeXBlLAogICAgICB0eXBlcwogICAgfS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pZiAodHlwZSA9PT0gImJ5dGVzIikKICAgICAgcmV0dXJuIHZhbHVlOwogICAgaWYgKHR5cGUgPT09ICJib29sIikKICAgICAgcmV0dXJuIHBhZChib29sVG9IZXgodmFsdWUpLCB7IHNpemU6IGlzQXJyYXkgPyAzMiA6IDEgfSk7CiAgICBjb25zdCBpbnRNYXRjaCA9IHR5cGUubWF0Y2goaW50ZWdlclJlZ2V4Mik7CiAgICBpZiAoaW50TWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBiYXNlVHlwZSwgYml0cyA9ICIyNTYiXSA9IGludE1hdGNoOwogICAgICBjb25zdCBzaXplMyA9IE51bWJlci5wYXJzZUludChiaXRzKSAvIDg7CiAgICAgIHJldHVybiBudW1iZXJUb0hleCh2YWx1ZSwgewogICAgICAgIHNpemU6IGlzQXJyYXkgPyAzMiA6IHNpemUzLAogICAgICAgIHNpZ25lZDogYmFzZVR5cGUgPT09ICJpbnQiCiAgICAgIH0pOwogICAgfQogICAgY29uc3QgYnl0ZXNNYXRjaCA9IHR5cGUubWF0Y2goYnl0ZXNSZWdleDIpOwogICAgaWYgKGJ5dGVzTWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBzaXplM10gPSBieXRlc01hdGNoOwogICAgICBpZiAoTnVtYmVyLnBhcnNlSW50KHNpemUzKSAhPT0gKHZhbHVlLmxlbmd0aCAtIDIpIC8gMikKICAgICAgICB0aHJvdyBuZXcgQnl0ZXNTaXplTWlzbWF0Y2hFcnJvcih7CiAgICAgICAgICBleHBlY3RlZFNpemU6IE51bWJlci5wYXJzZUludChzaXplMyksCiAgICAgICAgICBnaXZlblNpemU6ICh2YWx1ZS5sZW5ndGggLSAyKSAvIDIKICAgICAgICB9KTsKICAgICAgcmV0dXJuIHBhZCh2YWx1ZSwgeyBkaXI6ICJyaWdodCIsIHNpemU6IGlzQXJyYXkgPyAzMiA6IG51bGwgfSk7CiAgICB9CiAgICBjb25zdCBhcnJheU1hdGNoID0gdHlwZS5tYX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AgY29uc3Qgd3JhcHBlckFycmF5ID0gaGFzTmV0d29ya1dyYXBwZXIgPyB0cmFuc2FjdGlvbk9yV3JhcHBlckFycmF5LnNsaWNlKDEpIDogW107CiAgICBjb25zdCBbY2hhaW5JZCwgbm9uY2UsIG1heFByaW9yaXR5RmVlUGVyR2FzLCBtYXhGZWVQZXJHYXMsIGdhcywgdG8sIHZhbHVlLCBkYXRhLCBhY2Nlc3NMaXN0LCBtYXhGZWVQZXJCbG9iR2FzLCBibG9iVmVyc2lvbmVkSGFzaGVzLCB2LCByLCBzXSA9IHRyYW5zYWN0aW9uQXJyYXk7CiAgICBjb25zdCBbYmxvYnMsIGNvbW1pdG1lbnRzLCBwcm9vZnNdID0gd3JhcHBlckFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDExIHx8IHRyYW5zYWN0aW9uQXJyYXkubGVuZ3RoID09PSAxNCkpCiAgICAgIHRocm93IG5ldyBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uRXJyb3IoewogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGNoYWluSWQsCiAgICAgICAgICBub25jZSwKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAiZWlwNDg0NCIKICAgICAgfSk7CiAgICBjb25zdCB0cmFuc2FjdGlvbiA9IHsKICAgICAgYmxvYlZl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gdGhyb3cgbmV3IEludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25FcnJvcih7CiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2hhaW5JZCwKICAgICAgICAgIG5vbmNlLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBtYXhGZWVQZXJHYXMsCiAgICAgICAgICBnYXMsCiAgICAgICAgICB0bywKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGFjY2Vzc0xpc3QsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDkgPyB7CiAgICAgICAgICAgIHYsCiAgICAgICAgICAgIHIsCiAgICAgICAgICAgIHMKICAgICAgICAgIH0gOiB7fQogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uLAogICAgICAgIHR5cGU6ICJlaXAxNTU5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICBjaGFpbklkOiBoZXhUb051bWJlcihjaGFpbklkKSwKICAgICAgdHlwZTogImVpcDE1NTkiCiAgICB9OwogICAgaWYgKGlzSGV4KHRvKSAmJiB0byAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24udG8gPSB0bzsKICAgIGlmIChpc0hleChnYXMpICYmIGdhcyAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZ2FzID0gaGV4VG9CaWdJbnQoZ2FzKTsKICAgIGlmIChpc0hleChkYXRhKSAmJiBkYXRhICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5kYXRhID0gZGF0YTsKICAgIGlmIChpc0hleChub25jZSkgJiYgbm9uY2UgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLm5vbmNlID0gaGV4VG9OdW1iZXIobm9uY2UpOwogICAgaWYgKGlzSGV4KHZhbHVlKSAmJiB2YWx1ZSAhPT0gIjB4IikKICAgICAgd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LCBhY2Nlc3NMaXN0LCB2LCByLCBzXSA9IHRyYW5zYWN0aW9uQXJyYXk7CiAgICBpZiAoISh0cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA9PT0gOCB8fCB0cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA9PT0gMTEpKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBjaGFpbklkLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBnYXNQcmljZSwKICAgICAgICAgIGdhcywKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUsCiAgICAgICAgICBkYXRhLAogICAgICAgICAgYWNjZXNzTGlzdCwKICAgICAgICAgIC4uLnRyYW5zYWN0aW9uQXJyYXkubGVuZ3RoID4gOCA/IHsKICAgICAgICAgICAgdiwKICAgICAgICAgICAgciwKICAgICAgICAgICAgcwogICAgICAgICAgfSA6IHt9CiAgICAgICAgfSwKICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdHlwZTogImVpcDI5MzAiCiAgICAgIH0pOwogICAgY29uc3QgdHJhbnNhY3Rpb24gPSB7CiAgICAgIGNoYWluSWQ6IGhleFRvTnVtYmVyKGNoYWluSWQpLAogICAgICB0eXBlOiAiZWlwMjkzMCIKICAgIH07CiAgICBpZiAoaXNIZXgodG8pICYmIHRvICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi50byA9IHRvOwogICAgaWYgKGlzSGV4KGdhcykgJiYgZ2FzICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5nYXMgPSBoZXhUb0JpZ0ludChnYXMpOwogICAgaWYgKGlzSGV4KGRhdGEpICYmIGRhdGEgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmRhdGEgPSBkYXRhOwogICAgaWYgKGlzSGV4KG5vbmNlKSAmJiBub25jZSAhPT0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BcnJheS5sZW5ndGggPT09IDkpKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBub25jZSwKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDYgPyB7CiAgICAgICAgICAgIHY6IGNoYWluSWRPclZfLAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAibGVnYWN5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICB0eXBlOiAibGVnYWN5IgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvTnVtYmVyKG5vbmNlKTsKICAgIGlmIChpc0hleCh2YWx1ZSkgJiYgdmFsdWUgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnZhbHVlID0gaGV4VG9CaWdJbnQodmFsdWUpOwogICAgaWYgKGlzSGV4KGdhc1ByaWNlKSAmJiBnYX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HNlcmlhbGl6ZWRUcmFuc2FjdGlvbiA9IFsKICAgICAgdG9IZXgoY2hhaW5JZCksCiAgICAgIG5vbmNlID8gdG9IZXgobm9uY2UpIDogIjB4IiwKICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMgPyB0b0hleChtYXhQcmlvcml0eUZlZVBlckdhcykgOiAiMHgiLAogICAgICBtYXhGZWVQZXJHYXMgPyB0b0hleChtYXhGZWVQZXJHYXMpIDogIjB4IiwKICAgICAgZ2FzID8gdG9IZXgoZ2FzKSA6ICIweCIsCiAgICAgIHRvID8/ICIweCIsCiAgICAgIHZhbHVlID8gdG9IZXgodmFsdWUpIDogIjB4IiwKICAgICAgZGF0YSA/PyAiMHgiLAogICAgICBzZXJpYWxpemVkQWNjZXNzTGlzdCwKICAgICAgbWF4RmVlUGVyQmxvYkdhcyA/IHRvSGV4KG1heEZlZVBlckJsb2JHYXMpIDogIjB4IiwKICAgICAgYmxvYlZlcnNpb25lZEhhc2hlcyA/PyBbXSwKICAgICAgLi4udG9ZUGFyaXR5U2lnbmF0dXJlQXJyYXkodHJhbnNhY3Rpb24sIHNpZ25hdHVyZSkKICAgIF07CiAgICBjb25zdCBibG9icyA9IFtdOwogICAgY29uc3QgY29tbWl0bWVudHMgPSBbXTsKICAgIGNvbnN0IHByb29mcyA9IFtdOwogICAgaWYgKHNpZGVjYXJzKQogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNpZGVjYXJzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgY29uc3QgeyBibG9iLCBjb21taXRtZW50LCBwcm9vZiB9ID0gc2lkZWNhcnNbaV07CiAgICAgICAgYmxvYnMucHVzaChibG9iKTsKICAgICAgICBjb21taXRtZW50cy5wdXNoKGNvbW1pdG1lbnQpOwogICAgICAgIHByb29mcy5wdXNoKHByb29mKTsKICAgICAgfQogICAgcmV0dXJuIGNvbmNhdEhleChbCiAgICAgICIweDAzIiwKICAgICAgc2lkZWNhcnMgPyAoCiAgICAgICAgLy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AtIDI3bik7CiAgICAgICAgY29uc3QgdjIgPSAyN24gKyAoc2lnbmF0dXJlLnYgPT09IDI3biA/IDBuIDogMW4pOwogICAgICAgIGlmIChzaWduYXR1cmUudiAhPT0gdjIpCiAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZExlZ2FjeVZFcnJvcih7IHY6IHNpZ25hdHVyZS52IH0pOwogICAgICAgIHJldHVybiB2MjsKICAgICAgfSkoKTsKICAgICAgY29uc3QgciA9IHRyaW0oc2lnbmF0dXJlLnIpOwogICAgICBjb25zdCBzID0gdHJpbShzaWduYXR1cmUucyk7CiAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiA9IFsKICAgICAgICAuLi5zZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdG9IZXgodiksCiAgICAgICAgciA9PT0gIjB4MDAiID8gIjB4IiA6IHIsCiAgICAgICAgcyA9PT0gIjB4MDAiID8gIjB4IiA6IHMKICAgICAgXTsKICAgIH0gZWxzZSBpZiAoY2hhaW5JZCA+IDApIHsKICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gWwogICAgICAgIC4uLnNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0b0hleChjaGFpbklkKSwKICAgICAgICAiMHgiLAogICAgICAgICIweCIKICAgICAgXTsKICAgIH0KICAgIHJldHVybiB0b1JscChzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogIH0KICBmdW5jdGlvbiB0b1lQYXJpdHlTaWduYXR1cmVBcnJheSh0cmFuc2FjdGlvbiwgc2lnbmF0dXJlXykgewogICAgY29uc3Qgc2lnbmF0dXJlID0gc2lnbmF0dXJlXyA/PyB0cmFuc2FjdGlvbjsKICAgIGNvbnN0IHsgdiwgeVBhcml0eSB9ID0gc2lnbmF0dXJlOwogICAgaWYgKHR5cGVvZiBzaWduYXR1cmUuciA9PT0gInVuZGVmaW5lZCIpCiAgICAgIHJldHVybiBbXTsKICAgIGlmICh0eXBlb2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QoeyBhZGRyZXNzLCBjaGFpbklkIH0pIHsKICAgICAgICBjb25zdCBrZXkgPSBnZXRLZXkoeyBhZGRyZXNzLCBjaGFpbklkIH0pOwogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICBkZWx0YU1hcC5zZXQoa2V5LCBkZWx0YSArIDEpOwogICAgICB9LAogICAgICBhc3luYyBnZXQoeyBhZGRyZXNzLCBjaGFpbklkLCBjbGllbnQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgbGV0IHByb21pc2UgPSBwcm9taXNlTWFwLmdldChrZXkpOwogICAgICAgIGlmICghcHJvbWlzZSkgewogICAgICAgICAgcHJvbWlzZSA9IChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgY29uc3Qgbm9uY2UgPSBhd2FpdCBzb3VyY2UuZ2V0KHsgYWRkcmVzcywgY2hhaW5JZCwgY2xpZW50IH0pOwogICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzTm9uY2UgPSBub25jZU1hcC5nZXQoa2V5KSA/PyAwOwogICAgICAgICAgICAgIGlmIChwcmV2aW91c05vbmNlID4gMCAmJiBub25jZSA8PSBwcmV2aW91c05vbmNlKQogICAgICAgICAgICAgICAgcmV0dXJuIHByZXZpb3VzTm9uY2UgKyAxOwogICAgICAgICAgICAgIG5vbmNlTWFwLmRlbGV0ZShrZXkpOwogICAgICAgICAgICAgIHJldHVybiBub25jZTsKICAgICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgICB0aGlzLnJlc2V0KHsgYWRkcmVzcywgY2hhaW5JZCB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkoKTsKICAgICAgICAgIHByb21pc2VNYXAuc2V0KGtleSwgcHJvbWlzZSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGRlbHRhID0g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mUpCiAgICAgICAgICB0aHJvdyByZXN1bHQucmVhc29uOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY2h1bmtlZENhbGxzW2ldLmxlbmd0aDsgaisrKSB7CiAgICAgICAgICByZXN1bHRzLnB1c2goewogICAgICAgICAgICBzdGF0dXM6ICJmYWlsdXJlIiwKICAgICAgICAgICAgZXJyb3I6IHJlc3VsdC5yZWFzb24sCiAgICAgICAgICAgIHJlc3VsdDogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QgYWdncmVnYXRlM1Jlc3VsdCA9IHJlc3VsdC52YWx1ZTsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBhZ2dyZWdhdGUzUmVzdWx0Lmxlbmd0aDsgaisrKSB7CiAgICAgICAgY29uc3QgeyByZXR1cm5EYXRhLCBzdWNjZXNzIH0gPSBhZ2dyZWdhdGUzUmVzdWx0W2pdOwogICAgICAgIGNvbnN0IHsgY2FsbERhdGEgfSA9IGNodW5rZWRDYWxsc1tpXVtqXTsKICAgICAgICBjb25zdCB7IGFiaTogYWJpMiwgYWRkcmVzcywgZnVuY3Rpb25OYW1lLCBhcmdzIH0gPSBjb250cmFjdHMyW3Jlc3VsdHMubGVuZ3RoXTsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGNhbGxEYXRhID09PSAiMHgiKQogICAgICAgICAgICB0aHJvdyBuZXcgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yKCk7CiAgICAgICAgICBpZiAoIXN1Y2Nlc3MpCiAgICAgICAgICAgIHRocm93IG5ldyBSYXdDb250cmFjdEVycm9yKHsgZGF0YTogcmV0dXJuRGF0YSB9KTsKICAgICAgICAgIGNvbnN0IHJlc3VsdDIgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgZGF0YTogcmV0dXJuRGF0YSwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIHJlc3VsdHMucHVzaChhbGxvd0ZhaWx1cmUgPyB7IHJlc3VsdDogcmVzdWx0Miwgc3RhdHVzOiAic3VjY2VzcyIgfSA6IHJlc3VsdDIpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2RvY3MvY29udHJhY3QvbXVsdGljYWxsIiwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIGlmICghYWxsb3dGYWlsdXJlKQogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIHJlc3VsdHMucHVzaCh7IGVycm9yLCByZXN1bHQ6IHZvaWQgMCwgc3RhdHVzOiAiZmFpbHVyZSIgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAocmVzdWx0cy5sZW5ndGggIT09IGNvbnRyYWN0czIubGVuZ3RoKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigibXVsdGljYWxsIHJlc3VsdHMgbWlzbWF0Y2giKTsKICAgIHJldHVybiByZXN1bHRzOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL3ZlcmlmeUhhc2guanMKICBpbml0X2FiaXMoKTsKICBpbml0X2NvbnRyYWN0cygpOwogIGluaXRfY29udHJhY3QoKTsKICBpbml0X2VuY29kZURlcGxveURhdGEoKTsKICBpbml0X2dldEFkZHJlc3MoKTsKICBpbml0X2lzQWRkcmVzc0VxdWFsKCk7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pZW50LnRyYW5zcG9ydC50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIgJiYgY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzWzBdLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIHJldHVybiB0cnVlOwogICAgfSkoKTsKICAgIGxldCBwcmV2QmxvY2tOdW1iZXI7CiAgICBjb25zdCBwb2xsQmxvY2tOdW1iZXIgPSAoKSA9PiB7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaEJsb2NrTnVtYmVyIiwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGVtaXRPbkJlZ2luLAogICAgICAgIGVtaXRNaXNzZWQsCiAgICAgICAgcG9sbGluZ0ludGVydmFsCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uQmxvY2tOdW1iZXIsIG9uRXJyb3IgfSwgKGVtaXQpID0+IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7IGNhY2hlVGltZTogMCB9KTsKICAgICAgICAgIGlmIChwcmV2QmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgaWYgKGJsb2NrTnVtYmVyID09PSBwcmV2QmxvY2tOdW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2tOdW1iZXIgLSBwcmV2QmxvY2tOdW1iZXIgPiAxICYmIGVtaXRNaXNzZWQpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBpID0gcHJldkJsb2NrTnVtYmVyICsgMW47IGkgPCBibG9ja051bWJlcjsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoaSwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoIXByZXZCbG9ja051bWJlciB8fCBibG9ja051bWJlciA+IHByZXZCbG9ja051bWJlcikgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoYmxvY2tOdW1iZXIsIHByZXZCbG9ja051bWJlcik7CiAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja051bWJlciA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQmxvY2tOdW1iZXIiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZW1pdE9uQmVnaW4sCiAgICAgICAgZW1pdE1pc3NlZAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrTnVtYmVyLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IGFjdGl2ZSA9IHRydWU7CiAgICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIikgewogICAgICAgICAgICAgICAgY29uc3QgdHJhbnNwb3J0MiA9IGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0cy5maW5kKCh0cmFuc3BvcnQzKSA9PiB0cmFuc3BvcnQzLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0Iik7CiAgICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICAgICAgcmV0dXJuIHRyYW5zcG9ydDIudmFsdWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJuZXdIZWFkcyJdLAogICAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2tOdW1iZXIgPSBoZXhUb0JpZ0ludChkYXRhLnJlc3VsdD8ubnVtYmVyKTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9ja051bWJlcihibG9ja051bWJlciwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgICAgZW1pdC5vbkVycm9yPy4o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cHQpIHsKICAgICAgICAgICAgICBpZiAoY29uZmlybWF0aW9ucyA+IDEgJiYgKCFyZWNlaXB0LmJsb2NrTnVtYmVyIHx8IGJsb2NrTnVtYmVyIC0gcmVjZWlwdC5ibG9ja051bWJlciArIDFuIDwgY29uZmlybWF0aW9ucykpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgZG9uZSgoKSA9PiBlbWl0LnJlc29sdmUocmVjZWlwdCkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgIGF3YWl0IHdpdGhSZXRyeShhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uLCAiZ2V0VHJhbnNhY3Rpb24iKSh7IGhhc2g6IGhhc2gzIH0pOwogICAgICAgICAgICAgICAgaWYgKHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyKQogICAgICAgICAgICAgICAgICBibG9ja051bWJlciA9IHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgcmV0cnlDb3VudAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIHJldHJ5aW5nID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVjZWlwdCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uUmVjZWlwdCwgImdldFRyYW5zYWN0aW9uUmVjZWlwdCIpKHsgaGFzaDogaGFzaDMgfSk7CiAgICAgICAgICAgIGlmIChjb25maXJtYXRpb25zID4gMSAmJiAoIXJlY2VpcHQuYmxvY2tOdW1iZXIgfHwgYmxvY2tOdW1iZXIgLSByZWNlaXB0LmJsb2NrTnVtYmVyICsgMW4gPCBjb25maXJtYXRpb25zKSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZXNvbHZlKHJlY2VpcHQpKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVHJhbnNhY3Rpb25Ob3RGb3VuZEVycm9yIHx8IGVyciBpbnN0YW5jZW9mIFRyYW5zYWN0aW9uUmVjZWlwdE5vdEZvdW5kRXJyb3IpIHsKICAgICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgICByZXRyeWluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiA9IHRyYW5zYWN0aW9uOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCB3aXRoUmV0cnkoKCkgPT4gZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHsKICAgICAgICAgICAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVUcmFuc2FjdGlvbnM6IHRydWUKICAgICAgICAgICAgICAgIH0pLCB7CiAgICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgICByZXRyeUNvdW50LAogICAgICAgICAgICAgICAgICBzaG91bGRSZXRyeTogKHsgZXJyb3IgfSkgPT4gZXJyb3IgaW5zdGFuY2VvZiBCbG9ja05vdEZvdW5kRXJyb3IKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcGxhY2VtZW50VHJhbnNhY3Rpb24gPSBibG9jay50cmFuc2FjdGlvbnMuZmluZCgoeyBmcm9tLCBub25jZSB9KSA9PiBmcm9tID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLmZyb20gJiYgbm9uY2UgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24ubm9uY2UpOwogICAgICAgICAgICAgICAgaWYgKCFyZXBsYWNlbWVudFRyYW5zYWN0aW9uKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICByZWNlaXB0ID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0VHJhbnNhY3Rpb25SZWNlaXB0LCAiZ2V0VHJhbnNhY3Rpb25SZWNlaXB0IikoewogICAgICAgICAgICAgICAgICBoYXNoOiByZXBsYWNlbWVudFRyYW5zYWN0aW9uLmhhc2gKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgaWYgKGNvbmZpcm1hdGlvbnMgPiAxICYmICghcmVjZWlwdC5ibG9ja051bWJlciB8fCBibG9ja051bWJlciAtIHJlY2VpcHQuYmxvY2tOdW1iZXIgKyAxbiA8IGNvbmZpcm1hdGlvbnMpKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgcmVhc29uID0gInJlcGxhY2VkIjsKICAgICAgICAgICAgICAgIGlmIChyZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24udmFsdWUpIHsKICAgICAgICAgICAgICAgICAgcmVhc29uID0gInJlcHJpY2VkIjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVwbGFjZW1lbnRUcmFuc2FjdGlvbi5mcm9tID09PSByZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IDBuKSB7CiAgICAgICAgICAgICAgICAgIHJlYXNvbiA9ICJjYW5jZWxsZWQiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZG9uZSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgIGVtaXQub25SZXBsYWNlZD8uKHsKICAgICAgICAgICAgICAgICAgICByZWFzb24sCiAgICAgICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbjogcmVwbGFjZW1lbnRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvblJlY2VpcHQ6IHJlY2VpcHQKICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgIGVtaXQucmVzb2x2ZShyZWNlaXB0KTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0gY2F0Y2ggKGVycl8pIHsKICAgICAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZWplY3QoZXJyXykpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBkb25lKCgpID0+IGVtaXQucmVqZWN0KGVycikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9KTsKICAgIH0pOwogICAgcmV0dXJuIHByb21pc2U7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vYWN0aW9ucy9wdWJsaWMvd2F0Y2hCbG9ja3MuanMKICBpbml0X3N0cmluZ2lmeSgpOwogIGZ1bmN0aW9uIHdhdGNoQmxvY2tzKGNsaWVudCwgeyBibG9ja1RhZyA9ICJsYXRlc3QiLCBlbWl0TWlzc2VkID0gZmFsc2UsIGVtaXRPbkJlZ2luID0gZmF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GFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRCbG9jaywgImdldEJsb2NrIikoewogICAgICAgICAgICBibG9ja1RhZywKICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoYmxvY2subnVtYmVyICYmIHByZXZCbG9jaz8ubnVtYmVyKSB7CiAgICAgICAgICAgIGlmIChibG9jay5udW1iZXIgPT09IHByZXZCbG9jay5udW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2subnVtYmVyIC0gcHJldkJsb2NrLm51bWJlciA+IDEgJiYgZW1pdE1pc3NlZCkgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSBwcmV2QmxvY2s/Lm51bWJlciArIDFuOyBpIDwgYmxvY2subnVtYmVyOyBpKyspIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrMiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgICAgIGJsb2NrTnVtYmVyOiBpLAogICAgICAgICAgICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9jayhibG9jazIsIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoCiAgICAgICAgICAgIC8vIElmIG5vIHByZXZpb3VzIGJsb2NrIGV4aXN0cywgZW1pdC4KICAgICAgICAgICAgIXByZXZCbG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBibG9jayB0YWcgaXMgInBlbmRpbmciIHdpdGggbm8gYmxvY2sgbnVtYmVyLCBlbWl0LgogICAgICAgICAgICBibG9ja1RhZyA9PT0gInBlbmRpbmciICYmICFibG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBuZXh0IGJsb2NrIG51bWJlciBpcyBncmVhdGVyIHRoYW4gdGhlIHByZXZpb3VzIGJsb2NrIG51bWJlciwgZW1pdC4KICAgICAgICAgICAgLy8gV2UgZG9uJ3Qgd2FudCB0byBlbWl0IGJsb2NrcyBpbiB0aGUgcGFzdC4KICAgICAgICAgICAgYmxvY2subnVtYmVyICYmIGJsb2NrLm51bWJlciA+IHByZXZCbG9jay5udW1iZXIKICAgICAgICAgICkgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgIHByZXZCbG9jayA9IGJsb2NrOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja3MgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgZW1pdEZldGNoZWQgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGVtaXRPbkJlZ2luKSB7CiAgICAgICAgICAgIGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgICB9KS50aGVuKChibG9jaykgPT4gewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGlmICghZW1pdEZldGNoZWQpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgb25CbG9jayhibG9jaywgdm9pZCAwKTsKICAgICAgICAgICAgICBlbWl0RmV0Y2hlZCA9IGZhbHNlOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibmV3SGVhZHMiXSwKICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBjb25zdCBmb3JtYXQgPSBjbGllbnQuY2hhaW4/LmZvcm1hdHRlcnM/LmJsb2NrPy5mb3JtYXQgfHwgZm9ybWF0QmxvY2s7CiAg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CiAgICBjb25zdCBlbmFibGVQb2xsaW5nID0gKCgpID0+IHsKICAgICAgaWYgKHR5cGVvZiBwb2xsXyAhPT0gInVuZGVmaW5lZCIpCiAgICAgICAgcmV0dXJuIHBvbGxfOwogICAgICBpZiAodHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJ3ZWJTb2NrZXQiKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIiAmJiBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHNbMF0uY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9KSgpOwogICAgY29uc3Qgc3RyaWN0ID0gc3RyaWN0XyA/PyBmYWxzZTsKICAgIGNvbnN0IHBvbGxFdmVudCA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoRXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50LAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBmcm9tQmxvY2sKICAgICAgXSk7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IHByZXZpb3VzQmxvY2tOdW1iZXI7CiAgICAgICAgaWYgKGZyb21CbG9jayAhPT0gdm9pZCAwKQogICAgICAgICAgcHJldmlvdXNCbG9ja051bWJlciA9IGZyb21CbG9jayAtIDFuOwogICAgICAgIGxldCBmaWx0ZXI7CiAgICAgICAgbGV0IGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgY29uc3QgdW53YXRjaCA9IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgICAgaWYgKCFpbml0aWFsaXplZCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZUV2ZW50RmlsdGVyLCAiY3JlYXRlRXZlbnRGaWx0ZXIiKSh7CiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIGV2ZW50LAogICAgICAgICAgICAgICAgZXZlbnRzLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciAhPT0gYmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgICAgIGxvZ3MgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRMb2dzLCAiZ2V0TG9ncyIpKHsKICAgICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgICAgZXZlbnQsCiAgICAgICAgICAgICAgICAgIGV2ZW50cywKICAgICAgICAgICAgICAgICAgZnJvbUJsb2NrOiBwcmV2aW91c0Jsb2NrTnVtYmVyICsgMW4sCiAgICAgICAgICAgICAgICAgIHRvQmxvY2s6IGJsb2NrTnVtYmVyCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUV2ZW50ID0gKCkgPT4gewogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBldmVudHNfID0gZXZlbnRzID8/IChldmVudCA/IFtldmVudF0gOiB2b2lkIDApOwogICAgICAgICAgbGV0IHRvcGljcyA9IFtdOwogICAgICAgICAgaWYgKGV2ZW50c18pIHsKICAgICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50c18uZmxhdE1hcCgoZXZlbnQyKSA9PiBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgICAgICAgICAgYWJpOiBbZXZlbnQyXSwKICAgICAgICAgICAgICBldmVudE5hbWU6IGV2ZW50Mi5uYW1lLAogICAgICAgICAgICAgIGFyZ3MKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB0b3BpY3MgPSBbZW5jb2RlZF07CiAgICAgICAgICAgIGlmIChldmVudCkKICAgICAgICAgICAgICB0b3BpY3MgPSB0b3BpY3NbMF07CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibG9ncyIsIHsgYWRkcmVzcywgdG9waWNzIH1dLAogICAgICAgICAgICBvbkRhdGEoZGF0YSkgewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGNvbnN0IGxvZyA9IGRhdGEucmVzdWx0OwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBjb25zdCB7IGV2ZW50TmFtZSwgYXJnczogYXJnczIgfSA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgICAgICAgICAgYWJpOiBldmVudHNfID8/IFtdLAogICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgdG9waWNzOiBsb2cudG9waWNzLAogICAgICAgICAgICAgICAgICBzdHJpY3QKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgeyBhcmdzOiBhcmdzMiwgZXZlbnROYW1lIH0pOwogICAgICAgICAgICAgICAgb25Mb2dzKFtmb3JtYXR0ZWRdKTsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIGxldCBldmVudE5hbWU7CiAgICAgICAgICAgICAgICBsZXQgaXNVbm5hbWVkOwogICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIERlY29kZUxvZ0RhdGFNaXNtYXRjaCB8fCBlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCkgewogICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgIGV2ZW50TmFtZSA9IGVyci5hYmlJdGVtLm5hbWU7CiAgICAgICAgICAgICAgICAgIGlzVW5uYW1lZCA9IGVyci5hYmlJdGVtLmlucHV0cz8uc29tZSgoeCkgPT4gISgibmFtZSIgaW4geCAmJiB4Lm5hbWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZCA9IGZvcm1hdExvZyhsb2csIHsKICAgICAgICAgICAgICAgICAgYXJnczogaXNVbm5hbWVkID8gW10gOiB7fSwKICAgICAgICAgICAgICAgICAgZXZlbnROYW1lCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LAogICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICB1bnN1YnNjcmliZSA9IHVuc3Vic2NyaWJlXzsKICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICB1bnN1YnNjcmliZSgpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgb25FcnJvcj8uKGVycik7CiAgICAgICAgfQogICAgICB9KSgpOwogICAgICByZXR1cm4gKCkgPT4gdW5zdWJzY3JpYmUoKTsKICAgIH07CiAgICByZXR1cm4gZW5hYmxlUG9sbGluZyA/IHBvbGxFdmVudCgpIDogc3Vic2NyaWJlRX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ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciwgImNyZWF0ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciIpKHt9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIHVud2F0Y2goKTsKICAgICAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgaGFzaGVzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgaWYgKGhhc2hlcy5sZW5ndGggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmF0Y2gpCiAgICAgICAgICAgICAgZW1pdC5vblRyYW5zYWN0aW9ucyhoYXNoZXMpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBoYXNoMyBvZiBoYXNoZXMpCiAgICAgICAgICAgICAgICBlbWl0Lm9uVHJhbnNhY3Rpb25zKFtoYXNoM10pOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZVBlbmRpbmdUcmFuc2FjdGlvbnMgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgeyB1bnN1YnNjcmliZTogdW5zdWJzY3JpYmVfIH0gPSBhd2FpdCBjbGllbnQudHJhbnNwb3J0LnN1YnNjcmliZSh7CiAgICAgICAgICAgIHBhcmFtczogWyJuZXdQZW5kaW5nVHJhbnNhY3Rpb25zIl0sCiAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgaWYgKCFhY3RpdmUpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICBvblRyYW5zYWN0aW9ucyhbdHJhbnNhY3Rpb25dKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIG9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgdW5zdWJzY3JpYmUoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgIH0KICAgICAgfSkoKTsKICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsUGVuZGluZ1RyYW5zYWN0aW9ucygpIDogc3Vic2NyaWJlUGVuZGluZ1RyYW5zYWN0aW9ucygp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ICAgICAgdGhyb3cgbmV3IFVybFJlcXVpcmVkRXJyb3IoKTsKICAgICAgcmV0dXJuIGNyZWF0ZVRyYW5zcG9ydCh7CiAgICAgICAga2V5LAogICAgICAgIG5hbWUsCiAgICAgICAgYXN5bmMgcmVxdWVzdCh7IG1ldGhvZCwgcGFyYW1zIH0pIHsKICAgICAgICAgIGNvbnN0IGJvZHkgPSB7IG1ldGhvZCwgcGFyYW1zIH07CiAgICAgICAgICBjb25zdCBycGNDbGllbnQgPSBhd2FpdCBnZXRXZWJTb2NrZXRScGNDbGllbnQodXJsXywgewogICAgICAgICAgICBrZWVwQWxpdmUsCiAgICAgICAgICAgIHJlY29ubmVjdAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCB7IGVycm9yLCByZXN1bHQgfSA9IGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0QXN5bmMoewogICAgICAgICAgICBib2R5LAogICAgICAgICAgICB0aW1lb3V0CiAgICAgICAgICB9KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogIndlYlNvY2tldCIKICAgICAgfSwgewogICAgICAgIGdldFNvY2tldCgpIHsKICAgICAgICAgIHJldHVybiBnZXRTb2NrZXQodXJsXyk7CiAgICAgICAgfSwKICAgICAgICBnZXRScGNDbGllbnQoKSB7CiAgICAgICAgICByZXR1cm4gZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgIH0sCiAgICAgICAgYXN5bmMgc3Vic2NyaWJlKHsgcGFyYW1zLCBvbkRhdGEsIG9uRXJyb3IgfSkgewogICAgICAgICAgY29uc3QgcnBjQ2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgICAgY29uc3QgeyByZXN1bHQ6IHN1YnNjcmlwdGlvbklkIH0gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIGJvZHk6IHsKICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfc3Vic2NyaWJlIiwKICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIHJlamVjdChlcnJvcik7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuZXJyb3IpIHsKICAgICAgICAgICAgICAgIHJlamVjdChyZXNwb25zZS5lcnJvcik7CiAgICAgICAgICAgICAgICBvbkVycm9yPy4ocmVzcG9uc2UuZXJyb3IpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc3BvbnNlLmlkID09PSAibnVtYmVyIikgewogICAgICAgICAgICAgICAgcmVzb2x2ZShyZXNwb25zZSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChyZXNwb25zZS5tZXRob2QgIT09ICJldGhfc3Vic2NyaXB0aW9uIikKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBvbkRhdGEocmVzcG9uc2UucGFyYW1zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgc3Vic2NyaXB0aW9uSWQsCiAgICAgICAgICAgIGFzeW5jIHVuc3Vic2NyaWJlKCkgewogICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4gcnBjQ2xpZW50LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfdW5zdWJzY3JpYmUiLAogICAgICAgICAgICAgICAgICBwYXJhbXM6IFtzdWJzY3JpcHRpb25JZF0KICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiByZXNvbHZlCiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgfSk7CiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2luZGV4LmpzCiAgaW5pdF9hYmlzKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvYWRkcmVzcy5qcwogIHZhciB6ZXJvQWRkcmVzcyA9ICIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAiOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vaW5kZXguanMKICBpbml0X2NvbnRyYWN0cygpOwogIGluaXRfdW5pdCgpOwogIGluaXRfbnVtYmVyKCk7CiAgaW5pdF9hYmkoKTsKICBpbml0X2Jhc2UoKTsKICBpbml0X2NvbnRyYWN0KCk7CiAgaW5pdF9ycGMoKTsKICBpbml0X2NoYWluKCk7CiAgaW5pdF9lbmNvZGluZygpOwogIGluaXRfbm9kZSgpOwogIGlu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GwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICAgIHRyYW5zYWN0aW9uUmVjZWlwdDogLyogQF9fUFVSRV9fICovIGRlZmluZVRyYW5zYWN0aW9uUmVjZWlwdCh7CiAgICAgIGZvcm1hdChhcmdzKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGwxQmF0Y2hOdW1iZXI6IGFyZ3MubDFCYXRjaE51bWJlciA/IGhleFRvQmlnSW50KGFyZ3MubDFCYXRjaE51bWJlcikgOiBudWxsLAogICAgICAgICAgbDFCYXRjaFR4SW5kZXg6IGFyZ3MubDFCYXRjaFR4SW5kZXggPyBoZXhUb0JpZ0ludChhcmdzLmwxQmF0Y2hUeEluZGV4KSA6IG51bGwsCiAgICAgICAgICBsb2dzOiBhcmdzLmxvZ3MubWFwKChsb2cpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAuLi5mb3JtYXRMb2cobG9nKSwKICAgICAgICAgICAgICBsMUJhdGNoTnVtYmVyOiBsb2cubDFCYXRjaE51bWJlciA/IGhleFRvQmlnSW50KGxvZy5sMUJhdGNoTnVtYmVyKSA6IG51bGwsCiAgICAgICAgICAgICAgdHJhbnNhY3Rpb25Mb2dJbmRleDogaGV4VG9OdW1iZXIobG9nLnRyYW5zYWN0aW9uTG9nSW5kZXgpLAogICAgICAgICAgICAgIGxvZ1R5cGU6IGxvZy5sb2dUeXBlCiAgICAgICAgICAgIH07CiAgICAgICAgICB9KSwKICAgICAgICAgIGwyVG9MMUxvZ3M6IGFyZ3MubDJUb0wxTG9ncy5tYXAoKGwyVG9MMUxvZykgPT4gewogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIGJsb2NrTnVtYmVyOiBoZXhUb0JpZ0ludChsMlRvTDFMb2cuYmxvY2tIYXNoKSwKICAgICAgICAgICAgICBibG9ja0hhc2g6IGwyVG9MMUxvZy5ibG9ja0hhc2gsCiAgICAgICAgICAgICAgbDFCYXRjaE51bWJlcjogaGV4VG9CaWdJbnQobDJUb0wxTG9nLmwxQmF0Y2hOdW1iZXIpLAogICAgICAgICAgICAgIHRyYW5zYWN0aW9uSW5kZXg6IGhleFRvQmlnSW50KGwyVG9MMUxvZy50cmFuc2FjdGlvbkluZGV4KSwKICAgICAgICAgICAgICBzaGFyZElkOiBoZXhUb0JpZ0ludChsMlRvTDFMb2cuc2hhcmRJZCksCiAgICAgICAgICAgICAgaXNTZXJ2aWNlOiBsMlRvTDFMb2cuaXNTZXJ2aWNlLAogICAgICAgICAgICAgIHNlbmRlcjogbDJUb0wxTG9nLnNlbmRlciwKICAgICAgICAgICAgICBrZXk6IGwyVG9MMUxvZy5rZXksCiAgICAgICAgICAgICAgdmFsdWU6IGwyVG9MMUxvZy52YWx1ZSwKICAgICAgICAgICAgICB0cmFuc2FjdGlvbkhhc2g6IGwyVG9MMUxvZy50cmFuc2FjdGlvbkhhc2gsCiAgICAgICAgICAgICAgbG9nSW5kZXg6IGhleFRvQmlnSW50KGwyVG9MMUxvZy5sb2dJbmRleCkKICAgICAgICAgICAgfTsKICAgICAgICAgIH0pCiAgICAgICAgfTsKICAgICAgfQogICAgfSksCiAgICB0cmFuc2FjdGlvblJlcXVlc3Q6IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVUcmFuc2FjdGlvblJlcXVlc3QoewogICAgICBleGNsdWRlOiBbCiAgICAgICAgImN1c3RvbVNpZ25hdHVyZSIsCiAgICAgICAgImZhY3RvcnlEZXBzIiwKICAgICAgICAiZ2FzUGVyUHViZGF0YSIsCiAgICAgICAgInBheW1hc3RlciIsCiAgICAgICAgInBheW1hc3RlcklucHV0IgogICAgICBdLAogICAgICBmb3JtYXQoYXJncykgewogICAgICAgIGlmIChhcmdzLmdhc1BlclB1YmRhdGEgfHwgYXJncy5wYXltYXN0ZXIgJiYgYXJncy5wYXltYXN0ZXJJbnB1dCB8fCBhcmdzLmZhY3RvcnlEZXBzIHx8IGFyZ3MuY3VzdG9tU2lnbmF0dXJlKQogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgZWlwNzEyTWV0YTogewogICAgICAgICAgICAgIC4uLmFyZ3MuZ2FzUGVyUHViZGF0YSA/IHsgZ2FzUGVyUHViZGF0YTogdG9IZXgoYXJncy5nYXNQZXJQdWJkYXRhKSB9IDogeyBnYXNQZXJQdWJkYXRhOiB0b0hleChnYXNQZXJQdWJkYXRhRGVmYXVsdCkgfSwKICAgICAgICAgICAgICAuLi5hcmdzLnBheW1hc3RlciAmJiBhcmdzLnBheW1hc3RlcklucHV0ID8gewogICAgICAgICAgICAgICAgcGF5bWFzdGVyUGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgIHBheW1hc3RlcjogYXJncy5wYXltYXN0ZXIsCiAgICAgICAgICAgICAgICAgIHBheW1hc3RlcklucHV0OiBBcnJheS5mcm9tKGhleFRvQnl0ZXMoYXJncy5wYXltYXN0ZXJJbnB1dCkpCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSA6IHt9LAogICAgICAgICAgICAgIC4uLmFyZ3MuZmFjdG9yeURlcHMgPyB7CiAgICAgICAgICAgICAgICBmYWN0b3J5RGVwczogYXJncy5mYWN0b3J5RGVwcy5tYXAoKGRlcCkgPT4gQXJyYXkuZnJvbShoZXhUb0J5dGVzKGRlcCkpKQogICAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgICAuLi5hcmdzLmN1c3RvbVNpZ25hdHVyZSA/IHsKICAgICAgICAgICAgICAgIGN1c3RvbVNpZ25hdHVyZTogQXJyYXkuZnJvbShoZXhUb0J5dGVzKGFyZ3MuY3VzdG9tU2lnbmF0dXJlKSkKICAgICAgICAgICAgICB9IDoge30KICAgICAgICAgICAgfSwKICAgICAgICAgICAgdHlwZTogIjB4NzEiCiAgICAgICAgICB9OwogICAgICAgIHJldHVybiB7fTsKICAgICAgfQogICAgfSkKICB9OwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy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OC5nZyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkFuY2llbnQ4IGV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NjYW4uYW5jaWVudDguZ2ciLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vc2Nhbi5hbmNpZW50OC5nZy9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWRdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhCMDlEQzA4NDI4QzhiNEVGQjRmZjlDMDgyNzM4NkNERjM0Mjc3OTk2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkXTogewogICAgICAgICAgYWRkcmVzczogIjB4NjM5RjJBRUNFMzk4QWE3NmIwN2U1OWVGNmFiZTJjRmUzMmJhY2I2OCIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MDcwNTcxCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkXTogewogICAgICAgICAgYWRkcmVzczogIjB4ZDVlM2VEZjViNjgxMzVENTU5RDU3MkUyNmJGODYzRkJDMTk1MDAzMyIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MDcwNTcxCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9hbmNpZW50OFNlcG9saWEuanMKICB2YXIgc291cmNlSWQyID0gMTExNTUxMTE7Ci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vZGUuY29tIiwKICAgICAgICAgICJodHRwczovL3JwYzIuYmFoYW11dC5pbyIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3dzMS5zYWhhcmEuYmFoYW11dGNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vYmFoYW11dC1ycGMucHVibGljbm9kZS5jb20iLAogICAgICAgICAgIndzczovL3dzMi5zYWhhcmEuYmFoYW11dGNoYWluLmNvbSIKICAgICAgICBdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZ0bnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vd3d3LmZ0bnNjYW4uY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3d3dy5mdG5zY2FuLmNvbS9hcGkiCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9iYXNlLmpzCiAgdmFyIHNvdXJjZUlkNiA9IDE7CiAgdmFyIGJhc2UgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDg0NTMsCiAgICBuYW1lOiAiQmFzZSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tYWlubmV0LmJhc2Uub3JnIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiQmFzZXNjYW4iLAogICAgICAgIHVybDog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KICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIG5hbWU6ICJCaXRjb2luIiwKICAgICAgc3ltYm9sOiAiQlRDIiwKICAgICAgZGVjaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLmJzcXVhcmVkLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJibG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuYnNxdWFyZWQubmV0d29yayIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9idHIuanMKICB2YXIgYnRyID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMDA5MDEsCiAgICBuYW1lOiAiQml0bGF5ZXIiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgbmFtZTogIkJpdGNvaW4iLAogICAgICBzeW1ib2w6ICJCVEMiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbCiAgICAgICAgICAiaHR0cHM6Ly9ycGMuYml0bGF5ZXIub3JnIiwKICAgICAgICAgICJodHRwczovL3JwYy5iaXRsYXllci1ycGMuY29tIiwKICAgICAgICAgICJodHRwczovL3JwYy5hbmtyLmNvbS9iaXRsYXllciIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly93cy5iaXRsYXllci5vcmciLCAid3NzOi8vd3MuYml0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hUb0JpZ0ludCh0cmFuc2FjdGlvbi5nYXRld2F5RmVlKSwKICAgICAgICAgICAgICBnYXRld2F5RmVlUmVjaXBpZW50OiB0cmFuc2FjdGlvbi5nYXRld2F5RmVlUmVjaXBpZW50CiAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgZmVlQ3VycmVuY3k6IHRyYW5zYWN0aW9uLmZlZUN1cnJlbmN5CiAgICAgICAgICB9OwogICAgICAgIH0pOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICB0cmFuc2FjdGlvbnMsCiAgICAgICAgICAuLi5hcmdzLnJhbmRvbW5lc3MgPyB7IHJhbmRvbW5lc3M6IGFyZ3MucmFuZG9tbmVzcyB9IDoge30KICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICAgIHRyYW5zYWN0aW9uOiAvKiBAX19QVVJFX18gKi8gZGVmaW5lVHJhbnNhY3Rpb24oewogICAgICBmb3JtYXQoYXJncykgewogICAgICAgIGlmIChhcmdzLnR5cGUgPT09ICIweDdlIikKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIGlzU3lzdGVtVHg6IGFyZ3MuaXNTeXN0ZW1UeCwKICAgICAgICAgICAgbWludDogYXJncy5taW50ID8gaGV4VG9CaWdJbnQoYXJncy5taW50KSA6IHZvaWQgMCwKICAgICAgICAgICAgc291cmNlSGFzaDogYXJncy5zb3VyY2VIYXNoLAogICAgICAgICAgICB0eXBlOiAiZGVwb3NpdCIKICAgICAgICAgIH07CiAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSB7IGZlZUN1cnJlbmN5OiBhcmdzLmZlZUN1cnJlbmN5IH07CiAgICAgICAgaWYgKGFyZ3MudHlwZSA9PT0gIjB4N2IiKQogICAgICAgICAgdHJhbnNhY3Rpb24udHlwZSA9ICJjaXA2NCI7CiAgICAgICAgZWxzZSB7CiAgICAgICAgICBpZiAoYXJncy50eXBlID09PSAiMHg3YyIpCiAgICAgICAgICAgIHRyYW5zYWN0aW9uLnR5c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KICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIG5hbWU6ICJEZUZpQ2hhaW4iLAogICAgICBzeW1ib2w6ICJERkkiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vZXRoLm1haW5uZXQub2NlYW4uamVsbHlmaXNoc2RrLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkRlRmlTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL21ldGEuZGVmaXNjYW4ubGl2ZSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMzc4NTIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2RlZmljaGFpbkV2bVRlc3RuZXQuanMKICB2YXIgZGVmaWNoYWluRXZtVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMTEzMSwKICAgIG5ldHdvcms6ICJkZWZpY2hhaW4tZXZtLXRlc3RuZXQiLAogICAgbmFtZTogIkRlRmlDaGFpbiBFVk0gVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiRGVGaUNoYWluIiwKICAgICAgc3ltYm9sOiAiREZJIiwKICAgICAgZGVjaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB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W4gQ2hhaW4gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZGVnZW4udGlwcyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5kZWdlbi50aXBzL2FwaS92MiIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Rmay5qcwogIHZhciBkZmsgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDUzOTM1LAogICAgbmFtZTogIkRGSyBDaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJKZXdlbCIsCiAgICAgIHN5bWJvbDogIkpFV0VMIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9zdWJuZXRzLmF2YXgubmV0d29yay9kZWZpLWtpbmdkb21zL2Rmay1jaGFpbi9ycGMiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJERktTdWJuZXRTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3N1Ym5ldHMuYXZheC5uZXR3b3JrL2RlZmkta2luZ2RvbXMiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTQ3OTA1NTEKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxL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ZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDEzMzgsCiAgICBuYW1lOiAiRWx5c2l1bSBUZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkxBVkEiLAogICAgICBzeW1ib2w6ICJMQVZBIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9lbHlzaXVtLXRlc3QtcnBjLnZ1bGNhbmZvcmdlZC5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFbHlzaXVtIHRlc3RuZXQgZXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZWx5c2l1bS1leHBsb3Jlci52dWxjYW5mb3JnZWQuY29tIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Vvbi5qcwogIHZhciBlb24gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDczMzIsCiAgICBuYW1lOiAiSG9yaXplbiBFT04iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiWkVOIiwKICAgICAgc3ltYm9sOiAiWkVOIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vZW9uLXJwYy5ob3JpemVubGFicy5pby9ldGh2MSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICB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U6ICJGbG93IiwKICAgICAgc3ltYm9sOiAiRkxPVyIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbWFpbm5ldC5ldm0ubm9kZXMub25mbG93Lm9yZyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1haW5uZXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZmxvd2RpdmVyLmlvIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvZmxvd1ByZXZpZXduZXQuanMKICB2YXIgZmxvd1ByZXZpZXduZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDY0NiwKICAgIG5hbWU6ICJGbG93RVZNIFByZXZpZXduZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRmxvdyIsCiAgICAgIHN5bWJvbDogIkZMT1ciCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3ByZXZpZXduZXQuZXZtLm5vZGVzLm9uZmxvdy5vcmciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJQcmV2aWV3bmV0IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3ByZXZpZXduZXQuZmxvd2RpdmVyLmlvIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXN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ovL2ZyYXhzY2FuLmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9hcGkuZnJheHNjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDE0XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjZDQzkxNkVkNUM2QzJGQTk3MDE0ZjdEMWNEMTQxNTI4QWUxNzFlNCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQxNF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDM2Y2I2NWMxOTY3QTBGYjBFRUUxMTU2OUM1MUMyZjJhQTFDYTZmNkQiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTEzNTMyMwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDE0XTogewogICAgICAgICAgYWRkcmVzczogIjB4MzRDMGJENTg3N0E1RWU3MDk5RDBmNTY4OEQ2NUY0YkI5MTU4QkRFMiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MTM1MzIzCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMTQKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9mcmF4dGFsVGVzdG5ldC5qcwogIHZhciBzb3VyY2VJZDE1ID0gMTdlMzsKICB2YXIgZnJheH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ICAgICAgbmFtZTogIkhhcm1vbnkgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuaGFybW9ueS5vbmUiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjQxODU3NTMKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hhc2hrZXlDaGFpblRlc3RuZXQuanMKICB2YXIgaGFzaGtleVRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEzMywKICAgIG5hbWU6ICJIYXNoS2V5IENoYWluIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiSGFzaEtleSBFY29Qb2ludHMiLAogICAgICBzeW1ib2w6ICJIU0siCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2hhc2hrZXljaGFpbi10ZXN0bmV0LmFsdC50ZWNobm9sb2d5Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSGFzaEtleSBDaGFpbiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9oYXNoa2V5Y2hhaW4tdGVzdG5ldC1leHBsb3Jlci5hbHQudGVjaG5vbG9neSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hlZGVyYS5qcwogIHZhciBoZWRlcmEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDI5NSwKICAgIG5hbWU6ICJIZWRlcmEgTWFpbm5ldCIsCiAgICBuZXR3b3JrOiAiaGVkZXJhLW1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgc3ltYm9sOiAiSEJBUiIsCiAgICAgIG5hbWU6ICJIQkFSIiwKICAgICAgZGVjaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5uZXQuaGFzaGlvLmlvL2FwaSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkhhc2hzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2hhc2hzY2FuLmlvL21haW5uZXQiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hlZGVyYVByZXZpZXduZXQuanMKICB2YXIgaGVkZXJhUHJldmlld25ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMjk3LAogICAgbmFtZTogIkhlZGVyYSBQcmV2aWV3bmV0IiwKICAgIG5ldHdvcms6ICJoZWRlcmEtcHJldmlld25ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBzeW1ib2w6ICJIQkFSIiwKICAgICAgbmFtZTogIkhCQVIiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNV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wbG9yZXIueHl6L2FwaS92MiIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMTg2MDYKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2lua1NlcG9saWEuanMKICB2YXIgc291cmNlSWQxOSA9IDExMTU1MTExOwogIHZhciBpbmtTZXBvbGlhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiA3NjMzNzMsCiAgICBuYW1lOiAiSW5rIFNlcG9saWEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlNlcG9saWEgRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMtZ2VsLXNlcG9saWEuaW5rb25jaGFpbi5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLXNlcG9saWEuaW5rb25jaGFpbi5jb20vIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLXNlcG9saWEuaW5rb25jaGFpbi5jb20vYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICA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lkOiAxODkwLAogICAgbmFtZTogIkxpZ2h0TGluayBQaG9lbml4IE1haW5uZXQiLAogICAgbmV0d29yazogImxpZ2h0bGluay1waG9lbml4IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkV0aGVyIiwKICAgICAgc3ltYm9sOiAiRVRIIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9yZXBsaWNhdG9yLnBob2VuaXgubGlnaHRsaW5rLmlvL3JwYy92MSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkxpZ2h0TGluayBQaG9lbml4IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Bob2VuaXgubGlnaHRsaW5rLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2xpbmVhL2FjdGlvbnMvZXN0aW1hdGVHYXMuanMKICBpbml0X3BhcnNlQWNjb3VudCgpOwogIGluaXRfdG9IZXgoKTsKICBpbml0X2dldENhbGxFcnJvcigpOwogIGluaXRfZXh0cmFjdCgpOwogIGluaXRfdHJhbnNhY3Rpb25SZXF1ZXN0KCk7CiAgaW5pdF9hc3NlcnRSZXF1ZXN0KCk7CiAgYXN5bmMgZnVuY3Rpb24gZXN0aW1hdGVHYXMyKGNsaWVudCwgYXJncykgewogICAgY29uc3QgeyBhY2NvdW50OiBhY2NvdW50XyA9IGNsaWVudC5hY2NvdW50IH0gPSBhcmdzOwogICAgaWYgKCFhY2NvdW50XykKICAgICAgdGhyb3cgbmV3IEFjY291bnROb3RGb3VuZEVycm9yKCk7CiAgICBjb25zd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ICAgIHRvLAogICAgICAgIHZhbHVlCiAgICAgIH0pOwogICAgICBjb25zdCB7IGJhc2VGZWVQZXJHYXMsIGdhc0xpbWl0LCBwcmlvcml0eUZlZVBlckdhcyB9ID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImxpbmVhX2VzdGltYXRlR2FzIiwKICAgICAgICBwYXJhbXM6IGJsb2NrID8gW3JlcXVlc3QsIGJsb2NrXSA6IFtyZXF1ZXN0XQogICAgICB9KTsKICAgICAgcmV0dXJuIHsKICAgICAgICBiYXNlRmVlUGVyR2FzOiBCaWdJbnQoYmFzZUZlZVBlckdhcyksCiAgICAgICAgZ2FzTGltaXQ6IEJpZ0ludChnYXNMaW1pdCksCiAgICAgICAgcHJpb3JpdHlGZWVQZXJHYXM6IEJpZ0ludChwcmlvcml0eUZlZVBlckdhcykKICAgICAgfTsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICB0aHJvdyBnZXRDYWxsRXJyb3IoZXJyLCB7CiAgICAgICAgLi4uYXJncywKICAgICAgICBhY2NvdW50LAogICAgICAgIGNoYWluOiBjbGllbnQuY2hhaW4KICAgICAgfSk7CiAgICB9CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vbGluZWEvY2hhaW5Db25maWcuanMKICB2YXIgY2hhaW5Db25maWc0ID0gewogICAgZmVlczogewogICAgICBlc3RpbWF0ZUZlZXNQZXJHYXM6IGVzdGltYXRlRmVlc1BlckdhczIsCiAgICAgIGFzeW5jIG1heFByaW9yaXR5RmVlUGVyR2FzKHsgYmxvY2ssIGNsaWVudCwgcmVxdWVzdCB9KSB7CiAgICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCBlc3RpbWF0ZUZlZXNQZXJHYXMyKHsKICAgICAgICAgIGJsb2NrLAogICAgICAgICAgY2xpZW50LAogICAgICAgICAgbXVsdGlwbHk6ICh4KSA9P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ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMuZ29lcmxpLmxpbmVhLmJ1aWxkIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy5nb2VybGkubGluZWEuYnVpbGQiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFdGhlcnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vZ29lcmxpLmxpbmVhc2Nhbi5idWlsZCIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9nb2VybGkubGluZWFzY2FuLmJ1aWxkL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA0OTg2MjMKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9saXNrLmpzCiAgdmFyIHNvdXJjZUlkMjAgPSAxOwogIHZhciBsaXNrID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiAxMTM1LAogICAgbmFtZTogIkxpc2siLAogICAgbmV0d29yazogImxpc2siLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hcGkubGlzay5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL2Jsb2Nrc2NvdXQubGlzay5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYmxvY2tzY291dC5saXNrLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweEE5ZDcxRTFkZDdjYTI2RjI2ZTY1NkU2NmQ2QUE4MWVkN2Y3NDViZjAiCiAgICAgIH0sCiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7CiAgICAgICAgW3NvdXJjZUlkMjBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgxMTNjQjk5MjgzQUYyNDJEYTBBMEM1NDM0NzY2N2VkRjUzMUFhN2Q2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgyNmRCOTNGOGI4YjRmNzAxNjI0MGFmNjJGNzczMDk3OWQzNTNmOUE3IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDIwXTogewogICAgICAgICAgYWRkcmVzczogIjB4MjY1ODcyM0JmNzBjNzY2N0RlNkIyNUY5OWZjY2UxM0ExNkQyNWQwOCIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQyMAogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8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gICBpZDogMTU1NTEsCiAgICBuYW1lOiAiTG9vcE5ldHdvcmsgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiTE9PUCIsCiAgICAgIHN5bWJvbDogIkxPT1AiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vYXBpLm1haW5uZXRsb29wLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkxvb3BOZXR3b3JrIEJsb2NrY2hhaW4gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubWFpbm5ldGxvb3AuY29tLyIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IGZhbHNlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuNDAvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvbHVrc28uanMKICB2YXIgbHVrc28gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDQyLAogICAgbmV0d29yazogImx1a3NvIiwKICAgIG5hbWU6ICJMVUtTTyIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiTFVLU08iLAogICAgICBzeW1ib2w6ICJMWVgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLm1haW5uZXQubHVrc28ubmV0d29yayJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly93cy1ycGMubWFpbm5ldC5sdWtzby5uZXR3b3JrIl0KICAgICAgfQogICAgfSwKICAgIGJsb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gubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgImh0dHBzOi8vZXUtd2VzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAiaHR0cHM6Ly9hc2lhLXNvdXRoZWFzdC5seWNhbmNoYWluLmNvbSIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3JwYy5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vdXMtZWFzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vdXMtd2VzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vZXUtbm9ydGgubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgIndzczovL2V1LXdlc3QubHljYW5jaGFpbi5jb20iLAogICAgICAgICAgIndzczovL2FzaWEtc291dGhlYXN0Lmx5Y2FuY2hhaW4uY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTHljYW4gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubHljYW5jaGFpbi5jb20iCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9seXJhLmpzCiAgdmFyIGx5cmEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDk1NywKICAgIG5hbWU6ICJMeXJhIENoYWluIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5seXJhLmZpbmFuY2UiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJMeXJhIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLmx5cmEuZmluYW5jZSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5seXJhLmZpbmFuY2UvYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5MzUxOTgKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21haW5uZXQuanMKICB2YXIgbWFpbm5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMSwKICAgIG5hbWU6ICJFdGhlcmV1bSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9jbG91ZGZsYXJlLWV0aC5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFdGhlcnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vZXRoZXJzY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS5ldGhlcnNjYW4uaW8vYXBpIgog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JdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLm1ldGFsbDIuY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLm1ldGFsbDIuY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDIyXTogewogICAgICAgICAgYWRkcmVzczogIjB4M0IxRjdhRGEwRmNjMjZCMTM1MTVhZjc1MkRkMDdmQjFDQWMxMTQyNiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDAKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjJdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgzRjM3YUJkRTJDNmI1QjJlZDZGODA0NTc4N0RmMUVEMUUzNzUzOTU2IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDIyXTogewogICAgICAgICAgYWRkcmVzczogIjB4NmQwZjY1RDU5YjU1QjBGRUM1ZDJkMTUzNjUxNTREY0FEQzE0MEJGMyIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQyMgogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGVyLmpzCiAgdmFyIG1ldGVyID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4MiwKICAgIG5hbWU6ICJNZXRlciIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJNVFIiLAogICAgICBzeW1ib2w6ICJNVFIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMubWV0ZXIuaW8iXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNZXRlclNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vc2Nhbi5tZXRlci5pbyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGVyVGVzdG5ldC5qcwogIHZhciBtZXRlclRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDgzLAogICAgbmFtZTogIk1ldGVyIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiTVRSIiwKICAgICAgc3ltYm9sOiAiTVRSIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjdGVzdC5tZXRlci5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1ldGVyVGVzdG5ldFNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vc2Nhbi13YXJyaW5nc3Rha2VzLm1ldGVyLmlvIgogICAgICB9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XQubW9kZS5uZXR3b3JrIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTW9kZXNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vbW9kZXNjYW4uaW8iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjQ2NTg4MgogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDIzXTogewogICAgICAgICAgYWRkcmVzczogIjB4NDMxN2JhMTQ2RDQ5MzNEODg5NTE4YTNlNUUxMUZlN2E1MzE5OWIwNCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDIzXTogewogICAgICAgICAgYWRkcmVzczogIjB4OEIzNGIxNGM3YzcxMjM0NTlDZjMwNzZiOENiOTI5QkUwOTdkMEMwNyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQyM106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDczNWFEQmJFNzIyMjZCRDUyZTgxOEU3MTgxOTUzZjQyRTNiMEZGMjEiCiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMjMKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9tb2RlVGVzdG5ldC5qcwogIHZhciBzb3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IgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwNTIwNjExMgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL25lb25NYWlubmV0LmpzCiAgdmFyIG5lb25NYWlubmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyNDUwMjI5MzQsCiAgICBuZXR3b3JrOiAibmVvbk1haW5uZXQiLAogICAgbmFtZTogIk5lb24gRVZNIE1haW5OZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIk5FT04iLCBzeW1ib2w6ICJORU9OIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbmVvbi1wcm94eS1tYWlubmV0LnNvbGFuYS5wMnAub3JnIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTmVvbnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vbmVvbnNjYW4ub3JnIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwNjU0NTUyNAogICAgICB9CiAgICB9LAog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ldC5vcHRpbWlzbS5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk9wdGltaXNtIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL29wdGltaXN0aWMuZXRoZXJzY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1vcHRpbWlzdGljLmV0aGVyc2Nhbi5pby9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgZGlzcHV0ZUdhbWVGYWN0b3J5OiB7CiAgICAgICAgW3NvdXJjZUlkMjddOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhlNTk2NUFiNTk2MmVEYzc0NzdDODUyMDI0M0E5NTUxN0NEMjUyZkE5IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyN106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGRmZTk3ODY4MjMzZDFhYTIyZTgxNWEyNjY5ODJmMmNmMTc2ODVhMjciCiAgICAgICAgfQogICAgICB9LAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA0Mjg2MjYzCiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDI3XTogewogICAgICAgICAgYWRkcmVzczogIjB4YkViNUZjNTc5MTE1MDcxNzY0Yzc0MjNBNGYxMmVEZGU0MWYxMDZFZCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQyN106IHsKICAgICAgICAgIGF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LmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3Bnbi5qcwogIHZhciBzb3VyY2VJZDMwID0gMTsKICB2YXIgcGduID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA0MjQsCiAgICBuZXR3b3JrOiAicGduIiwKICAgIG5hbWU6ICJQR04iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkV0aGVyIiwgc3ltYm9sOiAiRVRIIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnB1YmxpY2dvb2RzLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJQR04gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIucHVibGljZ29vZHMubmV0d29yayIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5wdWJsaWNnb29kcy5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDMwXTogewogICAgICAgICAgYWRkcmVzczogIjB4OUU2MjA0Rjc1MGNEODY2YjI5OTU5NGUyYUM5ZUE4MjRFMmU1Zjk1YyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDMzODAyMDkKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMzB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Qb2x5Z29uIE11bWJhaSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiTUFUSUMiLCBzeW1ib2w6ICJNQVRJQyIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hbmtyLmNvbS9wb2x5Z29uX211bWJhaSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlBvbHlnb25TY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL211bWJhaS5wb2x5Z29uc2Nhbi5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLXRlc3RuZXQucG9seWdvbnNjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAyNTc3MDE2MAogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3BvbHlnb25aa0V2bS5qcwogIHZhciBwb2x5Z29uWmtFdm0gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDExMDEsCiAgICBuYW1lOiAiUG9seWdvbiB6a0VWTSIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6I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k1NzgzMzcKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQzM106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGM0NzNjYTdFMDJhZjI0YzEyOWMyZUVmNTFGMmFEZjA0MTFjMURmNjkiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTU3ODMzMQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3JleWFOZXR3b3JrLmpzCiAgdmFyIHJleWFOZXR3b3JrID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxNzI5LAogICAgbmFtZTogIlJleWEgTmV0d29yayIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBkZWNpbWFsczogMTgsIG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMucmV5YS5uZXR3b3JrIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3dzLnJleWEubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlJleWEgTmV0d29yayBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5yZXlhLm5ldHdvcmsiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3JvbGx1eC5qcwogIHZhci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cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlN5c2NvaW4iLAogICAgICBzeW1ib2w6ICJTWVMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy10YW5lbmJhdW0ucm9sbHV4LmNvbS8iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vcnBjLXRhbmVuYmF1bS5yb2xsdXguY29tL3dzcyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlJvbGx1eFRlc3RuZXRFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9yb2xsdXgudGFuZW5iYXVtLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3JvbGx1eC50YW5lbmJhdW0uaW8vYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE4MTM2NzUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3JvbmluLmpzCiAgdmFyIHJvbmluID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMDIwLAogICAgbmFtZTogIlJvbmluIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJST04iLCBzeW1ib2w6ICJST04iLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6I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ICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQzNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDZFZjhjNjlDZkU0NjM1ZDg2NmUzRTAyNzMyMDY4MDIyYzA2ZTcyNEQiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDM2OTk0MAogICAgICAgIH0KICAgICAgfSwKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEVCMDZmRmExNjAxMUI1NjI4QmFCOThFMjk3NzYzNjFjODM3NDFkZDMiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDM2OTkzMwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDM2XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjJFZGQ1ZjQ5MzBFYTkyZENhM2ZCODE2ODliREQ5YjlkMDc2YjU3QiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwMzY5OTM1CiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMzYKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9zaGFwZVNlcG9saWEuanMKICB2YXIgc291cmNlSWQzNyA9IDExMTU1MTExOwogIHZhciBzaGFwZVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDExMDExLAogICAgbmFtZTogIlNoYXBlIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiU2Vwb2xpYSBFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEuc2hhcGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXItc2Vwb2xpYS5zaGFwZS5uZXR3b3JrLyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci1zZXBvbGlhLnNoYXBlLm5ldHdvcmsvYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDEKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQzNwogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoYXJkZXVtU3BoaW54LmpzCiAgdmFyIHNoYXJkZXVtU3BoaW54ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4MDgyLAogICAgbmFtZTogIlNoYXJkZXVtIFNwaGlueCIsCiAgICBuYXRpdmVDdXJyZ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ICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS5zaGltbWVyLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTaGltbWVyIE5ldHdvcmsgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZXZtLnNoaW1tZXIubmV0d29yayIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5ldm0uc2hpbW1lci5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoaW1tZXJUZXN0bmV0LmpzCiAgdmFyIHNoaW1tZXJUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMDczLAogICAgbmFtZTogIlNoaW1tZXIgVGVzdG5ldCIsCiAgICBuZXR3b3JrOiAic2hpbW1lci10ZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlNoaW1tZXIiLAogICAgICBzeW1ib2w6ICJTTVIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS50ZXN0bmV0LnNoaW1tZXIubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlNoaW1tZXIgTmV0d29yayBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jl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W0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvc25heC5qcwogIHZhciBzb3VyY2VJZDM4ID0gMTsKICB2YXIgc25heCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICAuLi5jaGFpbkNvbmZpZzIsCiAgICBpZDogMjE5MiwKICAgIG5ldHdvcms6ICJzbmF4Y2hhaW4tbWFpbm5ldCIsCiAgICBuYW1lOiAiU25heENoYWluIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5uZXQuc25heGNoYWluLmlvIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiU25heCBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5zbmF4Y2hhaW4uaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuc25heGNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQzOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDQ3MjU2MkZjZjI2RDZiMjc5M2Y4RTBiMGZCNjYwYmEwRTVlMDhBNDYiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM4XTogewogICAgICAgICAgYWRkcmVzczogIjB4MjE3MmU0OTJGYzgwN0Y1ZDU2NDVEMEUzNTQzZjEzOUVDRjUzOTI5NCIKICAgICAgICB9CiAgICA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iAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTbmF4IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQzOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDIwNmE3NWQ4OWQ0NUYxNDZDNTQwMjBGMTMyRkY5M2JFREQwOWY1NUUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM5XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjBlM0EzNjhhNGNkQ0VmODVmZkI5NjRlMzcyNzI2RjU2QTQ2MjIxZSIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGI1YWZkZDBFOGRERjA4MUVmOTBlOEEzZTBjN2I1Nzk4ZTY2RTk1NEUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMzldOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhiZDM3RTFhNTlENEMwMEM5QTQ2Rjc1MDE4ZGZmZDg0MDYxYkM1Zjc0IgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQzOQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NvbmVpdW1NaW5hdG8uanMKICB2YXIgc291cmNlSWQ0MCA9IDExMTU1MTExOwogIHZhciBzb25laXVtTWluYXRvID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiAxOTQ2LAogICAgbmFtZTogIlNvbmVpdW0gTWluYXRvIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlNlcG9saWEgRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMubWluYXRvLnNvbmVpdW0ub3JnIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiQmxvY2tzY291dCIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci10ZXN0bmV0LnNvbmVpdW0ub3JnIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLXRlc3RuZXQuc29uZWl1bS5vcmcvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIGRpc3B1dGVHYW1lRmFjdG9yeTogewogICAgICAgIFtzb3VyY2VJZDQwXTogewogICAgICAgICAgYWRkcmVzczogIjB4RjY5ZEI2Y0E1NTlDNTJkOUE0QkI2ZTJCMjkwMWY0OTB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gIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLm1haW5uZXQudGFpa28ueHl6Il0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3dzLm1haW5uZXQudGFpa28ueHl6Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiVGFpa29zY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3RhaWtvc2Nhbi5pbyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9hcGkudGFpa29zY2FuLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2IyNDM2Nzc0QzNlMTkxYzg1MDU2ZDI0OEVGNDI2MGNlNWYyN0E5RCIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3RhaWtvSGVrbGEuanMKICB2YXIgdGFpa29IZWtsYSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMTY3MDA5LAogICAgbmFtZTogIlRhaWtvIEhla2xhIEwyIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5oZWtsYS50YWlrby54eXoiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG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dXJyZW5jeTogeyBuYW1lOiAiVEhBVCIsIHN5bWJvbDogIlRIQVQiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9hcGkudGhhdGNoYWluLmlvL21haW5uZXQiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL3RoYXQuYmxvY2tzY291dC5jb20iCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3RoZXRhLmpzCiAgdmFyIHRoZXRhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAzNjEsCiAgICBuYW1lOiAiVGhldGEgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiVEZVRUwiLCBzeW1ib2w6ICJURlVFTCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2V0aC1ycGMtYXBpLnRoZXRhdG9rZW4ub3JnL3JwYyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlRoZXRhIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnRoZXRhdG9rZW4ub3JnIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40M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UZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJzWGFpIiwgc3ltYm9sOiAic1hBSSIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtdjIueGFpLWNoYWluLm5ldC9ycGMiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXItdjIueGFpLWNoYWluLm5ldCIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy94ZGMuanMKICB2YXIgeGRjID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA1MCwKICAgIG5hbWU6ICJYaW5GaW4gTmV0d29yayIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJYREMiLAogICAgICBzeW1ib2w6ICJYREMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMueGRjcnBjLmNvbSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlhEQ1NjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8veGRjc2Nhbi5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweDBCMTc5NWNjQ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WxsaXFhLXRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlppbGxpcWEiLCBzeW1ib2w6ICJaSUwiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9kZXYtYXBpLnppbGxpcWEuY29tIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiRXRoZXJuYWwiLAogICAgICAgIHVybDogImh0dHBzOi8vZXZteC50ZXN0bmV0LnppbGxpcWEuY29tIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3ppcmN1aXQuanMKICB2YXIgemlyY3VpdCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNDg5MDAsCiAgICBuYW1lOiAiWmlyY3VpdCBNYWlubmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkV0aGVyIiwKICAgICAgc3ltYm9sOiAiRVRIIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsKICAgICAgICAgICJodHRwczovL3ppcmN1aXQxLW1haW5uZXQucDJwaWZ5LmNvbSIsCiAgICAgICAgICAiaHR0cHM6Ly96aXJjdWl0MS1tYWlubmV0LmxpcXVpZnkuY29tIiwKICAgICAgICAgICJodHRwczovL3ppcmN1aXQtbWFpbm5ldC5kcnBjLm9yZyIKICAgICAgICBdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlppcmN1aXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuemlyY3VpdC5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3ppcmN1aXRUZXN0bmV0LmpzCiAgdmFyIHppcmN1aXRUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA0ODg5OSwKICAgIG5hbWU6ICJaaXJjdWl0IFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkVUSCIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vemlyY3VpdDEtdGVzdG5ldC5wMnBpZnkuY29tIiwKICAgICAgICAgICJodHRwczovL3ppcmN1aXQxLXRlc3RuZXQubGlxdWlmeS5jb20iCiAgICAgICAgXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJaaXJjdWl0IFRlc3RuZXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIudGVzdG5ldC56aXJjdWl0LmNvbSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNh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gICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS40MC9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy96a0ZhaXJUZXN0bmV0LmpzCiAgdmFyIHprRmFpclRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDQzODUxLAogICAgbmFtZTogIlpLRmFpciBUZXN0bmV0IiwKICAgIG5ldHdvcms6ICJ6a2ZhaXItdGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJVU0QgQ29pbiIsCiAgICAgIHN5bWJvbDogIlVTREMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLnprZmFpci5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogInprRmFpciBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly90ZXN0bmV0LXNjYW4uemtmYWlyLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3prTGlua05vdmEuanMKICB2YXIgemtMaW5rTm92YSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODEwMTgwLAogICAgbmFtZTogInprTGluayBOb3ZhIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkVU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bm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvemtzeW5jLmpzCiAgdmFyIHprc3luYyA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICAuLi5jaGFpbkNvbmZpZywKICAgIGlkOiAzMjQsCiAgICBuYW1lOiAiWktzeW5jIEVyYSIsCiAgICBuZXR3b3JrOiAiemtzeW5jLWVyYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vbWFpbm5ldC5lcmEuemtzeW5jLmlvIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL21haW5uZXQuZXJhLnprc3luYy5pby93cyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV0aGVyc2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9lcmEuemtzeW5jLm5ldHdvcmsvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1lcmEuemtzeW5jLm5ldHdvcmsvYXBpIgogICAgICB9LAogICAgICBuYXRpdmU6IHsKICAgICAgICBuYW1lOiAiWktzeW5jIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnprc3luYy5pby8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYmxvY2stZXhwbG9yZXItYXBpLm1haW5uZXQuemtzeW5jLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4RjljZGE2MjRGQkM3ZTA1OTM1NWNlOThhMz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0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnpvcmEuZW5lcmd5Il0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy56b3JhLmVuZXJneSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnpvcmEuZW5lcmd5IiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLnpvcmEuZW5lcmd5L2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDQ0XTogewogICAgICAgICAgYWRkcmVzczogIjB4OUU2MjA0Rjc1MGNEODY2YjI5OTU5NGUyYUM5ZUE4MjRFMmU1Zjk1YyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDU4ODIKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkNDRdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgxYTBhZDAxMTkxM0ExNTBmNjlmNkExOURGNDQ3QTBDZkQ5NTUxMDU0IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDQ0XTogewogICAgICAgICAgYWRkcmVzczogIjB4M2UyRWE5QjkyQjdFNDhBNTIyOTZmRDI2MWRjMjZmZDk5NTI4NDYzMSIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQ0NAogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjQwL25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3pvcmFTZXBvbGlhLmpzCiAgdmFyIHNvdXJjZUlkNDUgPSAxMTE1NTExMTsKICB2YXIgem9yYVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDk5OTk5OTk5OSwKICAgIG5hbWU6ICJab3JhIFNlcG9saWEiLAogICAgbmV0d29yazogInpvcmEtc2Vwb2xpYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJab3JhIFNlcG9saWEiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEucnBjLnpvcmEuZW5lcmd5Il0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3NlcG9saWEucnBjLnpvcmEuZW5lcmd5Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiWm9yYSBTZXBvbGlhIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NlcG9saWEuZXhwbG9yZXIuem9yYS5lbmVyZ3kvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3NlcG9saWEuZXhwbG9yZXIuem9yYS5lbmVyZ3kvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7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NlbGVjdGVkQWRkcmVzcyA9IGFkZHJlc3Nlc1swXTsKICAgICAgfSk7CiAgICB9CiAgICBlbmFibGUoKSB7CiAgICAgIHJldHVybiB0aGlzLnJlcXVlc3RBY2NvdW50cygpOwogICAgfQogICAgcmVxdWVzdCh7IG1ldGhvZCwgcGFyYW1zIH0pIHsKICAgICAgY29uc29sZS5sb2coInJlcXVlc3QiLCBtZXRob2QsIHBhcmFtcyk7CiAgICAgIHN3aXRjaCAobWV0aG9kKSB7CiAgICAgICAgY2FzZSAiZXRoX3JlcXVlc3RBY2NvdW50cyI6CiAgICAgICAgICByZXR1cm4gdGhpcy5yZXF1ZXN0QWNjb3VudHMoKTsKICAgICAgICBjYXNlICJldGhfYWNjb3VudHMiOgogICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSh0aGlzLmdldEFjY291bnRzKCkpOwogICAgICAgIGNhc2UgImV0aF9zZW5kVHJhbnNhY3Rpb24iOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2VuZFRyYW5zYWN0aW9uKHBhcmFtc1swXSk7CiAgICAgICAgY2FzZSAiZXRoX3NpZ24iOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2lnbihwYXJhbXNbMF0sIHBhcmFtc1sxXSk7CiAgICAgICAgY2FzZSAicGVyc29uYWxfc2lnbiI6CiAgICAgICAgICByZXR1cm4gdGhpcy5wZXJzb25hbFNpZ24ocGFyYW1zWzBdLCBwYXJhbXNbMV0pOwogICAgICAgIGNhc2UgImV0aF9zaWduVHlwZWREYXRhIjoKICAgICAgICAgIHJldHVybiB0aGlzLnNpZ25UeXBlZERhdGEocGFyYW1zWzBdLCBwYXJhbXNbMV0pOwogICAgICAgIGNhc2UgImV0aF9jaGFpbklkIjoKICAgICAgICAgIHJldHVybiB0aGlzLmdldENoYWluSWQoKTsKICAgICAgICBjYXNlICJuZXRfdmVyc2lvbiI6CiAgICAgICAgICByZXR1cm4gdGhpcy5nZXROZXR3b3JrSWQoKTsKICAgICAgIC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sKICAgIH0KICAgIGdldEFjY291bnRzKCkgewogICAgICByZXR1cm4gdGhpcy5zZWxlY3RlZEFkZHJlc3MgPyBbdGhpcy5zZWxlY3RlZEFkZHJlc3NdIDogW107CiAgICB9CiAgICBhc3luYyBzZW5kVHJhbnNhY3Rpb24odHgpIHsKICAgICAgaWYgKCF0aGlzLnNlbGVjdGVkQWRkcmVzcykgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiTm8gYWNjb3VudHMgYXZhaWxhYmxlIik7CiAgICAgIH0KICAgICAgaWYgKCF0eC50byB8fCAhdHgudmFsdWUgfHwgIXR4LmdhcykgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiTWlzc2luZyByZXF1aXJlZCB0cmFuc2FjdGlvbiBwYXJhbWV0ZXJzIik7CiAgICAgIH0KICAgICAgY29uc29sZS5sb2coInNlbmRUcmFuc2FjdGlvbiB0eDogIiwgdHgpOwogICAgICBjb25zb2xlLmxvZygiVHJhbnNhY3Rpb24gZ2FzUHJpY2U6ICIsIHR4Lmdhc1ByaWNlKTsKICAgICAgY29uc29sZS5sb2coIlRyYW5zYWN0aW9uIGdhczogIiwgdHguZ2FzKTsKICAgICAgY29uc3QgdmFsdWUgPSBCaWdJbnQodHgudmFsdWUpOwogICAgICBjb25zdCB2YWx1ZUluRXRoID0gTnVtYmVyKHZhbHVlKSAvIDEwICoqIDE4OwogICAgICBjb25zb2xlLmxvZyhgVHJhbnNhY3Rpb24gdmFsdWUgaW4gRVRIOiAke3ZhbHVlSW5FdGh9YCk7CiAgICAgIGNvbnN0IHRyYW5zYWN0aW9uQ29udGVudCA9IHsKICAgICAgICB0bzogdHgudG8sCiAgICAgICAgdmFsdWUsCiAgICAgICAgZGF0YTogdHguZGF0YSwKICAgICAgICBjaGFpbjogdGhpcy5jbGllbnQuY2hhaW4KICAgICAgfTsKICAgICAgY29uc29sZS5sb2coInNlbmRUcmFuc2FjdGlvbiIsIHRyYW5zYWN0aW9uQ29udGVudCk7CiAgICAgIHRyeS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ZXMgPyBbLi4uYXJncy5tZXRhTWVzc2FnZXMsICIiXSA6IFtdLAogICAgICAgICAgICAuLi5kb2NzUGF0aDkgPyBbYERvY3M6IGh0dHBzOi8vYWJpdHlwZS5kZXYke2RvY3NQYXRoOX1gXSA6IFtdLAogICAgICAgICAgICAuLi5kZXRhaWxzID8gW2BEZXRhaWxzOiAke2RldGFpbHN9YF0gOiBbXSwKICAgICAgICAgICAgYFZlcnNpb246IGFiaXR5cGVAJHt2ZXJzaW9ufWAKICAgICAgICAgIF0uam9pbigiXG4iKTsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkZXRhaWxzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZG9jc1BhdGgiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtZXRhTWVzc2FnZXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaG9ydE1lc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bGVkIHRvIHBhcnNlIEFCSSBpdGVtLiIsIHsKICAgICAgICAgICAgZGV0YWlsczogYHBhcnNlQWJpSXRlbSgke0pTT04uc3RyaW5naWZ5KHNpZ25hdHVyZSwgbnVsbCwgMil9KWAsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2FwaS9odW1hbiNwYXJzZWFiaWl0ZW0tMSIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRBYmlJdGVtRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVua25vd25UeXBlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0eXBlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHR5cGUuIiwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgVHlwZSAiJHt0eXBlfSIgaXMgbm90IGEgdmFsaWQgQUJJIHR5cGUuIFBlcmhhcHMgeW91IGZvcmdvdCB0byBpbmNsdWRlIGEgc3RydWN0IHNpZ25hdHVyZT9gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIlVua25vd25UeXBlRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07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hcnNlYWJpcGFyYW1ldGVycy0xIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZFBhcmFtZXRlckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0gfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6ICJJbnZhbGlkUGFyYW1ldGVyRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFNvbGlkaXR5UHJvdGVjdGVkS2V5d29yZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIG5hbWUgfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtLAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgIiR7bmFtZX0iIGlzIGEgcHJvdGVjdGVkIFNvbGlkaXR5IGtleXdvcmQuIE1vcmUgaW5mbzogaHR0cHM6Ly9kb2NzLnNvbGlkaXR5bGFuZy5vcmcvZW4vbGF0ZXN0L2NoZWF0c2hlZXQuaHRtbGAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiU29saWRpdHlQcm90ZWN0ZWRLZXl3b3JkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRNb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRNb2RpZmllckVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRnVuY3Rpb25Nb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gLAogICAgICAgICAgICAgIGBEYXRhIGxvY2F0aW9uIGNhbiBvbmx5IGJlIHNwZWNpZmllZCBmb3IgYXJyYXksIHN0cnVjdCwgb3IgbWFwcGluZyB0eXBlcywgYnV0ICIke21vZGlmaWVyfSIgd2FzIGdpdmVuLmAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEZ1bmN0aW9uTW9kaWZpZXJFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZEFiaVR5cGVQYXJhbWV0ZXJFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IGFiaVBhcmFtZXRlciB9KSB7CiAgICAgICAgICBzdXBlcigiSW52YWxpZCBBQkkgcGFyYW1ldGVyL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gJHt0eXBlfSBzaWduYXR1cmUuYCwgewogICAgICAgICAgICBkZXRhaWxzOiBzaWduYXR1cmUKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRTaWduYXR1cmVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgVW5rbm93blNpZ25hdHVyZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgc2lnbmF0dXJlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNpZ25hdHVyZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU3RydWN0U2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzaWduYXR1cmUgfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgc3RydWN0IHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZSwKICAgICAgICAgICAgbWV0YU1l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RhYmlsaXR5ID8/ICJub25wYXlhYmxlIiwKICAgICAgICBpbnB1dHMsCiAgICAgICAgb3V0cHV0cwogICAgICB9OwogICAgfQogICAgaWYgKGlzRXZlbnRTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFdmVudFNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJldmVudCIgfSk7CiAgICAgIGNvbnN0IHBhcmFtcyA9IHNwbGl0UGFyYW1ldGVycyhtYXRjaC5wYXJhbWV0ZXJzKTsKICAgICAgY29uc3QgYWJpUGFyYW1ldGVycyA9IFtdOwogICAgICBjb25zdCBsZW5ndGggPSBwYXJhbXMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgYWJpUGFyYW1ldGVycy5wdXNoKHBhcnNlQWJpUGFyYW1ldGVyKHBhcmFtc1tpXSwgewogICAgICAgICAgbW9kaWZpZXJzOiBldmVudE1vZGlmaWVycywKICAgICAgICAgIHN0cnVjdHMsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiB7IG5hbWU6IG1hdGNoLm5hbWUsIHR5cGU6ICJldmVudCIsIGlucHV0czogYWJpUGFyYW1ldGVycyB9OwogICAgfQogICAgaWYgKGlzRXJyb3JTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFcnJvclNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJlcnJvciIgfSk7CiAgICAgIGNvbnN0I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gICAgIC4uLmFiaVBhcmFtZXRlciwKICAgICAgICAgICAgdHlwZTogYHR1cGxlJHthcnJheSA/PyAiIn1gLAogICAgICAgICAgICBjb21wb25lbnRzOiByZXNvbHZlU3RydWN0cyhzdHJ1Y3RzW3R5cGVdID8/IFtdLCBzdHJ1Y3RzLCAvKiBAX19QVVJFX18gKi8gbmV3IFNldChbLi4uYW5jZXN0b3JzLCB0eXBlXSkpCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGlzU29saWRpdHlUeXBlKHR5cGUpKQogICAgICAgICAgICBjb21wb25lbnRzLnB1c2goYWJpUGFyYW1ldGVyKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgdGhyb3cgbmV3IFVua25vd25UeXBlRXJyb3IoeyB0eXBlIH0pOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGNvbXBvbmVudHM7CiAgfQogIHZhciB0eXBlV2l0aG91dFR1cGxlUmVnZXg7CiAgdmFyIGluaXRfc3RydWN0cyA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9ydW50aW1lL3N0cnVjdHMuanMiKCkgewogICAgICBpbml0X3JlZ2V4KCk7CiAgICAgIGluaXRfYWJpSXRlbSgpOwogICAgICBpbml0X2FiaVBhcmFtZXRlcigpOwogICAgICBpbml0X3NpZ25hdHVyZSgpOwogICAgICBpbml0X3N0cnVjdCgpOwogICAgICBpbml0X3NpZ25hdHVyZXMoKTsKICAgICAgaW5pdF91dGlscygpOwogICAgICB0eXBlV2l0aG91dFR1cGxlUmVnZXggPSAvXig/PHR5cGU+W2EtekEtWiRfXVthLXpBLVowLTkkX10qKSg/PGFycmF5Pig/OlxbXGQqP1xdKSs/KT8kLzsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL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XVzZT8ubWVzc2FnZSkKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5tZXNzYWdlOwogICAgICAgICAgICByZXR1cm4gYXJncy5kZXRhaWxzOwogICAgICAgICAgfSkoKTsKICAgICAgICAgIGNvbnN0IGRvY3NQYXRoOSA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kb2NzUGF0aCB8fCBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgICByZXR1cm4gYXJncy5kb2NzUGF0aDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBkb2NzVXJsID0gZXJyb3JDb25maWcuZ2V0RG9jc1VybD8uKHsgLi4uYXJncywgZG9jc1BhdGg6IGRvY3NQYXRoOSB9KTsKICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBbCiAgICAgICAgICAgIHNob3J0TWVzc2FnZSB8fCAiQW4gZXJyb3Igb2NjdXJyZWQuIiwKICAgICAgICAgICAgIiIsCiAgICAgICAgICAgIC4uLmFyZ3MubWV0YU1lc3NhZ2VzID8gWy4uLmFyZ3MubWV0YU1lc3NhZ2VzLCAiIl0gOiBbXSwKICAgICAgICAgICAgLi4uZG9jc1VybCA/IFtgRG9jczogJHtkb2NzVXJsfWBdIDogW10sCiAgICAgICAgICAgIC4uLmRldGFpbHMgPyBbYERldGFpbHM6ICR7ZGV0YWlsc31gXSA6IFtdLAogICAgICAgICAgICAuLi5lcnJvckNvbmZpZy52ZXJzaW9uID8gW2BWZXJzaW9uOiAke2Vycm9yQ29uZmlnLnZlcnNpb259YF0gOiBbXQogICAgICAgICAgXS5qb2luKCJcbiIpOwogICAgICAgICAgc3VwZXIobWVzc2FnZSwgYXJncy5jYXVzZSA/IHsgY2F1c2U6IGFyZ3MuY2F1c2UgfSA6IHZvaWQgMCk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRldGFpbHMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkb2NzUGF0aCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm1ldGFNZXNzYWdlcyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNob3J0TWVzc2FnZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInZlcnNpb24iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhb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FtZTogIkFiaURlY29kaW5nRGF0YVNpemVUb29TbWFsbEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJwYXJhbXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuZGF0YSA9IGRhdGE7CiAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgIHRoaXMuc2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgIHN1cGVyKCdDYW5ub3QgZGVjb2RlIHplcm8gZGF0YSAoIjB4Iikgd2l0aCBBQkkgcGFyYW1ldGVycy4nLCB7CiAgICAgICA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b3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIERlY29kZUxvZ0RhdGFNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBkYXRhLCBwYXJhbXMsIHNpemU6IHNpemUzIH0pIHsKICAgICAgICAgIHN1cGVyKFsKICAgICAgICAgICAgYERhdGEgc2l6ZSBvZiAke3NpemUzfSBieXRlcyBpcyB0b28gc21hbGwgZm9yIG5vbi1pbmRleGVkIGV2ZW50IHBhcmFtZXRlcnMuYAogICAgICAgICAgXS5qb2luKCJcbiIpLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBQYXJhbXM6ICgke2Zvcm1hdEFiaVBhcmFtcyhwYXJhbXMsIHsgaW5jbHVkZU5hbWU6IHRydWUgfSl9KWAsCiAgICAgICAgICAgICAgYERhdGE6ICAgJHtkYXRhfSAoJHtzaXplM30gYnl0ZXMpYAogICAgICAgICAgICBdLAogICAgICAgICAgICBuYW1lOiAiRGVjb2RlTG9nRGF0YU1pc21hdGNoIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImFiaUl0ZW0iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkYXRhIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAicGFyYW1zIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAic2l6ZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaUl0ZW0gPSBhYmlJdGVtOwogICAgICAgICAgdGhpcy5kYXRhID0gZGF0YTsKICAgICAgICAgIHRoaXMucGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgdGhpcy5zaXplID0gc2l6ZTM7CiAgICAgICAgfQogICAgICB9OwogICAgICBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBwYXJhbSB9KSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICAgICAgIGBFeHBlY3RlZCBhIHRvcGljIGZvciBpbmRleGVkIGV2ZW50IHBhcmFtZXRlciR7cGFyYW0ubmFtZSA/IGAgIiR7cGFyYW0ubmFtZX0iYCA6ICIifSBvbiBldmVudCAiJHtmb3JtYXRBYmlJdGVtMihhYmlJdGVtLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pfSIuYAogICAgICAgICAgXS5qb2luKCJcbiIpLCB7IG5hbWU6ICJEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCIg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LCB7IGRvY3NQYXRoOiBkb2NzUGF0aDksIG5hbWU6ICJJbnZhbGlkQWJpRGVjb2RpbmdUeXBlIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRBcnJheUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih2YWx1ZSkgewogICAgICAgICAgc3VwZXIoW2BWYWx1ZSAiJHt2YWx1ZX0iIGlzIG5vdCBhIHZhbGlkIGFycmF5LmBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBcnJheUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRGVmaW5pdGlvblR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlZmluaXRpb24gdHlwZS5gLAogICAgICAgICAgICAnVmFsaWQgdHlwZXM6ICJmdW5jdGlvbiIsICJldmVudCIsICJlcnJvciInCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsgbmFtZTogIkludmFsaWREZWZpbml0aW9uVHlwZUVycm9yIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVuc3VwcG9ydGVkUGFja2VkQWJpVHlwZSA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoYFR5cGUgIiR7dHlwZX0iIGlzIG5vdCBzdXBwb3J0ZWQgZm9yIHBhY2tlZCBlbmNvZGluZy5gLCB7CiAgICAgICAgICAgIG5hbWU6ICJVbnN1cHBvcnRlZFBhY2tlZEFiaVR5cGUiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07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IpIHsKICAgICAgaWYgKGRhdGEubGVuZ3RoID09PSAxICYmIGRpciA9PT0gInJpZ2h0IikKICAgICAgICBkYXRhID0gYCR7ZGF0YX0wYDsKICAgICAgcmV0dXJuIGAweCR7ZGF0YS5sZW5ndGggJSAyID09PSAxID8gYDAke2RhdGF9YCA6IGRhdGF9YDsKICAgIH0KICAgIHJldHVybiBkYXRhOwogIH0KICB2YXIgaW5pdF90cmltID0gX19lc20oewogICAgIm5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9kYXRhL3RyaW0uanMiKCkgewogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvZW5jb2RpbmcvZnJvbUhleC5qcwogIGZ1bmN0aW9uIGFzc2VydFNpemUoaGV4T3JCeXRlcywgeyBzaXplOiBzaXplMyB9KSB7CiAgICBpZiAoc2l6ZShoZXhPckJ5dGVzKSA+IHNpemUzKQogICAgICB0aHJvdyBuZXcgU2l6ZU92ZXJmbG93RXJyb3IoewogICAgICAgIGdpdmVuU2l6ZTogc2l6ZShoZXhPckJ5dGVzKSwKICAgICAgICBtYXhTaXplOiBzaXplMwogICAgICB9KTsKICB9CiAgZnVuY3Rpb24gZnJvbUhleChoZXgsIHRvT3JPcHRzKSB7CiAgICBjb25zdCBvcHRzID0gdHlwZW9mIHRvT3JPcHRzID09PSAic3RyaW5nIiA/IHsgdG86IHRvT3JPcHRzIH0gOiB0b09yT3B0czsKICAgIGNvbnN0IHRvID0gb3B0cy50bzsKICAgIGlmICh0byA9PT0gIm51bWJlciIpCiAgICAgIHJldHVybiBoZXhUb051bWJlcihoZXgsIG9wdHMpOwogICAgaWYgKHRvID09PSAiYmlnaW50IikKICAgICAgcmV0dXJuIGhleFRvQmlnSW50KGhleCwgb3B0cyk7CiAgICBpZiAodG8gPT09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5kKyspIHsKICAgICAgZm9yIChsZXQgeCA9IDA7IHggPCAxMDsgeCsrKQogICAgICAgIEJbeF0gPSBzW3hdIF4gc1t4ICsgMTBdIF4gc1t4ICsgMjBdIF4gc1t4ICsgMzBdIF4gc1t4ICsgNDBdOwogICAgICBmb3IgKGxldCB4ID0gMDsgeCA8IDEwOyB4ICs9IDIpIHsKICAgICAgICBjb25zdCBpZHgxID0gKHggKyA4KSAlIDEwOwogICAgICAgIGNvbnN0IGlkeDAgPSAoeCArIDIpICUgMTA7CiAgICAgICAgY29uc3QgQjAgPSBCW2lkeDBdOwogICAgICAgIGNvbnN0IEIxID0gQltpZHgwICsgMV07CiAgICAgICAgY29uc3QgVGggPSByb3RsSChCMCwgQjEsIDEpIF4gQltpZHgxXTsKICAgICAgICBjb25zdCBUbCA9IHJvdGxMKEIwLCBCMSwgMSkgXiBCW2lkeDEgKyAxXTsKICAgICAgICBmb3IgKGxldCB5ID0gMDsgeSA8IDUwOyB5ICs9IDEwKSB7CiAgICAgICAgICBzW3ggKyB5XSBePSBUaDsKICAgICAgICAgIHNbeCArIHkgKyAxXSBePSBUbDsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGN1ckggPSBzWzJdOwogICAgICBsZXQgY3VyTCA9IHNbM107CiAgICAgIGZvciAobGV0IHQgPSAwOyB0IDwgMjQ7IHQrKykgewogICAgICAgIGNvbnN0IHNoaWZ0ID0gU0hBM19ST1RMW3RdOwogICAgICAgIGNvbnN0IFRoID0gcm90bEgoY3VySCwgY3VyTCwgc2hpZnQpOwogICAgICAgIGNvbnN0IFRsID0gcm90bEwoY3VySCwgY3VyTCwgc2hpZnQpOwogICAgICAgIGNvbnN0IFBJID0gU0hBM19QSVt0XTsKICAgICAgICBjdXJIID0gc1tQSV07CiAgICAgICAgY3VyTCA9IHNbUEkgKyAxXTsKICAgICAgICBzW1BJXSA9IFRoOwogICAgICAgIHNbUEkgKyAxXSA9IFRsOwogICAgICB9CiAgICAgIGZvciAobGV0IH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gKi8gQmlnSW50KDEpOwogICAgICBfMm4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDIpOwogICAgICBfN24gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDcpOwogICAgICBfMjU2biA9IC8qIEBfX1BVUkVfXyAqLyBCaWdJbnQoMjU2KTsKICAgICAgXzB4NzFuID0gLyogQF9fUFVSRV9fICovIEJpZ0ludCgxMTMpOwogICAgICBmb3IgKGxldCByb3VuZCA9IDAsIFIgPSBfMW4sIHggPSAxLCB5ID0gMDsgcm91bmQgPCAyNDsgcm91bmQrKykgewogICAgICAgIFt4LCB5XSA9IFt5LCAoMiAqIHggKyAzICogeSkgJSA1XTsKICAgICAgICBTSEEzX1BJLnB1c2goMiAqICg1ICogeSArIHgpKTsKICAgICAgICBTSEEzX1JPVEwucHVzaCgocm91bmQgKyAxKSAqIChyb3VuZCArIDIpIC8gMiAlIDY0KTsKICAgICAgICBsZXQgdCA9IF8wbjsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDc7IGorKykgewogICAgICAgICAgUiA9IChSIDw8IF8xbiBeIChSID4+IF83bikgKiBfMHg3MW4pICUgXzI1Nm47CiAgICAgICAgICBpZiAoUiAmIF8ybikKICAgICAgICAgICAgdCBePSBfMW4gPDwgKF8xbiA8PCAvKiBAX19QVVJFX18gKi8gQmlnSW50KGopKSAtIF8xbjsKICAgICAgICB9CiAgICAgICAgX1NIQTNfSU9UQS5wdXNoKHQpOwogICAgICB9CiAgICAgIFtTSEEzX0lPVEFfSCwgU0hBM19JT1RBX0xdID0gLyogQF9fUFVSRV9fICovIHNwbGl0KF9TSEEzX0lPVEEsIHRydWUpOwogICAgICByb3RsSCA9IChoLCBsLCBzKSA9PiBzID4gMzIgPyByb3RsQkgoaCwgbCwgcykgOiByb3RsU0goaCwgbCwgcyk7CiAgICAgIHJvdGxMID0gKGgsIGwsIHMpID0+IHMgPiAzMiA/IHJvdGxCTChoLCBsLCBzKSA6IHJvdGxTTChoLCBsLC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lMzIpOwogICAgICAgICAga2VjY2FrUCh0aGlzLnN0YXRlMzIsIHRoaXMucm91bmRzKTsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAgdGhpcy5wb3NPdXQgPSAwOwogICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiwgc3RhdGUgfSA9IHRoaXM7CiAgICAgICAgICBkYXRhID0gdG9CeXRlczIoZGF0YSk7CiAgICAgICAgICBjb25zdCBsZW4gPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDA7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGNvbnN0IHRha2UgPSBNYXRoLm1pbihibG9ja0xlbiAtIHRoaXMucG9zLCBsZW4gLSBwb3MpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRha2U7IGkrKykKICAgICAgICAgICAgICBzdGF0ZVt0aGlzLnBvcysrXSBePSBkYXRhW3BvcysrXTsKICAgICAgICAgICAgaWYgKHRoaXMucG9zID09PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGZpbmlzaCgpIHsKICAgICAgICAgIGlmICh0aGlzLmZpbmlzaGVkKQogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB0aGlzLmZpbmlzaGVkID0gdHJ1ZTsKICAgICAgICAgIGNvbnN0IHsgc3RhdGUsIHN1ZmZpeCwgcG9zLCBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIHN0YXRlW3Bvc10gXj0gc3VmZml4OwogICAgICAgICAgaWYgKChzdWZmaXggJiAxMjgpICE9PSAwICYmIHBvcyA9PT0gYmxvY2tMZW4gLSAxKQogICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgc3RhdGVbYmxvY2tMZW4gLSAxXSBePSAxMjg7CiAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgIH0KICAgICAgICB3cml0ZUludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcywgZmFsc2UpOwogICAgICAgICAgYnl0ZXMob3V0KTsKICAgICAgICAgIHRoaXMuZmluaXNoKCk7CiAgICAgICAgICBjb25zdCBidWZmZXJPdXQgPSB0aGlzLnN0YXRlOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDAsIGxlbiA9IG91dC5sZW5ndGg7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnBvc091dCA+PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvc091dCwgbGVuIC0gcG9zKTsKICAgICAgICAgICAgb3V0LnNldChidWZmZXJPdXQuc3ViYXJyYXkodGhpcy5wb3NPdXQsIHRoaXMucG9zT3V0ICsgdGFrZSksIHBvcyk7CiAgICAgICAgICAgIHRoaXMucG9zT3V0ICs9IHRha2U7CiAgICAgICAgICAgIHBvcyArPSB0YWtlOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG91dDsKICAgICAgICB9CiAgICAgICAgeG9mSW50byhvdXQpIHsKICAgICAgICAgIGlmICghdGhpcy5lbmFibGVYT0YpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiWE9GIGlzIG5vdCBwb3NzaWJsZSBmb3IgdGhpcyBpbnN0YW5jZSIpOwogICAgICAgICAgcmV0dXJuIHRoaXMud3JpdGVJbnRvKG91dCk7CiAgICAgICAgfQogICAgICAgIHhvZihieXRlczIpIHsKICAgICAgICAgIG51bWJlcihieXRlczIpOwogICAgICAgICAgcmV0dXJuIHRoaXMueG9mSW50byhuZXcgVWludDhBcnJheShieXRlczIpKTsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIG91dHB1dChvdXQsIHRoaXMpOwogICAgICAgICAgaWYgKHRoaXMuZmluaXNoZWQpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZGlnZXN0KCkgd2FzIGFscmVhZHkgY2FsbGVkIik7CiAgICAgICAgICB0aGlzLndyaXRlSW50byhvdXQpOwogICAgICAgICAgdGhpcy5kZXN0cm95KCk7CiAgICAgICAgICByZXR1cm4gb3V0OwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5kaWdlc3RJbnRvKG5ldyBVaW50OEFycmF5KHRoaXMub3V0cHV0TGVuKSk7CiAgICAgICAgfQogICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICB0aGlzLnN0YXRlLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIGNvbnN0IHsgYmxvY2tMZW4sIHN1ZmZpeCwgb3V0cHV0TGVuLCByb3VuZHMsIGVuYWJsZVhPRiB9ID0gdGhpczsKICAgICAgICAgIHRvIHx8ICh0byA9IG5ldyBfS2VjY2FrKGJsb2NrTGVuLCBzdWZmaXgsIG91dHB1dExlbiwgZW5hYmxlWE9GLCByb3VuZHMpKTsKICAgICAgICAgIHRvLnN0YXRlMzIuc2V0KHRoaXMuc3RhdGUzMik7CiAgICAgICAgICB0by5wb3MgPSB0aGlzLnBvczsKICAgICAgICAgIHRvLnBvc091dCA9IHRoaXMucG9zT3V0OwogICAgICAgICAgdG8uZmluaXNoZWQgPSB0aGlzLmZpbmlzaGVkOwogICAgICAgICAgdG8ucm91bmRz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kKICAgICAgICBjb250aW51ZTsKICAgICAgaWYgKGxldmVsID09PSAwKSB7CiAgICAgICAgaWYgKGNoYXIgPT09ICIgIiAmJiBbImV2ZW50IiwgImZ1bmN0aW9uIiwgIiJdLmluY2x1ZGVzKHJlc3VsdCkpCiAgICAgICAgICByZXN1bHQgPSAiIjsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICAgICAgaWYgKGNoYXIgPT09ICIpIikgewogICAgICAgICAgICB2YWxpZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gIiAiKSB7CiAgICAgICAgaWYgKHNpZ25hdHVyZVtpIC0gMV0gIT09ICIsIiAmJiBjdXJyZW50ICE9PSAiLCIgJiYgY3VycmVudCAhPT0gIiwoIikgewogICAgICAgICAgY3VycmVudCA9ICIiOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICBjdXJyZW50ICs9IGNoYXI7CiAgICB9CiAgICBpZiAoIXZhbGlkKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigiVW5hYmxlIHRvIG5vcm1hbGl6ZSBzaWduYXR1cmUuIik7CiAgICByZXR1cm4gcmVzdWx0OwogIH0KICB2YXIgaW5pdF9ub3JtYWxpemVTaWduYXR1cmUgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL2hhc2gvbm9ybWFsaXplU2lnbmF0dXJlLmpzIigpIHsKICAgICAgaW5pdF9iYXNlKCk7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9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BoZXggY2hhcmFjdGVycykuIiwKICAgICAgICAgICAgICAiLSBBZGRyZXNzIG11c3QgbWF0Y2ggaXRzIGNoZWNrc3VtIGNvdW50ZXJwYXJ0LiIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBZGRyZXNzRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9scnUuanMKICB2YXIgTHJ1TWFwOwogIHZhciBpbml0X2xydSA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvbHJ1LmpzIigpIHsKICAgICAgTHJ1TWFwID0gY2xhc3MgZXh0ZW5kcyBNYXAgewogICAgICAgIGNvbnN0cnVjdG9yKHNpemUzKSB7CiAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtYXhTaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMubWF4U2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgICBnZXQoa2V5KSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHN1cGVyLmdldChrZXkpOwogICAgICAgICAgaWYgKHN1cGVyLmhhcyhrZXkpICYmIHZhbHVlICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgdGhpcy5kZWxldGUoa2V5KTsKICAgICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICA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XyA9IHZhbHVlOwogICAgICBpZiAoYnl0ZXNTaXplICUgMzIgIT09IDApCiAgICAgICAgdmFsdWVfID0gcGFkSGV4KHZhbHVlXywgewogICAgICAgICAgZGlyOiAicmlnaHQiLAogICAgICAgICAgc2l6ZTogTWF0aC5jZWlsKCh2YWx1ZS5sZW5ndGggLSAyKSAvIDIgLyAzMikgKiAzMgogICAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGR5bmFtaWM6IHRydWUsCiAgICAgICAgZW5jb2RlZDogY29uY2F0KFtwYWRIZXgobnVtYmVyVG9IZXgoYnl0ZXNTaXplLCB7IHNpemU6IDMyIH0pKSwgdmFsdWVfXSkKICAgICAgfTsKICAgIH0KICAgIGlmIChieXRlc1NpemUgIT09IE51bWJlci5wYXJzZUludChwYXJhbVNpemUpKQogICAgICB0aHJvdyBuZXcgQWJpRW5jb2RpbmdCeXRlc1NpemVNaXNtYXRjaEVycm9yKHsKICAgICAgICBleHBlY3RlZFNpemU6IE51bWJlci5wYXJzZUludChwYXJhbVNpemUpLAogICAgICAgIHZhbHVlCiAgICAgIH0pOwogICAgcmV0dXJuIHsgZHluYW1pYzogZmFsc2UsIGVuY29kZWQ6IHBhZEhleCh2YWx1ZSwgeyBkaXI6ICJyaWdodCIgfSkgfTsKICB9CiAgZnVuY3Rpb24gZW5jb2RlQm9vbCh2YWx1ZSkgewogICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gImJvb2xlYW4iKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMihgSW52YWxpZCBib29sZWFuIHZhbHVlOiAiJHt2YWx1ZX0iICh0eXBlOiAke3R5cGVvZiB2YWx1ZX0pLiBFeHBlY3RlZDogXGB0cnVlXGAgb3IgXGBmYWxzZVxgLmApOwogICAgcmV0dXJuIHsgZHluYW1pYzogZmFsc2UsIGVuY29kZWQ6IHBhZEhleChib29sVG9IZXgodmFsdWUpKSB9OwogIH0KICBmdW5jdGlvbiBlbmNvZGVOdW1iZXIodmF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ICAgICAgICBpZiAoYWJpSXRlbS50eXBlID09PSAiZnVuY3Rpb24iKQogICAgICAgICAgcmV0dXJuIHRvRnVuY3Rpb25TZWxlY3RvcihhYmlJdGVtKSA9PT0gbmFtZTsKICAgICAgICBpZiAoYWJpSXRlbS50eXBlID09PSAiZXZlbnQiKQogICAgICAgICAgcmV0dXJuIHRvRXZlbnRTZWxlY3RvcihhYmlJdGVtKSA9PT0gbmFtZTsKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIH0KICAgICAgcmV0dXJuICJuYW1lIiBpbiBhYmlJdGVtICYmIGFiaUl0ZW0ubmFtZSA9PT0gbmFtZTsKICAgIH0pOwogICAgaWYgKGFiaUl0ZW1zLmxlbmd0aCA9PT0gMCkKICAgICAgcmV0dXJuIHZvaWQgMDsKICAgIGlmIChhYmlJdGVtcy5sZW5ndGggPT09IDEpCiAgICAgIHJldHVybiBhYmlJdGVtc1swXTsKICAgIGxldCBtYXRjaGVkQWJpSXRlbSA9IHZvaWQgMDsKICAgIGZvciAoY29uc3QgYWJpSXRlbSBvZiBhYmlJdGVtcykgewogICAgICBpZiAoISgiaW5wdXRzIiBpbiBhYmlJdGVtKSkKICAgICAgICBjb250aW51ZTsKICAgICAgaWYgKCFhcmdzIHx8IGFyZ3MubGVuZ3RoID09PSAwKSB7CiAgICAgICAgaWYgKCFhYmlJdGVtLmlucHV0cyB8fCBhYmlJdGVtLmlucHV0cy5sZW5ndGggPT09IDApCiAgICAgICAgICByZXR1cm4gYWJpSXRlbTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIWFiaUl0ZW0uaW5wdXRzKQogICAgICAgIGNvbnRpbnVlOwogICAgICBpZiAoYWJpSXRlbS5pbnB1dHMubGVuZ3RoID09PSAwKQogICAgICAgIGNvbnRpbnVlOwogICAgICBpZiAoYWJpSXRlbS5pbnB1dHMubGVuZ3RoICE9PSBhcmdzLmxlbmd0aCkKICAgICAgICBjb250aW51ZTsKICAgICAgY29uc3Qg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4gYXJyYXkgd2hpY2ggaXMgdG9vIGxhcmdlLiIsCiAgICAgICAgODE6ICJBdHRlbXB0ZWQgdG8gY2FsbCBhIHplcm8taW5pdGlhbGl6ZWQgdmFyaWFibGUgb2YgaW50ZXJuYWwgZnVuY3Rpb24gdHlwZS4iCiAgICAgIH07CiAgICAgIHNvbGlkaXR5RXJyb3IgPSB7CiAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICB7CiAgICAgICAgICAgIG5hbWU6ICJtZXNzYWdlIiwKICAgICAgICAgICAgdHlwZTogInN0cmluZyIKICAgICAgICAgIH0KICAgICAgICBdLAogICAgICAgIG5hbWU6ICJFcnJvciIsCiAgICAgICAgdHlwZTogImVycm9yIgogICAgICB9OwogICAgICBzb2xpZGl0eVBhbmljID0gewogICAgICAgIGlucHV0czogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAicmVhc29uIiwKICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBuYW1lOiAiUGFuaWMiLAogICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2Vycm9ycy9jdXJzb3IuanMKICB2YXIgTmVnYXRpdmVPZmZzZXRFcnJvciwgUG9zaXRpb25PdXRPZkJvdW5kc0Vycm9yLCBSZWN1cnNpdmVSZWFkTGltaXRFeGNlZWRlZEVycm9yOwogIHZhciBpbml0X2N1cnNvciA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL2N1cnNvci5qcyIoKSB7CiAgICAgIGluaXRfYmFzZSgpOwogICAgICBOZWdhdGl2ZU9mZnNldEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJ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IGluY3JlbWVudFBvc2l0aW9uKG9mZnNldCkgewogICAgICAgICAgaWYgKG9mZnNldCA8IDApCiAgICAgICAgICAgIHRocm93IG5ldyBOZWdhdGl2ZU9mZnNldEVycm9yKHsgb2Zmc2V0IH0pOwogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uICsgb2Zmc2V0OwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0Qnl0ZShwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzW3Bvc2l0aW9uXTsKICAgICAgICB9LAogICAgICAgIGluc3BlY3RCeXRlcyhsZW5ndGgsIHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyBsZW5ndGggLSAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLnN1YmFycmF5KHBvc2l0aW9uLCBwb3NpdGlvbiArIGxlbmd0aCk7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDgocG9zaXRpb25fKSB7CiAgICAgICAgICBjb25zdCBwb3NpdGlvbiA9IHBvc2l0aW9uXyA/PyB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICByZXR1cm4gdGhpcy5ieXRlc1twb3NpdGlvbl07CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDE2KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmRhdGFWaWV3LmdldFVpbnQxNihwb3NpdGlvbik7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDI0KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAyKTsKICAgICAgICAgIHJldHVybiAodGhpcy5kYXRhVmlldy5nZXRVaW50MTYocG9zaXRpb24pIDw8IDgpICsgdGhpcy5kYXRhVmlldy5nZXRVaW50OChwb3NpdGlvbiArIDIpOwogICAgICAgIH0sCiAgICAgICAgaW5zcGVjdFVpbnQzMihwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uICsgMyk7CiAgICAgICAgICByZXR1cm4gdGhpcy5kYXRhVmlldy5nZXRVaW50MzIocG9zaXRpb24pOwogICAgICAgIH0sCiAgICAgICAgcHVzaEJ5dGUoYnl0ZSkgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9uKTsKICAgICAgICAgIHRoaXMuYnl0ZXNbdGhpcy5wb3NpdGlvbl0gPSBieXRlOwogICAgICAgICAgdGhpcy5wb3NpdGlvbisrOwogICAgICAgIH0sCiAgICAgICAgcHVzaEJ5dGVzKGJ5dGVzMikgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9u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YWx1ZSk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDQ7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZSgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RCeXRlKCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uKys7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZXMobGVuZ3RoLCBzaXplMykgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdEJ5dGVzKGxlbmd0aCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IHNpemUzID8/IGxlbmd0aDsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50OCgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50OCgpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAxOwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgcmVhZFVpbnQxNigpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50MTYoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb24gKz0gMjsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50MjQoKSB7CiAgICAgICAgICB0aGlzLmFzc2VydFJlYWRMaW1pdCgpOwogICAgICAgICAgdGhpcy5fdG91Y2goKTsKICAgICAgICAgIGNvbnN0IHZhbHVlID0gdGhpcy5pbnNwZWN0VWludDI0KCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDM7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkVWludDMyKCkgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdFVpbnQzMigpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSA0OwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgZ2V0IHJlbWFpbmluZygpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmxlbmd0aCAtIHRoaXMucG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBzZXRQb3NpdGlvbihwb3NpdGlvbikgewogICAgICAgICAgY29uc3Qgb2xkUG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgICByZXR1cm4gKCkgPT4gdGhpcy5wb3NpdGlvbiA9IG9sZFBvc2l0aW9uOwogICAgICAgIH0sCiAgICAgICAgX3RvdWNoKCkgewogICAgICAgICAgaWYgKHRoaXMucmVjdXJzaXZlUmVhZExpbWl0ID09PSBOdW1iZXIuUE9TSVRJVkVfSU5GSU5JVFkpCiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNvbnN0IGNvdW50ID0gdGhpcy5nZXRSZWFkQ291bnQoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb25SZWFkQ291bnQuc2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AgICAgICAgc3VwZXIoYEludmFsaWQgXGB2XGAgdmFsdWUgIiR7dn0iLiBFeHBlY3RlZCAyNyBvciAyOC5gLCB7CiAgICAgICAgICAgIG5hbWU6ICJJbnZhbGlkTGVnYWN5VkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXphYmxlVHJhbnNhY3Rpb25FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0cmFuc2FjdGlvbiB9KSB7CiAgICAgICAgICBzdXBlcigiQ2Fubm90IGluZmVyIGEgdHJhbnNhY3Rpb24gdHlwZSBmcm9tIHByb3ZpZGVkIHRyYW5zYWN0aW9uLiIsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIlByb3ZpZGVkIFRyYW5zYWN0aW9uOiIsCiAgICAgICAgICAgICAgInsiLAogICAgICAgICAgICAgIHByZXR0eVByaW50KHRyYW5zYWN0aW9uKSwKICAgICAgICAgICAgICAifSIsCiAgICAgICAgICAgICAgIiIsCiAgICAgICAgICAgICAgIlRvIGluZmVyIHRoZSB0eXBlLCBlaXRoZXIgcHJvdmlkZToiLAogICAgICAgICAgICAgICItIGEgYHR5cGVgIHRvIHRoZSBUcmFuc2FjdGlvbiwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC0xNTU5IFRyYW5zYWN0aW9uIHdpdGggYG1heEZlZVBlckdhc2AsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtMjkzMCBUcmFuc2FjdGlvbiB3aXRoIGBnYXNQcmljZWAgJiBgYWNjZXNzTGlzdGAsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtNDg0NCBUcmFuc2FjdGlvbiB3aXRoIGBibG9ic2AsIGBibG9iVmVyc2lvbmVkSGFzaGVzYCwgYHNpZGVjYXJzYCwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC03NzAyIFRyYW5zYWN0aW9uIHdpdGggYGF1dGhvcml6YXRpb25MaXN0YCwgb3IiLAogICAgICAgICAgICAgICItIGEgTGVnYWN5IFRyYW5zYWN0aW9uIHdpdGggYGdhc1ByaWNlYCIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemFibGVUcmFuc2FjdGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uVHlwZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHNlcmlhbGl6ZWRUeXBlIH0pIHsKICAgICAgICAgIHN1cGVyKGBTZXJpYWxpemVkIHRyYW5zYWN0aW9uIHR5cGUgIiR7c2VyaWFsaXplZFR5cGV9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25UeXBlIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlcmlhbGl6ZWRUeXBlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuc2VyaWFsaXplZFR5cGUgPSBzZXJpYWxpemVkVHlwZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhdHRyaWJ1dGVzLCBzZXJpYWxpemVkVHJhbnNhY3Rpb24sIHR5cGUgfSkgewogICAgICAgICAgY29uc3QgbWlzc2luZyA9IE9iamVjdC5lbnRyaWVzKGF0dHJpYnV0ZXMpLm1hcCgoW2tleSwgdmFsdWVdKSA9PiB0eXBlb2YgdmFsdWUgPT09ICJ1bmRlZmluZWQiID8ga2V5IDogdm9pZCAwKS5maWx0ZXIoQm9vbGVhbik7CiAgICAgICAgICBzdXBlcihgSW52YWxpZCBzZXJpYWxpemVkIHRyYW5zYWN0aW9uIG9mIHR5cGUgIiR7dHlwZX0iIHdhcyBwcm92aWRlZC5gLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBTZXJpYWxpemVkIFRyYW5zYWN0aW9uOiAiJHtzZXJpYWxpemVkVHJhbnNhY3Rpb259ImAsCiAgICAgICAgICAgICAgbWlzc2luZy5sZW5ndGggPiAwID8gYE1pc3NpbmcgQXR0cmlidXRlczogJHttaXNzaW5nLmpvaW4oIiwgIil9YCA6ICIiCiAgICAgICAgICAgIF0uZmlsdGVyKEJvb2xlYW4pLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlcmlhbGl6ZWRUcmFuc2FjdGlvbiIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInR5cGUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IH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iAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuY2F1c2UgPSBjYXVzZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFRyYW5zYWN0aW9uTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBibG9ja0hhc2gsIGJsb2NrTnVtYmVyLCBibG9ja1RhZywgaGFzaDogaGFzaDMsIGluZGV4OiBpbmRleDIgfSkgewogICAgICAgICAgbGV0IGlkZW50aWZpZXIgPSAiVHJhbnNhY3Rpb24iOwogICAgICAgICAgaWYgKGJsb2NrVGFnICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIHRpbWUgIiR7YmxvY2tUYWd9IiBhdCBpbmRleCAiJHtpbmRleDJ9ImA7CiAgICAgICAgICBpZiAoYmxvY2tIYXNoICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIGhhc2ggIiR7YmxvY2tIYXNofSIgYXQgaW5kZXggIiR7aW5kZXgyfSJgOwogICAgICAgICAgaWYgKGJsb2NrTnVtYmVyICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIG51bWJlciAiJHtibG9ja051bWJlcn0iIGF0IGluZGV4ICIke2luZGV4Mn0iYDsKICAgICAgICAgIGlmIChoYXNoMykKICAgIC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dhcyAhPT0gInVuZGVmaW5lZCIgJiYgYCR7Zm9ybWF0R3dlaShtYXhGZWVQZXJHYXMpfSBnd2VpYCwKICAgICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXM6IHR5cGVvZiBtYXhQcmlvcml0eUZlZVBlckdhcyAhPT0gInVuZGVmaW5lZCIgJiYgYCR7Zm9ybWF0R3dlaShtYXhQcmlvcml0eUZlZVBlckdhcyl9IGd3ZWlgLAogICAgICAgICAgICBub25jZQogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoc3RhdGVPdmVycmlkZSkgewogICAgICAgICAgICBwcmV0dHlBcmdzICs9IGAKJHtwcmV0dHlTdGF0ZU92ZXJyaWRlKHN0YXRlT3ZlcnJpZGUpfWA7CiAgICAgICAgICB9CiAgICAgICAgICBzdXBlcihjYXVzZS5zaG9ydE1lc3NhZ2UsIHsKICAgICAgICAgICAgY2F1c2UsCiAgICAgICAgICAgIGRvY3NQYXRoOiBkb2NzUGF0aDksCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIC4uLmNhdXNlLm1ldGFNZXNzYWdlcyA/IFsuLi5jYXVzZS5tZXRhTWVzc2FnZXMsICIgIl0gOiBbXSwKICAgICAgICAgICAgICAiUmF3IENhbGwgQXJndW1lbnRzOiIsCiAgICAgICAgICAgICAgcHJldHR5QXJncwogICAgICAgICAgICBdLmZpbHRlcihCb29sZWFuKSwKICAgICAgICAgICAgbmFtZTogIkNhbGxFeGVjdXRpb25FcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjYXVzZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGl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TmFtZT8ubGVuZ3RoID8/IDApLmtleXMoKV0ubWFwKCgpID0+ICIgIikuam9pbigiIil9JHtmb3JtYXR0ZWRBcmdzfWAsCiAgICAgICAgICAgIHNlbmRlcgogICAgICAgICAgfSk7CiAgICAgICAgICBzdXBlcihjYXVzZS5zaG9ydE1lc3NhZ2UgfHwgYEFuIHVua25vd24gZXJyb3Igb2NjdXJyZWQgd2hpbGUgZXhlY3V0aW5nIHRoZSBjb250cmFjdCBmdW5jdGlvbiAiJHtmdW5jdGlvbk5hbWV9Ii5gLCB7CiAgICAgICAgICAgIGNhdXNlLAogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAuLi5jYXVzZS5tZXRhTWVzc2FnZXMgPyBbLi4uY2F1c2UubWV0YU1lc3NhZ2VzLCAiICJdIDogW10sCiAgICAgICAgICAgICAgcHJldHR5QXJncyAmJiAiQ29udHJhY3QgQ2FsbDoiLAogICAgICAgICAgICAgIHByZXR0eUFyZ3MKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJDb250cmFjdEZ1bmN0aW9uRXhlY3V0aW9uRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiYWJpIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiYXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29udHJhY3RBZGRyZXNzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZm9ybWF0dGVkQXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImZ1bmN0aW9uTmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlbmRlciIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaSA9IGFiaTI7CiAgICAgICAgICB0aGlzLmFyZ3MgPSBhcmdzOwogICAgICAgICAgdGhpcy5jYXVzZSA9IGNhdXNlOwogICAgICAgICAgdGhpcy5jb250cmFjdEFkZHJlc3MgPSBjb250cmFjdEFkZHJlc3M7CiAgICAgICAgICB0aGlzLmZ1bmN0aW9uTmFtZSA9IGZ1bmN0aW9uTmFtZTsKICAgICAgICAgIHRoaXMuc2VuZGVyID0gc2VuZGVyOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYWJpOiBhYmkyLCBkYXRhLCBmdW5jdGlvbk5hbWUsIG1lc3NhZ2UgfSkgewogICAgICAgICAgbGV0IGNhdXNlOwogICAgICAgICAgbGV0IGRlY29kZWREYXRhID0gdm9pZCAwOwogICAgICAgICAgbGV0IG1ldGFNZXNzYWdlczsKICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICBpZiAoZGF0YSAmJiBkYXRhICE9PSAiMHgiKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZGVjb2RlZERhdGEgPSBkZWNvZGVFcnJvclJlc3VsdCh7IGFiaTogYWJpMiwgZGF0YSB9KTsKICAgICAgICAgICAgICBjb25zdCB7IGFiaUl0ZW0sIGVycm9yTmFtZSwgYXJnczogZXJyb3JBcmdzIH0gPSBkZWNvZGVkRGF0YTsKICAgICAgICAgICAgICBpZiAoZXJyb3JOYW1lID09PSAiRXJyb3IiKSB7CiAgICAgICAgICAgICAgICByZWFzb24gPSBlcnJvckFyZ3NbMF07CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnJvck5hbWUgPT09ICJQYW5pYyIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IFtmaXJzdEFyZ10gPSBlcnJvckFyZ3M7CiAgICAgICAgICAgICAgICByZWFzb24gPSBwYW5pY1JlYXNvbnNbZmlyc3RBcmddOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb25zdCBlcnJvcldpdGhQYXJhbXMgPSBhYmlJdGVtID8gZm9ybWF0QWJpSXRlbTIoYWJpSXRlbSwgeyBpbmNsdWRlTmFtZTogdHJ1ZSB9KSA6IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZEFyZ3MgPSBhYmlJdGVtICYmIGVycm9yQXJncyA/IGZvcm1hdEFiaUl0ZW1XaXRoQXJncyh7CiAgICAgICAgICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICAgICAgICAgIGFyZ3M6IGVycm9yQXJncywKICAgICAgICAgICAgICAgICAgaW5jbHVkZUZ1bmN0aW9uTmFtZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVOYW1lOiBmYWxzZQogICAgICAgICAgICAgICAgfSkgOiB2b2lkIDA7CiAgICAgICAgICAgICAgICBtZXRhTWVzc2FnZXMgPSBbCiAgICAgICAgICAgICAgICAgIGVycm9yV2l0aFBhcmFtcyA/IGBFcnJvcjogJHtlcnJvcldpdGhQYXJhbXN9YCA6ICIiLAogICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRBcmdzICYmIGZvcm1hdHRlZEFyZ3MgIT09ICIoKSIgPyBgICAgICAgICR7Wy4uLkFycmF5KGVycm9yTmFtZT8ubGVuZ3RoID8/IDApLmtleXMoKV0ubWFwKCgpID0+ICIgIikuam9pbigiIil9JHtmb3JtYXR0ZWRBcmdzfWAgOiAiIgogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAg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UaGUgY29udHJhY3QgZnVuY3Rpb24gIiR7ZnVuY3Rpb25OYW1lfSIgcmV2ZXJ0ZWQuYCwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzLAogICAgICAgICAgICBuYW1lOiAiQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZGF0YSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInJlYXNvbiIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hdHVyZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmRhdGEgPSBkZWNvZGVkRGF0YTsKICAgICAgICAgIHRoaXMucmVhc29uID0gcmVhc29uOwogICAgICAgICAgdGhpcy5zaWduYXR1cmUgPSBzaWduYXR1cmU7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uWmVyb0RhdGFFcnJvciA9IGNs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LAogICAgICAgICAgICAgICItIFRoZSBgZmFjdG9yeWAgaXMgYSB2YWxpZCBjb250cmFjdCBkZXBsb3ltZW50IGZhY3RvcnkgKGllLiBDcmVhdGUyIEZhY3RvcnksIEVSQy00MzM3IEZhY3RvcnksIGV0YykuIiwKICAgICAgICAgICAgICAiLSBUaGUgYGZhY3RvcnlEYXRhYCBpcyBhIHZhbGlkIGVuY29kZWQgZnVuY3Rpb24gY2FsbCBmb3IgY29udHJhY3QgZGVwbG95bWVudCBmdW5jdGlvbiBvbiB0aGUgZmFjdG9yeS4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb3VudGVyZmFjdHVhbERlcGxveW1lbnRGYWlsZWRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgUmF3Q29udHJhY3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBkYXRhLCBtZXNzYWdlIH0pIHsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UgfHwgIiIsIHsgbmFtZTogIlJhd0NvbnRyYWN0RXJyb3IiIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjb2RlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogMwogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAg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c3RFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJib2R5IiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiaGVhZGVycyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInN0YXR1cyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInVybCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmJvZHkgPSBib2R5OwogICAgICAgICAgdGhpcy5oZWFkZXJzID0gaGVhZGVyczsKICAgICAgICAgIHRoaXMuc3RhdHVzID0gc3RhdHVzOwogICAgICAgICAgdGhpcy51cmwgPSB1cmw7CiAgICAgICAgfQogICAgICB9OwogICAgICB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XNzYWdlcywgbmFtZSwgc2hvcnRNZXNzYWdlIH0pIHsKICAgICAgICAgIHN1cGVyKHNob3J0TWVzc2FnZSwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgZG9jc1BhdGg6IGRvY3NQYXRoOSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBtZXRhTWVzc2FnZXMgfHwgY2F1c2U/Lm1ldGFNZXNzYWdlcywKICAgICAgICAgICAgbmFtZTogbmFtZSB8fCAiUnBjRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29kZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLm5hbWUgPSBuYW1lIHx8IGNhdXNlLm5hbWU7CiAgICAgICAgICB0aGlzLmNvZGUgPSBjYXVzZSBpbnN0YW5jZW9mIFJwY1JlcXVlc3RFcnJvciA/IGNhdXNlLmNvZGUgOiBjb2RlID8/IHVua25vd25FcnJvckNvZGU7CiAgICAgICAgfQogICAgICB9OwogICAgICBQcm92aWRlclJwY0Vycm9yID0gY2xhc3MgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UsIG9wdGlvbnMpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCBvcHRpb25zKTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZGF0YSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQg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zYWdlOiAiSlNPTiBpcyBub3QgYSB2YWxpZCByZXF1ZXN0IG9iamVjdC4iCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnZhbGlkUmVxdWVzdFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyNjAwCiAgICAgIH0pOwogICAgICBNZXRob2ROb3RGb3VuZFJwY0Vycm9yID0gY2xhc3MgX01ldGhvZE5vdEZvdW5kUnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UsIHsgbWV0aG9kIH0gPSB7fSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX01ldGhvZE5vdEZvdW5kUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIk1ldGhvZE5vdEZvdW5kUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IGBUaGUgbWV0aG9kJHttZXRob2QgPyBgICIke21ldGhvZH0iYCA6ICIifSBkb2VzIG5vdCBleGlzdCAvIGlzIG5vdCBhdmFpbGFibGUuYAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTWV0aG9kTm90Rm91bmRScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMQogICAgICB9KTsKICAgICAgSW52YWxpZFBhcmFtc1JwY0Vycm9yID0gY2xhc3MgX0ludmFsaWRQYXJhbXNScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludmFsaWRQYXJhbXNScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiBbCiAgICAgICAgICAgICAgIkludmFsaWQgcGFyYW1ldGVycyB3ZXJlIHByb3ZpZGVkIHRvIHRoZSBSUEMgbWV0aG9kLiIsCiAgICAgICAgICAgICAgIkRvdWJsZSBjaGVjayB5b3UgaGF2ZSBwcm92aWRlZCB0aGUgY29ycmVjdCBwYXJhbWV0ZXJzLiIKICAgICAgICAgICAgXS5qb2luKCJcbiIpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnZhbGlkUGFyYW1zUnBjRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiAtMzI2MDIKICAgICAgfSk7CiAgICAgIEludGVybmFsUnBjRXJyb3IgPSBjbGFzcyBfSW50ZXJuYWxScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludGVybmFsUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkludGVybmFsUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBpbnRlcm5hbCBlcnJvciB3YXMgcmVjZWl2ZWQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoSW50ZXJuYWxScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMwogICAgICB9KTsKICAgICAgSW52YWxpZElucHV0UnBjRXJyb3IgPSBjbGFzcyBfSW52YWxpZElucHV0UnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9JbnZhbGlkSW5wdXRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZElucHV0UnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IFsKICAgICAgICAgICAgICAiTWlzc2luZyBvciBpbnZhbGlkIHBhcmFtZXRlcnMuIiwKICAgICAgICAgICAgICAiRG91YmxlIGNoZWNrIHlvdSBoYXZlIHByb3ZpZGVkIHRoZSBjb3JyZWN0IHBhcmFtZXRlcnMuIgogICAgICAgICAgICBdLmpvaW4oIlxuIikKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEludmFsaWRJbnB1dFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyZTMKICAgICAgfSk7CiAgICAgIFJlc291cmNlTm90Rm91bmRScGNFcnJvciA9IGNsYXNzIF9SZXNvdXJjZU5vdEZvdW5kUnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7Ci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gX01ldGhvZE5vdFN1cHBvcnRlZFJwY0Vycm9yIGV4dGVuZHMgUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlLCB7IG1ldGhvZCB9ID0ge30pIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9NZXRob2ROb3RTdXBwb3J0ZWRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IGBNZXRob2Qke21ldGhvZCA/IGAgIiR7bWV0aG9kfSJgIDogIiJ9IGlzIG5vdCBpbXBsZW1lbnRlZC5gCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShNZXRob2ROb3RTdXBwb3J0ZWRScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjAwNAogICAgICB9KTsKICAgICAgTGltaXRFeGNlZWRlZFJwY0Vycm9yID0gY2xhc3MgX0xpbWl0RXhjZWVkZWRScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0xpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiTGltaXRFeGNlZWRlZFJwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiAiUmVxdWVzdCBleGNlZWRzIGRlZmluZWQgbGltaXQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lU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NhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9Vc2VyUmVqZWN0ZWRSZXF1ZXN0RXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlVzZXJSZWplY3RlZFJlcXVlc3RFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlVzZXIgcmVqZWN0ZWQgdGhlIHJlcXVlc3QuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoVXNlclJlamVjdGVkUmVxdWVzdEVycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogNDAwMQogICAgICB9KTsKICAgICAgVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvciA9IGNsYXNzIF9VbmF1dGhvcml6ZWRQcm92aWRlckVycm9yIGV4dGVuZHMgUHJvdmlkZXJScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9VbmF1dGhvcml6ZWRQcm92aWRlckVycm9yLmNvZGUsCiAgICAgICAgICAgIG5hbWU6ICJVbmF1dGhvcml6ZWRQcm92aWRlckVycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiAiVGhlIHJlcXVlc3RlZCBtZXRob2QgYW5kL29yIGFjY291bnQgaGFzIG5vdCBiZWVuIGF1dGhvcml6ZWQgYnkgdGhlIHVzZXIuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb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gICBjb2RlOiBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlRoZSBQcm92aWRlciBpcyBkaXNjb25uZWN0ZWQgZnJvbSBhbGwgY2hhaW5zLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAwCiAgICAgIH0pOwogICAgICBDaGFpbkRpc2Nvbm5lY3RlZEVycm9yID0gY2xhc3MgX0NoYWluRGlzY29ubmVjdGVkRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0NoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkNoYWluRGlzY29ubmVjdGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJUaGUgUHJvdmlkZXIgaXMgbm90IGNvbm5lY3RlZCB0byB0aGUgcmVxdWVzdGVkIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KENoYWluRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAxCiAgICAgIH0pOwogICAgICBTd2l0Y2hDaGFpbkVycm9yID0gY2xhc3MgX1N3aXRjaENoYWluRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX1N3aXRjaENoYWluRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlN3aXRjaENoYWluRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBlcnJvciBvY2N1cnJlZCB3aGVuIGF0dGVtcHRpbmcgdG8gc3dpdGNoIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFN3aXRjaENoYWluRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAyCiAgICAgIH0pOwogICAgICBVbmtub3duUnBjRXJyb3IgPSBjbGFzcyBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgbmFtZTogIlVua25vd25ScGNFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIkFuIHVua25vd24gUlBDIGVycm9yIG9jY3VycmVkLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStoYXNoZXNAMS41LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9oYXNoZXMvZXNtL19tZC5qcwogIGZ1bmN0aW9uIH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pc0xFMikgewogICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgIHRoaXMuYmxvY2tMZW4gPSBibG9ja0xlbjsKICAgICAgICAgIHRoaXMub3V0cHV0TGVuID0gb3V0cHV0TGVuOwogICAgICAgICAgdGhpcy5wYWRPZmZzZXQgPSBwYWRPZmZzZXQ7CiAgICAgICAgICB0aGlzLmlzTEUgPSBpc0xFMjsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSBmYWxzZTsKICAgICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICAgIHRoaXMucG9zID0gMDsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICB0aGlzLmJ1ZmZlciA9IG5ldyBVaW50OEFycmF5KGJsb2NrTGVuKTsKICAgICAgICAgIHRoaXMudmlldyA9IGNyZWF0ZVZpZXcodGhpcy5idWZmZXIpOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyB2aWV3LCBidWZmZXI6IGJ1ZmZlcjIsIGJsb2NrTGVuIH0gPSB0aGlzOwogICAgICAgICAgZGF0YSA9IHRvQnl0ZXMyKGRhdGEpOwogICAgICAgICAgY29uc3QgbGVuID0gZGF0YS5sZW5ndGg7CiAgICAgICAgICBmb3IgKGxldCBwb3MgPSAwOyBwb3MgPCBsZW47ICkgewogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvcywgbGVuIC0gcG9zKTsKICAgICAgICAgICAgaWYgKHRha2UgPT09IGJsb2NrTGVuKSB7CiAgICAgICAgICAgICAgY29uc3QgZGF0YVZpZXcgPSBjcmVhdGVWaWV3KGRhdGEpOwogICAgICAgICAgICAgIGZvciAoOyBibG9ja0xlbiA8PSBsZW4gLSBwb3M7IHBvcyArPSBibG9ja0xlbikKICAgICAgICAgICAgICAgIHRoaXMucHJvY2VzcyhkYXRhVmlldywgcG9zKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIyLnNldChkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgdGFrZSksIHRoaXMucG9zKTsKICAgICAgICAgICAgdGhpcy5wb3MgKz0gdGFrZTsKICAgICAgICAgICAgcG9zICs9IHRha2U7CiAgICAgICAgICAgIGlmICh0aGlzLnBvcyA9PT0gYmxvY2tMZW4pIHsKICAgICAgICAgICAgICB0aGlzLnByb2Nlc3ModmlldywgMCk7CiAgICAgICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmxlbmd0aCArPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIHRoaXMucm91bmRDbGVhbigpOwogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdEludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcyk7CiAgICAgICAgICBvdXRwdXQob3V0LCB0aGlzKTsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSB0cnVlOwogICAgICAgICAgY29uc3QgeyBidWZmZXI6IGJ1ZmZlcjIsIHZpZXcsIGJsb2NrTGVuLCBpc0xFOiBpc0xFMiB9ID0gdGhpczsKICAgICAgICAgIGxldCB7IHBvcyB9ID0gdGhpczsKICAgICAgICAgIGJ1ZmZlcjJbcG9zKytdID0gMTI4OwogICAgICAgICAgdGhpcy5idWZmZXIuc3ViYXJyYXkocG9zKS5maWxsKDApOwogICAgICAgICAgaWYgKHRoaXMucGFkT2Zmc2V0ID4gYmxvY2tMZW4gLSBwb3MpIHsKICAgICAgICAgICAgdGhpcy5wcm9jZXNzKHZpZXcsIDApOwogICAgICAgICAgICBwb3MgPSAwOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChsZXQgaSA9IHBvczsgaSA8IGJsb2NrTGVuOyBpKyspCiAgICAgICAgICAgIGJ1ZmZlcjJbaV0gPSAwOwogICAgICAgICAgc2V0QmlnVWludDY0KHZpZXcsIGJsb2NrTGVuIC0gOCwgQmlnSW50KHRoaXMubGVuZ3RoICogOCksIGlzTEUyKTsKICAgICAgICAgIHRoaXMucHJvY2Vzcyh2aWV3LCAwKTsKICAgICAgICAgIGNvbnN0IG92aWV3ID0gY3JlYXRlVmlldyhvdXQpOwogICAgICAgICAgY29uc3QgbGVuID0gdGhpcy5vdXRwdXRMZW47CiAgICAgICAgICBpZiAobGVuICUgNCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIHNob3VsZCBiZSBhbGlnbmVkIHRvIDMyYml0Iik7CiAgICAgICAgICBjb25zdCBvdXRMZW4gPSBsZW4gLyA0OwogICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLmdldCgpOwogICAgICAgICAgaWYgKG91dExlbiA+IHN0YXRlLmxlbmd0aCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIGJpZ2dlciB0aGFuIHN0YXRlIik7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG91dExlbjsgaSsrKQogICAgICAgICAgICBvdmlldy5zZXRVaW50MzIoNCAqIGksIHN0YXRlW2ldLCBpc0xFMik7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdCgpIHsKICAgICAgICAgIGNvbnN0IHsgYnVmZmVyOiBidWZmZXIyLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8oYnVmZmVyMik7CiAgICAgICAgICBjb25zdCByZXMgPSBidWZmZXIyLnNsaWNlKDAsIG91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRlc3Ryb3koKTsKICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIHRvIHx8ICh0byA9IG5ldyB0aG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2MywKICAgICAgICAxNTA4OTcwOTkzLAogICAgICAgIDI0NTM2MzU3NDgsCiAgICAgICAgMjg3MDc2MzIyMSwKICAgICAgICAzNjI0MzgxMDgwLAogICAgICAgIDMxMDU5ODQwMSwKICAgICAgICA2MDcyMjUyNzgsCiAgICAgICAgMTQyNjg4MTk4NywKICAgICAgICAxOTI1MDc4Mzg4LAogICAgICAgIDIxNjIwNzgyMDYsCiAgICAgICAgMjYxNDg4ODEwMywKICAgICAgICAzMjQ4MjIyNTgwLAogICAgICAgIDM4MzUzOTA0MDEsCiAgICAgICAgNDAyMjIyNDc3NCwKICAgICAgICAyNjQzNDcwNzgsCiAgICAgICAgNjA0ODA3NjI4LAogICAgICAgIDc3MDI1NTk4MywKICAgICAgICAxMjQ5MTUwMTIyLAogICAgICAgIDE1NTUwODE2OTIsCiAgICAgICAgMTk5NjA2NDk4NiwKICAgICAgICAyNTU0MjIwODgyLAogICAgICAgIDI4MjE4MzQzNDksCiAgICAgICAgMjk1Mjk5NjgwOCwKICAgICAgICAzMjEwMzEzNjcxLAogICAgICAgIDMzMzY1NzE4OTEsCiAgICAgICAgMzU4NDUyODcxMSwKICAgICAgICAxMTM5MjY5OTMsCiAgICAgICAgMzM4MjQxODk1LAogICAgICAgIDY2NjMwNzIwNSwKICAgICAgICA3NzM1Mjk5MTIsCiAgICAgICAgMTI5NDc1NzM3MiwKICAgICAgICAxMzk2MTgyMjkxLAogICAgICAgIDE2OTUxODM3MDAsCiAgICAgICAgMTk4NjY2MTA1MSwKICAgICAgICAyMTc3MDI2MzUwLAogICAgICAgIDI0NTY5NTYwMzcsCiAgICAgICAgMjczMDQ4NTkyMSwKICAgICAgICAyODIwMzAyNDExLAogICAgICAgIDMyNTk3MzA4MDAsCiAgICAgICAgMzM0NTc2NDc3MSwKICAgICAgICAzNTE2MDY1ODE3LAogICAgICAgIDM2MDAzNTI4MDQsCiAgICAgICAgNDA5NDU3MTkwOSwKICAgICAgICAyNzU0MjMzNDQsCiAgICAgICAgNDMwMjI3NzM0LAogICAgICAgIDUwNjk0ODYxNiwKICAgICAgICA2NTkwNjA1NTYsCiAgICAgICAgODgzOTk3ODc3LAogICAgICAgIDk1ODEzOTU3MSwKICAgICAgICAxMzIyODIyMjE4LAogICAgICAgIDE1MzcwMDIwNjMsCiAgICAgICAgMTc0Nzg3Mzc3OSwKICAgICAgICAxOTU1NTYyMjIyLAogICAgICAgIDIwMjQxMDQ4MTUsCiAgICAgICAgMjIyNzczMDQ1MiwKICAgICAgICAyMzYxODUyNDI0LAogICAgICAgIDI0Mjg0MzY0NzQsCiAgICAgICAgMjc1NjczNDE4NywKICAgICAgICAzMjA0MDMxNDc5LAogICAgICAgIDMzMjkzMjUyOTgKICAgICAgXSk7CiAgICAgIFNIQTI1Nl9JViA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoWwogICAgICAgIDE3NzkwMzM3MDMsCiAgICAgICAgMzE0NDEzNDI3NywKICAgICAgICAxMDEzOTA0MjQyLAogICAgICAgIDI3NzM0ODA3NjIsCiAgICAgICAgMTM1OTg5MzExOSwKICAgICAgICAyNjAwODIyOTI0LAogICAgICAgIDUyODczNDYzNSwKICAgICAgICAxNTQxNDU5MjI1CiAgICAgIF0pOwogICAgICBTSEEyNTZfVyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoNjQpOwogICAgICBTSEEyNTYgPSBjbGFzcyBleHRlbmRzIEhhc2hNRCB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcig2NCwgMzIsIDgsIGZhbHNlKTsKICAgICAgICAgIHRoaXMuQSA9IFNIQTI1Nl9JVlswXSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBTSEEyNTZfSVZbMV0gfCAwOwogICAgICAgICAgdGhpcy5DID0gU0hBMjU2X0lWWzJdIHwgMDsKICAgICAgICAgIHRoaXMuRCA9IFNIQTI1Nl9JVlszXSB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBTSEEyNTZfSVZbNF0gfCAwOwogICAgICAgICAgdGhpcy5GID0gU0hBMjU2X0lWWzVdIHwgMDsKICAgICAgICAgIHRoaXMuRyA9IFNIQTI1Nl9JVls2XSB8IDA7CiAgICAgICAgICB0aGlzLkggPSBTSEEyNTZfSVZbN10gfCAwOwogICAgICAgIH0KICAgICAgICBnZXQoKSB7CiAgICAgICAgICBjb25zdCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICByZXR1cm4gW0EsIEIsIEMsIEQsIEUsIEYsIEcsIEhdOwogICAgICAgIH0KICAgICAgICAvLyBwcmV0dGllci1pZ25vcmUKICAgICAgICBzZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCkgewogICAgICAgICAgdGhpcy5BID0gQSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBCIHwgMDsKICAgICAgICAgIHRoaXMuQyA9IEMgfCAwOwogICAgICAgICAgdGhpcy5EID0gRCB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBFIHwgMDsKICAgICAgICAgIHRoaXMuRiA9IEYgfCAwOwogICAgICAgICAgdGhpcy5HID0gRyB8IDA7CiAgICAgICAgICB0aGlzLkggPSBIIHwgMDsKICAgICAgICB9CiAgICAgICAgcHJvY2Vzcyh2aWV3LCBvZmZzZXQpIHsKICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMTY7IGkrKywgb2Zmc2V0ICs9IDQpCiAgICAgICAgICAgIFNIQTI1Nl9XW2ldID0gdmlldy5nZXRVaW50MzIob2Zmc2V0LCBmYWxzZSk7CiAgICAgICAgICBmb3IgKGxldCBpID0gMTY7IGkgPCA2NDsgaSsrKSB7CiAgICAgICAgICAgIGNvbnN0IFcxNSA9IFNIQTI1Nl9XW2kgLSAxNV07CiAgICAgICAgICAgIGNvbnN0IFcyID0gU0hBMjU2X1dbaSAtIDJdOwogICAgICAgICAgICBjb25zdCBzMCA9IHJvdHIoVzE1LCA3KSBeIHJvdHIoVzE1LCAxOCkgXiBXMTUgPj4+IDM7CiAgICAgICAgICAgIGNvbnN0IHMxID0gcm90cihXMiwgMTcpIF4gcm90cihXMiwgMTkpIF4gVzIgPj4+IDEwOwogICAgICAgICAgICBTSEEyNTZfV1tpXSA9IHMxICsgU0hBMjU2X1dbaSAtIDddICsgczAgKyBTSEEyNTZfV1tpIC0gMTZdIHwgMDsKICAgICAgICAgIH0KICAgICAgICAgIGxldCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDY0OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc2lnbWExID0gcm90cihFLCA2KSBeIHJvdHIoRSwgMTEpIF4gcm90cihFLCAyNSk7CiAgICAgICAgICAgIGNvbnN0IFQxID0gSCArIHNpZ21hMSArIENoaShFLCBGLCBHKSArIFNIQTI1Nl9LW2ldICsgU0hBMjU2X1dbaV0gfCAwOwogICAgICAgICAgICBjb25zdCBzaWdtYTAgPSByb3RyKEEsIDIpIF4gcm90cihBLCAxMykgXiByb3RyKEEsIDIyKTsKICAgICAgICAgICAgY29uc3QgVDIgPSBzaWdtYTAgKyBNYWooQSwgQiwgQykgfCAwOwogICAgICAgICAgICBIID0gRzsKICAgICAgICAgICAgRyA9IEY7CiAgICAgICAgICAgIEYgPSBFOwogICAgICAgICAgICBFID0gRCArIFQxIHwgMDsKICAgICAgICAgICAgRCA9IEM7CiAgICAgICAgICAgIEMgPSBCOwogICAgICAgICAgICBCID0gQTsKICAgICAgICAgICAgQSA9IFQxICsgVDIgfCAwOwogICAgICAgICAgfQogICAgICAgICAgQSA9IEEgKyB0aGlzLkEgfCAwOwogICAgICAgICAgQiA9IEIgKyB0aGlzLkIgfCAwOwogICAgICAgICAgQyA9IEMgKyB0aGlzLkMgfCAwOwogICAgICAgICAgRCA9IEQgKyB0aGlzLkQgfCAwOwogICAgICAgICAgRSA9IEUgKyB0aGlzLkUgfCAwOwogICAgICAgICAgRiA9IEYgKyB0aGlzLkYgfCAwOwogICAgICAgICAgRyA9IEcgKyB0aGlzLkcgfCAwOwogICAgICAgICAgSCA9IEggKyB0aGlzLkggfCAwOwogICAgICAgICAgdGhpcy5zZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCk7CiAgICAgICAgfQogICAgICAgIHJvdW5kQ2xlYW4oKSB7CiAgICAgICAgICBTSEEyNTZfVy5maWxsKDApOwogICAgICAgIH0KICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgdGhpcy5zZXQoMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCk7CiAgICAgICAgICB0aGlzLmJ1ZmZlci5maWxsKDApOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2hhMjU2ID0gLyogQF9fUFVSRV9fICovIHdyYXBDb25zdHJ1Y3RvcigoKSA9PiBuZXcgU0hBMjU2KCkpOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2hhc2hlc0AxLjUuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2hhc2hlcy9lc20vaG1hYy5qcwogIHZhciBITUFDLCBobWFjOwogIHZhciBpbml0X2htYWMgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStoYXNoZXNAMS41LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9oYXNoZXMvZXNtL2htYWMuanMiKCkgewogICAgICBpbml0X2Fzc2VydCgpOwogICAgICBpbml0X3V0aWxzMigpOwogICAgICBITUFDID0gY2xhc3MgZXh0ZW5kcyBIYXNoIHsKICAgICAgICBjb25zdHJ1Y3RvcihoYXNoMywgX2tleSkgewogICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSBmYWxzZTsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICBoYXNoKGhhc2gzKTsKICAgICAgICAgIGNvbnN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2gudXBkYXRlKGJ1Zik7CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIGJ5dGVzKG91dCwgdGhpcy5vdXRwdXRMZW4pOwogICAgICAgICAgdGhpcy5maW5pc2hlZCA9IHRydWU7CiAgICAgICAgICB0aGlzLmlIYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMub0hhc2gudXBkYXRlKG91dCk7CiAgICAgICAgICB0aGlzLm9IYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMuZGVzdHJveSgpOwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICBjb25zdCBvdXQgPSBuZXcgVWludDhBcnJheSh0aGlzLm9IYXNoLm91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHJldHVybiBvdXQ7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIHRvIHx8ICh0byA9IE9iamVjdC5jcmVhdGUoT2JqZWN0LmdldFByb3RvdHlwZU9mKHRoaXMpLCB7fSkpOwogICAgICAgICAgY29uc3QgeyBvSGFzaCwgaUhhc2gsIGZpbmlzaGVkLCBkZXN0cm95ZWQsIGJsb2NrTGVuLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0byA9IHRvOwogICAgICAgICAgdG8uZmluaXNoZWQgPSBmaW5pc2hlZDsKICAgICAgICAgIHRvLmRlc3Ryb3llZCA9IGRlc3Ryb3llZDsKICAgICAgICAgIHRvLmJsb2NrTGVuID0gYmxvY2tMZW47CiAgICAgICAgICB0by5vdXRwdXRMZW4gPSBvdXRwdXRMZW47CiAgICAgICAgICB0by5vSGFzaCA9IG9IYXNoLl9jbG9uZUludG8odG8ub0hhc2gpOwogICAgICAgICAgdG8u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KICAgICAgICBpZiAoRnAyLmVxbChiLCBGcDIuWkVSTykpCiAgICAgICAgICByZXR1cm4gRnAyLlpFUk87CiAgICAgICAgbGV0IG0gPSAxOwogICAgICAgIGZvciAobGV0IHQyID0gRnAyLnNxcihiKTsgbSA8IHI7IG0rKykgewogICAgICAgICAgaWYgKEZwMi5lcWwodDIsIEZwMi5PTkUpKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIHQyID0gRnAyLnNxcih0Mik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGdlID0gRnAyLnBvdyhnLCBfMW4zIDw8IEJpZ0ludChyIC0gbSAtIDEpKTsKICAgICAgICBnID0gRnAyLnNxcihnZSk7CiAgICAgICAgeCA9IEZwMi5tdWwoeCwgZ2UpOwogICAgICAgIGIgPSBGcDIubXVsKGIsIGcpOwogICAgICAgIHIgPSBtOwogICAgICB9CiAgICAgIHJldHVybiB4OwogICAgfTsKICB9CiAgZnVuY3Rpb24gRnBTcXJ0KFApIHsKICAgIGlmIChQICUgXzRuID09PSBfM24pIHsKICAgICAgY29uc3QgcDFkaXY0ID0gKFAgKyBfMW4zKSAvIF80bjsKICAgICAgcmV0dXJuIGZ1bmN0aW9uIHNxcnQzbW9kNChGcDIsIG4pIHsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5wb3cobiwgcDFkaXY0KTsKICAgICAgICBpZiAoIUZwMi5lcWwoRnAyLnNxcihyb290MiksIG4pKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgZmluZCBzcXVhcmUgcm9vdCIpOwogICAgICAgIHJldHVybiByb290MjsKICAgICAgfTsKICAgIH0KICAgIGlmIChQICUgXzhuID09PSBfNW4pIHsKICAgICAgY29uc3QgYzEgPSAoUCAtIF81bikgLyBfOG47CiAgICAgIHJldHVybiBmdW5jdGlvbiBzcXJ0NW1vZDgoRnAyLCBuKSB7CiAgICAgICAgY29uc3QgbjIgPSBGcDIubXVsKG4sIF8ybjMpOwogICAgICAgIGNvbnN0IHYgPSBGcDIucG93KG4yLCBjMSk7CiAgICAgICAgY29uc3QgbnYgPSBGcDIubXVsKG4sIHYpOwogICAgICAgIGNvbnN0IGkgPSBGcDIubXVsKEZwMi5tdWwobnYsIF8ybjMpLCB2KTsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5tdWwobnYsIEZwMi5zdWIoaSwgRnAyLk9ORSkpOwogICAgICAgIGlmICghRnAyLmVxbChGcDIuc3FyKHJvb3QyKSwgbikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgICAgcmV0dXJuIHJvb3QyOwogICAgICB9OwogICAgfQogICAgaWYgKFAgJSBfMTZuID09PSBfOW4pIHsKICAgIH0KICAgIHJldHVybiB0b25lbGxpU2hhbmtzKFApOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZUZpZWxkKGZpZWxkKSB7CiAgICBjb25zdCBpbml0aWFsID0gewogICAgICBPUkRFUjogImJpZ2ludCIsCiAgICAgIE1BU0s6ICJiaWdpbnQiLAogICAgICBCWVRFUzogImlzU2FmZUludGVnZXIiLAogICAgICBCSVRTOiAiaXNTYWZlSW50ZWdlciIKICAgIH07CiAgICBjb25zdCBvcHRzID0gRklFTERfRklFTERTLnJlZHVjZSgobWFwLCB2YWwpID0+IHsKICAgICAgbWFwW3ZhbF0gPSAiZnVuY3Rpb24iOwogICAgICByZXR1cm4gbWFwOwogICAgfSwgaW5pdGlhbCk7CiAgICByZXR1cm4gdmFsaWRhdGVPYmplY3QoZmllbGQsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBGcFBvdyhmMiwgbnVtMiwgcG93ZXIpIHsKICAgIGlmIChwb3dlciA8IF8wbjMpCiAgICAgIHRocm93IG5ldyBFcnJvcigiRXhwZWN0ZWQgcG93ZXIgPiAwIik7CiAgICBpZiAocG93ZXIgPT09IF8wbjMpCiAgICAgIHJldHVybiBmMi5PTkU7CiAgICBpZiAocG93ZXIgPT09IF8xbjMpCiAgICAgIHJldHVybiBudW0yOwogICAgbGV0IHAgPSBmMi5PTkU7CiAgICBsZXQgZCA9IG51bTI7CiAgICB3aGlsZSAocG93ZXIgPiBfMG4zKSB7CiAgICAgIGlmIChwb3dlciAmIF8xbjMpCiAgICAgICAgcCA9IGYyLm11bChwLCBkKTsKICAgICAgZCA9IGYyLnNxcihkKTsKICAgICAgcG93ZXIgPj49IF8xbjM7CiAgICB9CiAgICByZXR1cm4gcDsKICB9CiAgZnVuY3Rpb24gRnBJbnZlcnRCYXRjaChmMiwgbnVtcykgewogICAgY29uc3QgdG1wID0gbmV3IEFycmF5KG51bXMubGVuZ3RoKTsKICAgIGNvbnN0IGxhc3RNdWx0aXBsaWVkID0gbnVtcy5yZWR1Y2UoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGFjYzsKICAgICAgcmV0dXJuIGYyLm11bChhY2MsIG51bTIpOwogICAgfSwgZjIuT05FKTsKICAgIGNvbnN0IGludmVydGVkID0gZjIuaW52KGxhc3RNdWx0aXBsaWVkKTsKICAgIG51bXMucmVkdWNlUmlnaHQoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGYyLm11bChhY2MsIHRtcFtpXSk7CiAgICAgIHJldHVybiBmMi5tdWwoYWNjLCBudW0yKTsKICAgIH0sIGludmVydGVkKTsKICAgIHJldHVybiB0bXA7CiAgfQogIGZ1bmN0aW9uIG5MZW5ndGgobiwgbkJpdExlbmd0aCkgewogICAgY29uc3QgX25CaXRMZW5ndGggPSBuQml0TGVuZ3RoICE9PSB2b2lkIDAgPyBuQml0TGVuZ3RoIDogbi50b1N0cmluZygyKS5sZW5ndGg7CiAgICBjb25zdCBuQnl0ZUxlbmd0aCA9IE1hdGguY2VpbChfb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4zLAogICAgICBpc09kZDogKG51bTIpID0+IChudW0yICYgXzFuMykgPT09IF8xbjMsCiAgICAgIG5lZzogKG51bTIpID0+IG1vZCgtbnVtMiwgT1JERVIpLAogICAgICBlcWw6IChsaHMsIHJocykgPT4gbGhzID09PSByaHMsCiAgICAgIHNxcjogKG51bTIpID0+IG1vZChudW0yICogbnVtMiwgT1JERVIpLAogICAgICBhZGQ6IChsaHMsIHJocykgPT4gbW9kKGxocyArIHJocywgT1JERVIpLAogICAgICBzdWI6IChsaHMsIHJocykgPT4gbW9kKGxocyAtIHJocywgT1JERVIpLAogICAgICBtdWw6IChsaHMsIHJocykgPT4gbW9kKGxocyAqIHJocywgT1JERVIpLAogICAgICBwb3c6IChudW0yLCBwb3dlcikgPT4gRnBQb3coZjIsIG51bTIsIHBvd2VyKSwKICAgICAgZGl2OiAobGhzLCByaHMpID0+IG1vZChsaHMgKiBpbnZlcnQocmhzLCBPUkRFUiksIE9SREVSKSwKICAgICAgLy8gU2FtZSBhcyBhYm92ZSwgYnV0IGRvZXNuJ3Qgbm9ybWFsaXplCiAgICAgIHNxck46IChudW0yKSA9PiBudW0yICogbnVtMiwKICAgICAgYWRkTjogKGxocywgcmhzKSA9PiBsaHMgKyByaHMsCiAgICAgIHN1Yk46IChsaHMsIHJocykgPT4gbGhzIC0gcmhzLAogICAgICBtdWxOOiAobGhzLCByaHMpID0+IGxocyAqIHJocywKICAgICAgaW52OiAobnVtMikgPT4gaW52ZXJ0KG51bTIsIE9SREVSKSwKICAgICAgc3FydDogcmVkZWYuc3FydCB8fCAoKG4pID0+IHNxcnRQKGYyLCBuKSksCiAgICAgIGludmVydEJhdGNoOiAobHN0KSA9PiBGcEludmVydEJhdGNoKGYyLCBsc3QpLAogICAgICAvLyBUT0RPOiBkbyB3ZSByZWFsbHkgbmVlZCBjb25zdGFudCBjbW92PwogICAgICAvLyBXZSBkb24ndCBoYXZlIGNvbnN0LXRpbWUgYmlnaW50cyBhbnl3YXksIHNvIHByb2JhYm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bnQoMyk7CiAgICAgIF80biA9IEJpZ0ludCg0KTsKICAgICAgXzVuID0gQmlnSW50KDUpOwogICAgICBfOG4gPSBCaWdJbnQoOCk7CiAgICAgIF85biA9IEJpZ0ludCg5KTsKICAgICAgXzE2biA9IEJpZ0ludCgxNik7CiAgICAgIEZJRUxEX0ZJRUxEUyA9IFsKICAgICAgICAiY3JlYXRlIiwKICAgICAgICAiaXNWYWxpZCIsCiAgICAgICAgImlzMCIsCiAgICAgICAgIm5lZyIsCiAgICAgICAgImludiIsCiAgICAgICAgInNxcnQiLAogICAgICAgICJzcXIiLAogICAgICAgICJlcWwiLAogICAgICAgICJhZGQiLAogICAgICAgICJzdWIiLAogICAgICAgICJtdWwiLAogICAgICAgICJwb3ciLAogICAgICAgICJkaXYiLAogICAgICAgICJhZGROIiwKICAgICAgICAic3ViTiIsCiAgICAgICAgIm11bE4iLAogICAgICAgICJzcXJOIgogICAgICBdOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2N1cnZlc0AxLjYuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2N1cnZlcy9lc20vYWJzdHJhY3QvY3VydmUuanMKICBmdW5jdGlvbiB3TkFGKGMsIGJpdHMpIHsKICAgIGNvbnN0IGNvbnN0VGltZU5lZ2F0ZSA9IChjb25kaXRpb24sIGl0ZW0pID0+IHsKICAgICAgY29uc3QgbmVnID0gaXRlbS5uZWdhdGUoKTsKICAgICAgcmV0dXJuIGNvbmRpdGlvbiA/IG5lZyA6IGl0ZW07CiAgICB9OwogICAgY29uc3QgdmFsaWRhdGVXID0gKFcpID0+IHsKICAgICAgaWYgKCFOdW1iZXIuaXNTYWZlSW50ZWdlcihXKSB8fCBXIDw9IDAgfHwgVyA+IGJpdHMpCiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBXcm9uZyB3aW5kb3cgc2l6ZT0ke1d9LCBzaG91bGQgYmUgWzEuLiR7Yml0c31dYCk7CiAgICB9OwogICAgY29uc3Qgb3B0cyA9IChXKSA9PiB7CiAgICAgIHZhbGlkYXRlVyhXKTsKICAgICAgY29uc3Qgd2luZG93cyA9IE1hdGguY2VpbChiaXRzIC8gVykgKyAxOwogICAgICBjb25zdCB3aW5kb3dTaXplID0gMiAqKiAoVyAtIDEpOwogICAgICByZXR1cm4geyB3aW5kb3dzLCB3aW5kb3dTaXplIH07CiAgICB9OwogICAgcmV0dXJuIHsKICAgICAgY29uc3RUaW1lTmVnYXRlLAogICAgICAvLyBub24tY29uc3QgdGltZSBtdWx0aXBsaWNhdGlvbiBsYWRkZXIKICAgICAgdW5zYWZlTGFkZGVyKGVsbSwgbikgewogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBkID0gZWxtOwogICAgICAgIHdoaWxlIChuID4gXzBuNCkgewogICAgICAgICAgaWYgKG4gJiBfMW40KQogICAgICAgICAgICBwID0gcC5hZGQoZCk7CiAgICAgICAgICBkID0gZC5kb3VibGUoKTsKICAgICAgICAgIG4gPj49IF8xbjQ7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwOwogICAgICB9LAogICAgICAvKioKICAgICAgICogQ3JlYXRlcyBhIHdOQUYgcHJlY29tcHV0YXRpb24gd2luZG93LiBVc2VkIGZvciBjYWNoaW5nLgogICAgICAgKiBEZWZhdWx0IHdpbmRvdyBzaXplIGlzIHNldCBieSBgdXRpbHMucHJlY29tcHV0ZSgpYCBhbmQgaXMgZXF1YWwgdG8gOC4KICAgICAgICogTnVtYmVyIG9mIHByZWNvbXB1dGVkIHBvaW50cyBkZXBlbmRzIG9uIHRoZSBjdXJ2ZSBzaXplOgogICAgICAgKiAyXijwnZGK4oiSMSkgKiAoTWF0aC5jZWlsKPCdkZsgLyDwnZGKKSArIDEpLCB3aGVyZToKICAgICAgICogLSDwnZGKIGlzIHRoZSB3aW5kb3cgc2l6ZQogICAgICAgKiAtIPCdkZsgaXMgdGhlIGJpdGxlbmd0aCBvZiB0aGUgY3VydmUgb3JkZXIuCiAgICAgICAqIEZvciBhIDI1Ni1iaXQgY3VydmUgYW5kIHdpbmRvdyBzaXplIDgsIHRoZSBudW1iZXIgb2YgcHJlY29tcHV0ZWQgcG9pbnRzIGlzIDEyOCAqIDMzID0gNDIyNC4KICAgICAgICogQHJldHVybnMgcHJlY29tcHV0ZWQgcG9pbnQgdGFibGVzIGZsYXR0ZW5lZCB0byBhIHNpbmdsZSBhcnJheQogICAgICAgKi8KICAgICAgcHJlY29tcHV0ZVdpbmRvdyhlbG0sIFcpIHsKICAgICAgICBjb25zdCB7IHdpbmRvd3MsIHdpbmRvd1NpemUgfSA9IG9wdHMoVyk7CiAgICAgICAgY29uc3QgcG9pbnRzID0gW107CiAgICAgICAgbGV0IHAgPSBlbG07CiAgICAgICAgbGV0IGJhc2UyID0gcDsKICAgICAgICBmb3IgKGxldCB3aW5kb3cyID0gMDsgd2luZG93MiA8IHdpbmRvd3M7IHdpbmRvdzIrKykgewogICAgICAgICAgYmFzZTIgPSBwOwogICAgICAgICAgcG9pbnRzLnB1c2goYmFzZTIpOwogICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCB3aW5kb3dTaXplOyBpKyspIHsKICAgICAgICAgICAgYmFzZTIgPSBiYXNlMi5hZGQocCk7CiAgICAgICAgICAgIHBvaW50cy5wdXNoKGJhc2UyKTsKICAgICAgICAgIH0KICAgICAgICAgIHAgPSBiYXNlMi5kb3VibGUoKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBvaW50czsKICAgICAgfSwKICAgICAgLyoqCiAgICAgICAqIEltcGxlbWVudHMgZWMgbXVsdGlwbGljYXRpb24gdXNpbmcgcHJlY29tcHV0ZWQgdGFibGVzIGFuZCB3LWFyeSBub24tYWRqYWNlbnQgZm9ybS4KICAgICAgICogQHBhcmFtIFcgd2luZG93IHNpemUKICAgICAgICogQHBhcmFtIHByZWNvbXB1dGVzIHByZWNvbXB1dGVkIHRhYmxlcwogICAgICAgKiBAcGFyYW0gbiBzY2FsYXIgKHdlIGRvbid0IGNoZWNrIGhlcmUsIGJ1dCBzaG91bGQgYmUgbGVzcyB0aGFuIGN1cnZlIG9yZGVyKQogICAgICAgKiBAcmV0dXJucyByZWFsIGFuZCBmYWtlIChmb3IgY29uc3QtdGltZSkgcG9pbnRzCiAgICAgICAqLwogICAgICB3TkFGKFcsIHByZWNvbXB1dGVzLCBuKSB7CiAgICAgICAgY29uc3QgeyB3aW5kb3dzLCB3aW5kb3dTaXplIH0gPSBvcHRzKFcpOwogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBmMiA9IGMuQkFTRTsKICAgICAgICBjb25zdCBtYXNrID0gQmlnSW50KDIgKiogVyAtIDEpOwogICAgICAgIGNvbnN0IG1heE51bWJlciA9IDIgKiogVzsKICAgICAgICBjb25zdCBzaGlmdEJ5ID0gQmlnSW50KFcpOwogICAgICAgIGZvciAobGV0IHdpbmRvdzIgPSAwOyB3aW5kb3cyIDwgd2luZG93czsgd2luZG93MisrKSB7CiAgICAgICAgICBjb25zdCBvZmZzZXQgPSB3aW5kb3cyICogd2luZG93U2l6ZTsKICAgICAgICAgIGxldCB3Yml0cyA9IE51bWJlcihuICYgbWFzayk7CiAgICAgICAgICBuID4+PSBzaGlmdEJ5OwogICAgICAgICAgaWYgKHdiaXRzID4gd2luZG93U2l6ZSkgewogICAgICAgICAgICB3Yml0cyAtPSBtYXhOdW1iZXI7CiAgICAgICAgICAgIG4gKz0gXzFuNDsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG9mZnNldDEgPSBvZmZzZXQ7CiAgICAgICAgICBjb25zdCBvZmZzZXQyID0gb2Zmc2V0ICsgTWF0aC5hYnMod2JpdHMpIC0gMTsKICAgICAgICAgIGNvbnN0IGNvbmQxID0gd2luZG93MiAlIDIgIT09IDA7CiAgICAgICAgICBjb25zdCBjb25kMiA9IHdiaXRzIDwgMDsKICAgICAgICAgIGlmICh3Yml0cyA9PT0gMCkgewogICAgICAgICAgICBmMiA9IGYyLmFkZChjb25zdFRpbWVOZWdhdGUoY29uZDEsIHByZWNvbXB1dGVzW29mZnNldDFdKSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwID0gcC5hZGQoY29uc3RUaW1lTmVnYXRlKGNvbmQyLCBwcmVjb21wdXRlc1tvZmZzZXQyXSkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4geyBwLCBmOiBmMiB9OwogICAgICB9LAogICAgICB3TkFGQ2FjaGVkKFAsIG4sIHRyYW5zZm9ybSkgewogICAgICAgIGNvbnN0IFcgPSBwb2ludFdpbmRvd1NpemVzLmdldChQKSB8fCAxOwogICAgICAgIGxldCBjb21wID0gcG9pbnRQcmVjb21wdXRlcy5nZXQoUCk7CiAgICAgICAgaWYgKCFjb21wKSB7CiAgICAgICAgICBjb21wID0gdGhpcy5wcmVjb21wdXRlV2luZG93KFAsIFcpOwogICAgICAgICAgaWYgKFcgIT09IDEpCiAgICAgICAgICAgIHBvaW50UHJlY29tcHV0ZXMuc2V0KFAsIHRyYW5zZm9ybShjb21wKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLndOQUYoVywgY29tcCwgbik7CiAgICAgIH0sCiAgICAgIC8vIFdlIGNhbGN1bGF0ZSBwcmVjb21wdXRlcyBmb3IgZWxsaXB0aWMgY3VydmUgcG9pbnQgbXVsdGlwbGljYXRpb24KICAgICAgLy8gdXNpbmcgd2luZG93ZWQgbWV0aG9kLiBUaGlzIHNwZWNpZmllcyB3aW5kb3cgc2l6ZSBhbmQKICAgICAgLy8gc3RvcmVzIHByZWNvbXB1dGVkIHZhbHVlcy4gVXN1YWxseSBvbmx5IGJhc2UgcG9pbnQgd291bGQgYmUgcHJlY29tcHV0ZWQuCiAgICAgIHNldFdpbmRvd1NpemUoUCwgVykgewogICAgICAgIHZhbGlkYXRlVyhXKTsKICAgICAgICBwb2ludFdpbmRvd1NpemVzLnNldChQLCBXKTsKICAgICAgICBwb2ludFByZWNvbXB1dGVzL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ewogICAgICAgIHRocm93IG5ldyBFcnJvcihgcHJpdmF0ZSBrZXkgbXVzdCBiZSAke25CeXRlTGVuZ3RofSBieXRlcywgaGV4IG9yIGJpZ2ludCwgbm90ICR7dHlwZW9mIGtleX1gKTsKICAgICAgfQogICAgICBpZiAod3JhcFByaXZhdGVLZXkpCiAgICAgICAgbnVtMiA9IG1vZChudW0yLCBOKTsKICAgICAgYUluUmFuZ2UoInByaXZhdGUga2V5IiwgbnVtMiwgXzFuNSwgTik7CiAgICAgIHJldHVybiBudW0yOwogICAgfQogICAgZnVuY3Rpb24gYXNzZXJ0UHJqUG9pbnQob3RoZXIpIHsKICAgICAgaWYgKCEob3RoZXIgaW5zdGFuY2VvZiBQb2ludDIpKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiUHJvamVjdGl2ZVBvaW50IGV4cGVjdGVkIik7CiAgICB9CiAgICBjb25zdCB0b0FmZmluZU1lbW8gPSBtZW1vaXplZCgocCwgaXopID0+IHsKICAgICAgY29uc3QgeyBweDogeCwgcHk6IHksIHB6OiB6IH0gPSBwOwogICAgICBpZiAoRnAyLmVxbCh6LCBGcDIuT05FKSkKICAgICAgICByZXR1cm4geyB4LCB5IH07CiAgICAgIGNvbnN0IGlzMCA9IHAuaXMwKCk7CiAgICAgIGlmIChpeiA9PSBudWxsKQogICAgICAgIGl6ID0gaXMwID8gRnAyLk9ORSA6IEZwMi5pbnYoeik7CiAgICAgIGNvbnN0IGF4ID0gRnAyLm11bCh4LCBpeik7CiAgICAgIGNvbnN0IGF5ID0gRnAyLm11bCh5LCBpeik7CiAgICAgIGNvbnN0IHp6ID0gRnAyLm11bCh6LCBpeik7CiAgICAgIGlmIChpczApCiAgICAgICAgcmV0dXJuIHsgeDogRnAyLlpFUk8sIHk6IEZwMi5aRVJPIH07CiAgICAgIGlmICghRnAyLmVxbCh6eiwgRnAyLk9ORSkpCiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJpbnZaIHdhcyBpbnZhbGlkIik7CiAgICA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KCJ4IHJlcXVpcmVkIik7CiAgICAgICAgaWYgKHB5ID09IG51bGwgfHwgIUZwMi5pc1ZhbGlkKHB5KSkKICAgICAgICAgIHRocm93IG5ldyBFcnJvcigieSByZXF1aXJlZCIpOwogICAgICAgIGlmIChweiA9PSBudWxsIHx8ICFGcDIuaXNWYWxpZChweikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInogcmVxdWlyZWQiKTsKICAgICAgICBPYmplY3QuZnJlZXplKHRoaXMpOwogICAgICB9CiAgICAgIC8vIERvZXMgbm90IHZhbGlkYXRlIGlmIHRoZSBwb2ludCBpcyBvbi1jdXJ2ZS4KICAgICAgLy8gVXNlIGZyb21IZXggaW5zdGVhZCwgb3IgY2FsbCBhc3NlcnRWYWxpZGl0eSgpIGxhdGVyLgogICAgICBzdGF0aWMgZnJvbUFmZmluZShwKSB7CiAgICAgICAgY29uc3QgeyB4LCB5IH0gPSBwIHx8IHt9OwogICAgICAgIGlmICghcCB8fCAhRnAyLmlzVmFsaWQoeCkgfHwgIUZwMi5pc1ZhbGlkKHkpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJpbnZhbGlkIGFmZmluZSBwb2ludCIpOwogICAgICAgIGlmIChwIGluc3RhbmNlb2YgUG9pbnQyKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJwcm9qZWN0aXZlIHBvaW50IG5vdCBhbGxvd2VkIik7CiAgICAgICAgY29uc3QgaXMwID0gKGkpID0+IEZwMi5lcWwoaSwgRnAyLlpFUk8pOwogICAgICAgIGlmIChpczAoeCkgJiYgaXMwKHkpKQogICAgICAgICAgcmV0dXJuIFBvaW50Mi5aRVJPOwogICAgICAgIHJldHVybiBuZXcgUG9pbnQyKHgsIHksIEZwMi5PTkUpOwogICAgICB9CiAgICAgIGdldCB4KCkgewogICAgICAgIHJldHVybiB0aGlzLnRvQWZmaW5lKCkueDsKICAgICAgfQogICAgICBnZXQgeSgpIHsKICAgICAgICByZXR1cm4gdGhpcy50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LlpFUk87CiAgICAgICAgbGV0IHQwID0gRnAyLm11bChYMSwgWDEpOwogICAgICAgIGxldCB0MSA9IEZwMi5tdWwoWTEsIFkxKTsKICAgICAgICBsZXQgdDIgPSBGcDIubXVsKFoxLCBaMSk7CiAgICAgICAgbGV0IHQzID0gRnAyLm11bChYMSwgWTEpOwogICAgICAgIHQzID0gRnAyLmFkZCh0MywgdDMpOwogICAgICAgIFozID0gRnAyLm11bChYMSwgWjEpOwogICAgICAgIFozID0gRnAyLmFkZChaMywgWjMpOwogICAgICAgIFgzID0gRnAyLm11bChhLCBaMyk7CiAgICAgICAgWTMgPSBGcDIubXVsKGIzMiwgdDIpOwogICAgICAgIFkzID0gRnAyLmFkZChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLnN1Yih0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLmFkZCh0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLm11bChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLm11bCh0MywgWDMpOwogICAgICAgIFozID0gRnAyLm11bChiMzIsIFozKTsKICAgICAgICB0MiA9IEZwMi5tdWwoYSwgdDIpOwogICAgICAgIHQzID0gRnAyLnN1Yih0MCwgdDIpOwogICAgICAgIHQzID0gRnAyLm11bChhLCB0Myk7CiAgICAgICAgdDMgPSBGcDIuYWRkKHQzLCBaMyk7CiAgICAgICAgWjMgPSBGcDIuYWRkKHQwLCB0MCk7CiAgICAgICAgdDAgPSBGcDIuYWRkKFozLCB0MCk7CiAgICAgICAgdDAgPSBGcDIuYWRkKHQwLCB0Mik7CiAgICAgICAgdDAgPSBGcDIubXVsKHQwLCB0Myk7CiAgICAgICAgWTMgPSBGcDIuYWRkKFkzLCB0MCk7CiAgICAgICAgdDIgPSBGcDIubXVsKFkxLCBaMSk7CiAgICAgICAgdDIgPSBGcDIuYWRkKHQyLCB0Mik7CiAgICAgICAgdDAgPSBGcDIubXVsKHQyLCB0Myk7CiAgICAgICAgWDMgPSBGcDIuc3ViKFgzLCB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ICAgICB0MCA9IEZwMi5tdWwodDEsIHQ0KTsKICAgICAgICBZMyA9IEZwMi5hZGQoWTMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDUsIHQ0KTsKICAgICAgICBYMyA9IEZwMi5tdWwodDMsIFgzKTsKICAgICAgICBYMyA9IEZwMi5zdWIoWDMsIHQwKTsKICAgICAgICB0MCA9IEZwMi5tdWwodDMsIHQxKTsKICAgICAgICBaMyA9IEZwMi5tdWwodDUsIFozKTsKICAgICAgICBaMyA9IEZwMi5hZGQoWjMsIHQwKTsKICAgICAgICByZXR1cm4gbmV3IFBvaW50MihYMywgWTMsIFozKTsKICAgICAgfQogICAgICBzdWJ0cmFjdChvdGhlcikgewogICAgICAgIHJldHVybiB0aGlzLmFkZChvdGhlci5uZWdhdGUoKSk7CiAgICAgIH0KICAgICAgaXMwKCkgewogICAgICAgIHJldHVybiB0aGlzLmVxdWFscyhQb2ludDIuWkVSTyk7CiAgICAgIH0KICAgICAgd05BRihuKSB7CiAgICAgICAgcmV0dXJuIHduYWYud05BRkNhY2hlZCh0aGlzLCBuLCBQb2ludDIubm9ybWFsaXplWik7CiAgICAgIH0KICAgICAgLyoqCiAgICAgICAqIE5vbi1jb25zdGFudC10aW1lIG11bHRpcGxpY2F0aW9uLiBVc2VzIGRvdWJsZS1hbmQtYWRkIGFsZ29yaXRobS4KICAgICAgICogSXQncyBmYXN0ZXIsIGJ1dCBzaG91bGQgb25seSBiZSB1c2VkIHdoZW4geW91IGRvbid0IGNhcmUgYWJvdXQKICAgICAgICogYW4gZXhwb3NlZCBwcml2YXRlIGtleSBlLmcuIHNpZyB2ZXJpZmljYXRpb24sIHdoaWNoIHdvcmtzIG92ZXIgKnB1YmxpYyoga2V5cy4KICAgICAgICovCiAgICAgIG11bHRpcGx5VW5zYWZlKHNjKSB7CiAgICAgICAgYUluUmFuZ2UoInNjYWxhciIsIHNjLCBfMG41LCBDVVJWRS5uKTsKICAgICAgICBjb25zdCBJID0gUG9pbnQyLlpFUk87CiAgICAgICAgaWYgKHNjID09PSBfMG41KQogICAgICAgICAgcmV0dXJuIEk7CiAgICAgICAgaWYgKHNjID09PSBfMW41KQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgY29uc3QgeyBlbmRvIH0gPSBDVVJWRTsKICAgICAgICBpZiAoIWVuZG8pCiAgICAgICAgICByZXR1cm4gd25hZi51bnNhZmVMYWRkZXIodGhpcywgc2MpOwogICAgICAgIGxldCB7IGsxbmVnLCBrMSwgazJuZWcsIGsyIH0gPSBlbmRvLnNwbGl0U2NhbGFyKHNjKTsKICAgICAgICBsZXQgazFwID0gSTsKICAgICAgICBsZXQgazJwID0gSTsKICAgICAgICBsZXQgZCA9IHRoaXM7CiAgICAgICAgd2hpbGUgKGsxID4gXzBuNSB8fCBrMiA+IF8wbjUpIHsKICAgICAgICAgIGlmIChrMSAmIF8xbjUpCiAgICAgICAgICAgIGsxcCA9IGsxcC5hZGQoZCk7CiAgICAgICAgICBpZiAoazIgJiBfMW41KQogICAgICAgICAgICBrMnAgPSBrMnAuYWRkKGQpOwogICAgICAgICAgZCA9IGQuZG91YmxlKCk7CiAgICAgICAgICBrMSA+Pj0gXzFuNTsKICAgICAgICAgIGsyID4+PSBfMW41OwogICAgICAgIH0KICAgICAgICBpZiAoazFuZWcpCiAgICAgICAgICBrMXAgPSBrMXAubmVnYXRlKCk7CiAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgazJwID0gazJwLm5lZ2F0ZSgpOwogICAgICAgIGsycCA9IG5ldyBQb2ludDIoRnAyLm11bChrMnAucHgsIGVuZG8uYmV0YSksIGsycC5weSwgazJwLnB6KTsKICAgICAgICByZXR1cm4gazFwLmFkZChrMnApOwogICAgICB9CiAgICAgIC8qKgogICAgICAgKiBDb25zdGFudCB0aW1lIG11bHRpcGxpY2F0aW9uLgogICAgICAgKiBVc2VzIHdOQUYgbWV0aG9kLiBXaW5kb3dlZCBtZXRob2QgbWF5IGJlIDEwJSBmYXN0ZXIsCiAgICAgICAqIGJ1dCB0YWtlcyAyeCBsb25nZXIgdG8gZ2VuZXJhdGUgYW5kIGNvbnN1bWVzIDJ4IG1lbW9yeS4KICAgICAgICogVXNlcyBwcmVjb21wdXRlcyB3aGVuIGF2YWlsYWJsZS4KICAgICAgICogVXNlcyBlbmRvbW9ycGhpc20gZm9yIEtvYmxpdHogY3VydmVzLgogICAgICAgKiBAcGFyYW0gc2NhbGFyIGJ5IHdoaWNoIHRoZSBwb2ludCB3b3VsZCBiZSBtdWx0aXBsaWVkCiAgICAgICAqIEByZXR1cm5zIE5ldyBwb2ludAogICAgICAgKi8KICAgICAgbXVsdGlwbHkoc2NhbGFyKSB7CiAgICAgICAgY29uc3QgeyBlbmRvLCBuOiBOIH0gPSBDVVJWRTsKICAgICAgICBhSW5SYW5nZSgic2NhbGFyIiwgc2NhbGFyLCBfMW41LCBOKTsKICAgICAgICBsZXQgcG9pbnQsIGZha2U7CiAgICAgICAgaWYgKGVuZG8pIHsKICAgICAgICAgIGNvbnN0IHsgazFuZWcsIGsxLCBrMm5lZywgazIgfSA9IGVuZG8uc3BsaXRTY2FsYXIoc2NhbGFyKTsKICAgICAgICAgIGxldCB7IHA6IGsxcCwgZjogZjFwIH0gPSB0aGlzLndOQUYoazEpOwogICAgICAgICAgbGV0IHsgcDogazJwLCBmOiBmMnAgfSA9IHRoaXMud05BRihrMik7CiAgICAgICAgICBrMXAgPSB3bmFmLmNvbnN0VGltZU5lZ2F0ZShrMW5lZywgazFwKTsKICAgICAgICAgIGsycCA9IHduYWYuY29uc3RUaW1lTmVnYXRlKGsybmVnLCBrMnApOwogICAgICAgICAgazJwID0gbmV3IFBvaW50MihGcDIubXVsKGsycC5weCwgZW5kby5iZXRhKSwgazJwLnB5LCBrMnAucHopOwogICAgICAgICAgcG9pbnQgPSBrMXAuYWRkKGsycCk7CiAgICAgICAgICBmYWtlID0gZjFwLmFkZChmMnApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCB7IH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ogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbNF0pLCB4LCBGcDIudG9CeXRlcyhhLnkpKTsKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGZyb21CeXRlcyhieXRlczIpIHsKICAgICAgICBjb25zdCBsZW4gPSBieXRlczIubGVuZ3RoOwogICAgICAgIGNvbnN0IGhlYWQgPSBieXRlczJbMF07CiAgICAgICAgY29uc3QgdGFpbCA9IGJ5dGVzMi5zdWJhcnJheSgxKTsKICAgICAgICBpZiAobGVuID09PSBjb21wcmVzc2VkTGVuICYmIChoZWFkID09PSAyIHx8IGhlYWQgPT09IDMpKSB7CiAgICAgICAgICBjb25zdCB4ID0gYnl0ZXNUb051bWJlckJFKHRhaWwpOwogICAgICAgICAgaWYgKCFpblJhbmdlKHgsIF8xbjUsIEZwMi5PUkRFUikpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiUG9pbnQgaXMgbm90IG9uIGN1cnZlIik7CiAgICAgICAgICBjb25zdCB5MiA9IHdlaWVyc3RyYXNzRXF1YXRpb24oeCk7CiAgICAgICAgICBsZXQgeTsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHkgPSBGcDIuc3FydCh5Mik7CiAgICAgICAgICB9IGNhdGNoIChzcXJ0RXJyb3IpIHsKICAgICAgICAgICAgY29uc3Qgc3VmZml4ID0gc3FydEVycm9yIGluc3RhbmNlb2YgRXJyb3IgPyAiOiAiICsgc3FydEVycm9yLm1lc3NhZ2UgOiAiIjsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJQb2ludCBpcyBub3Qgb24gY3VydmUiICsgc3VmZml4KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGlzWU9kZCA9ICh5ICYgXzFuNSkgPT09IF8xbjU7CiAgICAgICAgICBjb25zdCBpc0hlYWRPZGQgPSAoaGVhZCAmIDEpID09PSAxOwogICAgICAgICAgaWYgKGlzSGVh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sIF8xbjUsIENVUlZFX09SREVSKTsKICAgICAgfQogICAgICBhZGRSZWNvdmVyeUJpdChyZWNvdmVyeSkgewogICAgICAgIHJldHVybiBuZXcgU2lnbmF0dXJlKHRoaXMuciwgdGhpcy5zLCByZWNvdmVyeSk7CiAgICAgIH0KICAgICAgcmVjb3ZlclB1YmxpY0tleShtc2dIYXNoKSB7CiAgICAgICAgY29uc3QgeyByLCBzLCByZWNvdmVyeTogcmVjIH0gPSB0aGlzOwogICAgICAgIGNvbnN0IGggPSBiaXRzMmludF9tb2ROKGVuc3VyZUJ5dGVzKCJtc2dIYXNoIiwgbXNnSGFzaCkpOwogICAgICAgIGlmIChyZWMgPT0gbnVsbCB8fCAhWzAsIDEsIDIsIDNdLmluY2x1ZGVzKHJlYykpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInJlY292ZXJ5IGlkIGludmFsaWQiKTsKICAgICAgICBjb25zdCByYWRqID0gcmVjID09PSAyIHx8IHJlYyA9PT0gMyA/IHIgKyBDVVJWRS5uIDogcjsKICAgICAgICBpZiAocmFkaiA+PSBGcDIuT1JERVIpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInJlY292ZXJ5IGlkIDIgb3IgMyBpbnZhbGlkIik7CiAgICAgICAgY29uc3QgcHJlZml4ID0gKHJlYyAmIDEpID09PSAwID8gIjAyIiA6ICIwMyI7CiAgICAgICAgY29uc3QgUiA9IFBvaW50Mi5mcm9tSGV4KHByZWZpeCArIG51bVRvTkJ5dGVTdHIocmFkaikpOwogICAgICAgIGNvbnN0IGlyID0gaW52TihyYWRqKTsKICAgICAgICBjb25zdCB1MSA9IG1vZE4yKC1oICogaXIpOwogICAgICAgIGNvbnN0IHUyID0gbW9kTjIocyAqIGlyKTsKICAgICAgICBjb25zdCBRID0gUG9pbnQyLkJBU0UubXVsdGlwbHlBbmRBZGRVbnNhZmUoUiwgdTEsIHUyKTsKICAgICAgICBpZiAoIVEpCiAgICAgICAgICB0aHJvdyBuZXcgR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hRW50cm9weSIsIGUpKTsKICAgICAgfQogICAgICBjb25zdCBzZWVkID0gY29uY2F0Qnl0ZXMzKC4uLnNlZWRBcmdzKTsKICAgICAgY29uc3QgbSA9IGgxaW50OwogICAgICBmdW5jdGlvbiBrMnNpZyhrQnl0ZXMpIHsKICAgICAgICBjb25zdCBrID0gYml0czJpbnQoa0J5dGVzKTsKICAgICAgICBpZiAoIWlzV2l0aGluQ3VydmVPcmRlcihrKSkKICAgICAgICAgIHJldHVybjsKICAgICAgICBjb25zdCBpayA9IGludk4oayk7CiAgICAgICAgY29uc3QgcSA9IFBvaW50Mi5CQVNFLm11bHRpcGx5KGspLnRvQWZmaW5lKCk7CiAgICAgICAgY29uc3QgciA9IG1vZE4yKHEueCk7CiAgICAgICAgaWYgKHIgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgY29uc3QgcyA9IG1vZE4yKGlrICogbW9kTjIobSArIHIgKiBkKSk7CiAgICAgICAgaWYgKHMgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgbGV0IHJlY292ZXJ5ID0gKHEueCA9PT0gciA/IDAgOiAyKSB8IE51bWJlcihxLnkgJiBfMW41KTsKICAgICAgICBsZXQgbm9ybVMgPSBzOwogICAgICAgIGlmIChsb3dTICYmIGlzQmlnZ2VyVGhhbkhhbGZPcmRlcihzKSkgewogICAgICAgICAgbm9ybVMgPSBub3JtYWxpemVTKHMpOwogICAgICAgICAgcmVjb3ZlcnkgXj0gMTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG5ldyBTaWduYXR1cmUociwgbm9ybVMsIHJlY292ZXJ5KTsKICAgICAgfQogICAgICByZXR1cm4geyBzZWVkLCBrMnNpZyB9OwogICAgfQogICAgY29uc3QgZGVmYXVsdFNpZ09wdHMgPSB7IGxvd1M6IENVUlZFLmxvd1MsIHByZWhhc2g6IGZhbHNlIH07CiAgICBjb25zdCBkZWZhdWx0VmVyT3B0cyA9IHsgbG93UzogQ1VSVk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X3NpZyA9IFNpZ25hdHVyZS5mcm9tREVSKHNnKTsKICAgICAgICAgIH0gY2F0Y2ggKGRlckVycm9yKSB7CiAgICAgICAgICAgIGlmICghKGRlckVycm9yIGluc3RhbmNlb2YgREVSLkVycikpCiAgICAgICAgICAgICAgdGhyb3cgZGVyRXJyb3I7CiAgICAgICAgICAgIF9zaWcgPSBTaWduYXR1cmUuZnJvbUNvbXBhY3Qoc2cpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNnID09PSAib2JqZWN0IiAmJiB0eXBlb2Ygc2cuciA9PT0gImJpZ2ludCIgJiYgdHlwZW9mIHNnLnMgPT09ICJiaWdpbnQiKSB7CiAgICAgICAgICBjb25zdCB7IHI6IHIyLCBzOiBzMiB9ID0gc2c7CiAgICAgICAgICBfc2lnID0gbmV3IFNpZ25hdHVyZShyMiwgczIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBBUlNFIik7CiAgICAgICAgfQogICAgICAgIFAgPSBQb2ludDIuZnJvbUhleChwdWJsaWNLZXkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChlcnJvci5tZXNzYWdlID09PSAiUEFSU0UiKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzaWduYXR1cmUgbXVzdCBiZSBTaWduYXR1cmUgaW5zdGFuY2UsIFVpbnQ4QXJyYXkgb3IgaGV4IHN0cmluZ2ApOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobG93UyAmJiBfc2lnLmhhc0hpZ2hTKCkpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAocHJlaGFzaCkKICAgICAgICBtc2dIYXNoID0gQ1VSVkUuaGFzaChtc2dIYXNoKTsKICAgICAgY29uc3QgeyByLCBzIH0gPSBfc2lnOwogICAgICBjb25zdCBoID0gYml0czJpbnRfbW9kTihtc2dIYXNoKTsKICAgICA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EZwMi5wb3coWiwgYzIpOwogICAgY29uc3QgYzcgPSBGcDIucG93KFosIChjMiArIF8xbjUpIC8gXzJuNCk7CiAgICBsZXQgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgbGV0IHR2MSA9IGM2OwogICAgICBsZXQgdHYyID0gRnAyLnBvdyh2LCBjNCk7CiAgICAgIGxldCB0djMgPSBGcDIuc3FyKHR2Mik7CiAgICAgIHR2MyA9IEZwMi5tdWwodHYzLCB2KTsKICAgICAgbGV0IHR2NSA9IEZwMi5tdWwodSwgdHYzKTsKICAgICAgdHY1ID0gRnAyLnBvdyh0djUsIGMzKTsKICAgICAgdHY1ID0gRnAyLm11bCh0djUsIHR2Mik7CiAgICAgIHR2MiA9IEZwMi5tdWwodHY1LCB2KTsKICAgICAgdHYzID0gRnAyLm11bCh0djUsIHUpOwogICAgICBsZXQgdHY0ID0gRnAyLm11bCh0djMsIHR2Mik7CiAgICAgIHR2NSA9IEZwMi5wb3codHY0LCBjNSk7CiAgICAgIGxldCBpc1FSID0gRnAyLmVxbCh0djUsIEZwMi5PTkUpOwogICAgICB0djIgPSBGcDIubXVsKHR2MywgYzcpOwogICAgICB0djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgdHYzID0gRnAyLmNtb3YodHYyLCB0djMsIGlzUVIpOwogICAgICB0djQgPSBGcDIuY21vdih0djUsIHR2NCwgaXNRUik7CiAgICAgIGZvciAobGV0IGkgPSBjMTsgaSA+IF8xbjU7IGktLSkgewogICAgICAgIGxldCB0djUyID0gaSAtIF8ybjQ7CiAgICAgICAgdHY1MiA9IF8ybjQgPDwgdHY1MiAtIF8xbjU7CiAgICAgICAgbGV0IHR2djUgPSBGcDIucG93KHR2NCwgdHY1Mik7CiAgICAgICAgY29uc3QgZTEgPSBGcDIuZXFsKHR2djUsIEZwMi5PTkUpOwogICAgICAgIHR2MiA9IEZwMi5tdWwodHYzLCB0djEpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djEpOwogICAgICAgIHR2djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgICB0djMgPSBGcDIuY21vdih0djIsIHR2MywgZTEpOwogICAgICAgIHR2NCA9IEZwMi5jbW92KHR2djUsIHR2NCwgZTEpOwogICAgICB9CiAgICAgIHJldHVybiB7IGlzVmFsaWQ6IGlzUVIsIHZhbHVlOiB0djMgfTsKICAgIH07CiAgICBpZiAoRnAyLk9SREVSICUgXzRuMiA9PT0gXzNuMikgewogICAgICBjb25zdCBjMTIgPSAoRnAyLk9SREVSIC0gXzNuMikgLyBfNG4yOwogICAgICBjb25zdCBjMjIgPSBGcDIuc3FydChGcDIubmVnKFopKTsKICAgICAgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgICBsZXQgdHYxID0gRnAyLnNxcih2KTsKICAgICAgICBjb25zdCB0djIgPSBGcDIubXVsKHUsIHYpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djIpOwogICAgICAgIGxldCB5MSA9IEZwMi5wb3codHYxLCBjMTIpOwogICAgICAgIHkxID0gRnAyLm11bCh5MSwgdHYyKTsKICAgICAgICBjb25zdCB5MiA9IEZwMi5tdWwoeTEsIGMyMik7CiAgICAgICAgY29uc3QgdHYzID0gRnAyLm11bChGcDIuc3FyKHkxKSwgdik7CiAgICAgICAgY29uc3QgaXNRUiA9IEZwMi5lcWwodHYzLCB1KTsKICAgICAgICBsZXQgeSA9IEZwMi5jbW92KHkyLCB5MSwgaXNRUik7CiAgICAgICAgcmV0dXJuIHsgaXNWYWxpZDogaXNRUiwgdmFsdWU6IHkgfTsKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBzcXJ0UmF0aW87CiAgfQogIGZ1bmN0aW9uIG1hcFRvQ3VydmVTaW1wbGVTV1UoRnAyLCBvcHRzKSB7CiAgICB2YWxpZGF0ZUZpZWxkKEZwMik7CiAgICBpZiAoIUZwMi5pc1ZhbGlkKG9wdHMuQSkgfHwgIUZwMi5pc1ZhbGlk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TsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIEJhc2ljIGJ1aWxkaW5nIGJsb2NrIGlzIFRMViAoVGFnLUxlbmd0aC1WYWx1ZSkKICAgICAgICBfdGx2OiB7CiAgICAgICAgICBlbmNvZGU6ICh0YWcsIGRhdGEpID0+IHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgaWYgKHRhZyA8IDAgfHwgdGFnID4gMjU2KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZW5jb2RlOiB3cm9uZyB0YWciKTsKICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoICYgMSkKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogdW5wYWRkZWQgZGF0YSIpOwogICAgICAgICAgICBjb25zdCBkYXRhTGVuID0gZGF0YS5sZW5ndGggLyAyOwogICAgICAgICAgICBjb25zdCBsZW4gPSBudW1iZXJUb0hleFVucGFkZGVkKGRhdGFMZW4pOwogICAgICAgICAgICBpZiAobGVuLmxlbmd0aCAvIDIgJiAxMjgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5lbmNvZGU6IGxvbmcgZm9ybSBsZW5ndGggdG9vIGJpZyIpOwogICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBkYXRhTGVuID4gMTI3ID8gbnVtYmVyVG9IZXhVbnBhZGRlZChsZW4ubGVuZ3RoIC8gMiB8IDEyOCkgOiAiIjsKICAgICAgICAgICAgcmV0dXJuIGAke251bWJlclRvSGV4VW5wYWRkZWQodGFnKX0ke2xlbkxlbn0ke2xlbn0ke2RhdGF9YDsKICAgICAgICAgIH0sCiAgICAgICAgICAvLyB2IC0gdmFsdWUsIGwgLSBsZWZ0IGJ5dGVzICh1bnBhcnNlZCkKICAgICAgICAgIGRlY29kZSh0YWcsIGRhdGEpIHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgIGlmICh0YWcgPCAwIHx8IHRhZyA+IDI1NikKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogd3JvbmcgdGFnIik7CiAgICAgICAgICAgIGlmIChkYXRhLmxlbmd0aCA8IDIgfHwgZGF0YVtwb3MrK10gIT09IHRhZykKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZTogd3JvbmcgdGx2Iik7CiAgICAgICAgICAgIGNvbnN0IGZpcnN0ID0gZGF0YVtwb3MrK107CiAgICAgICAgICAgIGNvbnN0IGlzTG9uZyA9ICEhKGZpcnN0ICYgMTI4KTsKICAgICAgICAgICAgbGV0IGxlbmd0aCA9IDA7CiAgICAgICAgICAgIGlmICghaXNMb25nKQogICAgICAgICAgICAgIGxlbmd0aCA9IGZpcnN0OwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBmaXJzdCAmIDEyNzsKICAgICAgICAgICAgICBpZiAoIWxlbkxlbikKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBpbmRlZmluaXRlIGxlbmd0aCBub3Qgc3VwcG9ydGVkIik7CiAgICAgICAgICAgICAgaWYgKGxlbkxlbiA+IDQpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogYnl0ZSBsZW5ndGggaXMgdG9vIGJpZyIpOwogICAgICAgICAgICAgIGNvbnN0IGxlbmd0aEJ5dGVzID0gZGF0YS5zdWJhcnJheShwb3MsIHBvcyArIGxlbkxlbik7CiAgICAgICAgICAgICAgaWYgKGxlbmd0aEJ5dGVzLmxlbmd0aCAhPT0gbGVuTGVuKQogICAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5kZWNvZGU6IGxlbmd0aCBieXRlcyBub3QgY29tcGxldGUiKTsKICAgICAgICAgICAgIC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Bub3QgYWxsb3dlZCAobWluaW1hbCBlbmNvZGluZykKICAgICAgICBfaW50OiB7CiAgICAgICAgICBlbmNvZGUobnVtMikgewogICAgICAgICAgICBjb25zdCB7IEVycjogRSB9ID0gREVSOwogICAgICAgICAgICBpZiAobnVtMiA8IF8wbjUpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoImludGVnZXI6IG5lZ2F0aXZlIGludGVnZXJzIGFyZSBub3QgYWxsb3dlZCIpOwogICAgICAgICAgICBsZXQgaGV4ID0gbnVtYmVyVG9IZXhVbnBhZGRlZChudW0yKTsKICAgICAgICAgICAgaWYgKE51bWJlci5wYXJzZUludChoZXhbMF0sIDE2KSAmIDgpCiAgICAgICAgICAgICAgaGV4ID0gIjAwIiArIGhleDsKICAgICAgICAgICAgaWYgKGhleC5sZW5ndGggJiAxKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ1bmV4cGVjdGVkIGFzc2VydGlvbiIpOwogICAgICAgICAgICByZXR1cm4gaGV4OwogICAgICAgICAgfSwKICAgICAgICAgIGRlY29kZShkYXRhKSB7CiAgICAgICAgICAgIGNvbnN0IHsgRXJyOiBFIH0gPSBERVI7CiAgICAgICAgICAgIGlmIChkYXRhWzBdICYgMTI4KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJJbnZhbGlkIHNpZ25hdHVyZSBpbnRlZ2VyOiBuZWdhdGl2ZSIpOwogICAgICAgICAgICBpZiAoZGF0YVswXSA9PT0gMCAmJiAhKGRhdGFbMV0gJiAxMjgpKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJJbnZhbGlkIHNpZ25hdHVyZSBpbnRlZ2VyOiB1bm5lY2Vzc2FyeSBsZWFkaW5nIHplcm8iKTsKICAgICAgICAgICAgcmV0dXJuIGIybihkYXRhKTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIHRvU2lnKGhleCkgewogICAgICAgICAgY29uc3QgeyBFcnI6IEUsIF9pbnQ6IGludCwgX3RsdjogdGx2I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IEJpZ0ludCgiMHhlNDQzN2VkNjAxMGU4ODI4NmY1NDdmYTkwYWJmZTRjMyIpOwogICAgICAgICAgICBjb25zdCBhMiA9IEJpZ0ludCgiMHgxMTRjYTUwZjdhOGUyZjNmNjU3YzExMDhkOWQ0NGNmZDgiKTsKICAgICAgICAgICAgY29uc3QgYjIgPSBhMTsKICAgICAgICAgICAgY29uc3QgUE9XXzJfMTI4ID0gQmlnSW50KCIweDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMCIpOwogICAgICAgICAgICBjb25zdCBjMSA9IGRpdk5lYXJlc3QoYjIgKiBrLCBuKTsKICAgICAgICAgICAgY29uc3QgYzIgPSBkaXZOZWFyZXN0KC1iMSAqIGssIG4pOwogICAgICAgICAgICBsZXQgazEgPSBtb2QoayAtIGMxICogYTEgLSBjMiAqIGEyLCBuKTsKICAgICAgICAgICAgbGV0IGsyID0gbW9kKC1jMSAqIGIxIC0gYzIgKiBiMiwgbik7CiAgICAgICAgICAgIGNvbnN0IGsxbmVnID0gazEgPiBQT1dfMl8xMjg7CiAgICAgICAgICAgIGNvbnN0IGsybmVnID0gazIgPiBQT1dfMl8xMjg7CiAgICAgICAgICAgIGlmIChrMW5lZykKICAgICAgICAgICAgICBrMSA9IG4gLSBrMTsKICAgICAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgICAgIGsyID0gbiAtIGsyOwogICAgICAgICAgICBpZiAoazEgPiBQT1dfMl8xMjggfHwgazIgPiBQT1dfMl8xMjgpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInNwbGl0U2NhbGFyOiBFbmRvbW9ycGhpc20gZmFpbGVkLCBrPSIgKyBrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4geyBrMW5lZywgazEsIGsybmVnLCBrMiB9OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSwgc2hhMjU2KTsKICAgICAgXzBuNiA9IEJpZ0ludCgwKTsKICAgICAgVEFHR0VEX0hBU0hfUFJFRklYRVMgPSB7fTsKICAgICAgcG9pbnRUb0J5dGVzID0gKHBvaW50KSA9PiBwb2ludC50b1Jhd0J5dGVzKHRydWUpLnNsaWNlKDEpOwogICAgICBudW1UbzMyYiA9IChuKSA9PiBudW1iZXJUb0J5dGVzQkUobiwgMzIpOwogICAgICBtb2RQID0gKHgpID0+IG1vZCh4LCBzZWNwMjU2azFQKTsKICAgICAgbW9kTiA9ICh4KSA9PiBtb2QoeCwgc2VjcDI1NmsxTik7CiAgICAgIFBvaW50ID0gc2VjcDI1NmsxLlByb2plY3RpdmVQb2ludDsKICAgICAgR211bEFkZCA9IChRLCBhLCBiKSA9PiBQb2ludC5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFEsIGEsIGIpOwogICAgICBudW0gPSBieXRlc1RvTnVtYmVyQkU7CiAgICAgIHNjaG5vcnIgPSAvKiBAX19QVVJFX18gKi8gKCgpID0+ICh7CiAgICAgICAgZ2V0UHVibGljS2V5OiBzY2hub3JyR2V0UHVibGljS2V5LAogICAgICAgIHNpZ246IHNjaG5vcnJTaWduLAogICAgICAgIHZlcmlmeTogc2Nobm9yclZlcmlmeSwKICAgICAgICB1dGlsczogewogICAgICAgICAgcmFuZG9tUHJpdmF0ZUtleTogc2VjcDI1NmsxLnV0aWxzLnJhbmRvbVByaXZhdGVLZXksCiAgICAgICAgICBsaWZ0X3gsCiAgICAgICAgICBwb2ludFRvQnl0ZXMsCiAgICAgICAgICBudW1iZXJUb0J5dGVzQkUsCiAgICAgICAgICBieXRlc1RvTnVtYmVyQkUsCiAgICAgICAgICB0YWdnZWRIYXNoLAogICAgICAgICAgbW9kCiAgICAgICAgfQogICAgICB9KSkoKTsKICAgICAgaXNvTWFwID0gLyogQF9fUFVSRV9fICovICgoKSA9PiBpc29nZW55TWFwKEZwLCBbCiAgICAgICAgLy8geE51bQogICAgICAgIFsKICAgICAgICAgICIweDhlMzhlMzhlMzhlMzhlMzhlMzhlMzhlMzhlMz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WludDE3NiwgbWF4VWludDE4NCwgbWF4VWludDE5MiwgbWF4VWludDIwMCwgbWF4VWludDIwOCwgbWF4VWludDIxNiwgbWF4VWludDIyNCwgbWF4VWludDIzMiwgbWF4VWludDI0MCwgbWF4VWludDI0OCwgbWF4VWludDI1NjsKICB2YXIgaW5pdF9udW1iZXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NvbnN0YW50cy9udW1iZXIuanMiKCkgewogICAgICBtYXhJbnQ4ID0gMm4gKiogKDhuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDE2ID0gMm4gKiogKDE2biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQyNCA9IDJuICoqICgyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MzIgPSAybiAqKiAoMzJuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDQwID0gMm4gKiogKDQwbiAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ0OCA9IDJuICoqICg0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50NTYgPSAybiAqKiAoNTZuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDY0ID0gMm4gKiogKDY0biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ3MiA9IDJuICoqICg3Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50ODAgPSAybiAqKiAoODBuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDg4ID0gMm4gKiogKDg4biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ5NiA9IDJuICoqICg5Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTA0ID0gMm4gKiogKDEwNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTEyID0gMm4gKiogKDExMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTIwID0gMm4gKiogKDEyMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTI4ID0gMm4gKiogKDEyOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTM2ID0gMm4gKiogKDEzNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTQ0ID0gMm4gKiogKDE0NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTUyID0gMm4gKiogKDE1Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTYwID0gMm4gKiogKDE2MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTY4ID0gMm4gKiogKDE2OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTc2ID0gMm4gKiogKDE3Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTg0ID0gMm4gKiogKDE4NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTkyID0gMm4gKiogKDE5Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjAwID0gMm4gKiogKDIwMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjA4ID0gMm4gKiogKDIwOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjE2ID0gMm4gKiogKDIxNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjI0ID0gMm4gKiogKDIyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjMyID0gMm4gKiogKDIzMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQwID0gMm4gKiogKDI0MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQ4ID0gMm4gKiogKDI0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjU2ID0gMm4gKiogKDI1Nm4gLSAxbikgLSAxbjsKICAgICAgbWluSW50OCA9IC0oMm4gKiogKDhuIC0gMW4pKTsKICAgICAgbWluSW50MTYgPSAtKDJuICoqICgxNm4gLSAxbikpOwogICAgICBtaW5JbnQyNCA9IC0oMm4gKiogKDI0biAtIDFuKSk7CiAgICAgIG1pbkludDMyID0gLSgybiAqKiAoMzJuIC0gMW4pKTsKICAgICAgbWluSW50NDAgPSAtKDJuICoqICg0MG4gLSAxbikpOwogICAgICBtaW5JbnQ0OCA9IC0oMm4gKiogKDQ4biAtIDFuKSk7CiAgICAgIG1pbkludDU2ID0gLSgybiAqKiAoNTZuIC0gMW4pKTsKICAgICAgbWluSW50NjQgPSAtKDJuICoqICg2NG4gLSAxbikpOwogICAgICBtaW5JbnQ3MiA9IC0oMm4gKiogKDcybiAtIDFuKSk7CiAgICAgIG1pbkludDgwID0gLSgybiAqKiAoODBuIC0gMW4pKTsKICAgICAgbWluSW50ODggPSAtKDJuICoqICg4OG4gLSAxbikpOwogICAgICBtaW5JbnQ5NiA9IC0oMm4gKiogKDk2biAtIDFuKSk7CiAgICAgIG1pbkludDEwNCA9IC0oMm4gKiogKDEwNG4gLSAxbikpOwogICAgICBtaW5JbnQxMTIgPSAtKDJuICoqICgxMTJuIC0gMW4pKTsKICAgICAgbWluSW50MTIwID0gLSgybiAqKiAoMTIwbiAtIDFuKSk7CiAgICAgIG1pbkludDEyOCA9IC0oMm4gKiogKDEyOG4gLSAxbikpOwogICAgICBtaW5JbnQxMzYgPSAtKDJuICoqICgxMzZuIC0gMW4pKTsKICAgICAgbWluSW50MTQ0ID0gLSgybiAqKiAoMTQ0biAtIDFuKSk7CiAgICAgIG1pbkludDE1MiA9IC0oMm4gKiogKDE1Mm4gLSAxbikpOwogICAgICBtaW5JbnQxNjAgPSAtKDJuICoqICgxNjBuIC0gMW4pKTsKICAgICAgbWluSW50MTY4ID0gLSgybiAqKiAoMTY4biAtIDFuKSk7CiAgICAgIG1pbkludDE3NiA9IC0oMm4gKiogKDE3Nm4gLSAxbikpOwogICAgICBtaW5JbnQxODQgPSAtKDJuICoqICgxODRuIC0gMW4pKTsKICAgICAgbWluSW50MTkyID0gLSgybiAqKiAoMTkybiAtIDFuKSk7CiAgICAgIG1pbkludDIwMCA9IC0oMm4gKiogKDIwMG4gLSAxbikpOwogICAgICBtaW5JbnQyMDggPSAtKDJuICoqICgyMDhuIC0gMW4pKTsKICAgICAgbWluSW50MjE2ID0gLSgybiAqKiAoMjE2biAtIDFuKSk7CiAgICAgIG1pbkludDIyNCA9IC0oMm4gKiogKDIyNG4gLSAxbikpOwogICAgICBtaW5JbnQyMzIgPSAtKDJuICoqICgyMzJuIC0gMW4pKTsKICAgICAgbWluSW50MjQwID0gLSgybiAqKiAoMjQwbiAtIDFuKSk7CiAgICAgIG1pbkludDI0OCA9IC0oMm4gKiogKDI0OG4gLSAxbikpOwogICAgICBtaW5JbnQyNTYgPSAtKDJuICoqICgyNTZuIC0gMW4pKTsKICAgICAgbWF4VWludDggPSAybiAqKiA4biAtIDFuOwogICAgICBtYXhVaW50MTYgPSAybiAqKiAxNm4gLSAxbjsKICAgICAgbWF4VWludDI0ID0gMm4gKiogMjRuIC0gMW47CiAgICAgIG1heFVpbnQzMiA9IDJuICoqIDMybiAtIDFuOwogICAgICBtYXhVaW50NDAgPSAybiAqKiA0MG4gLSAxbjsKICAgICAgbWF4VWludDQ4ID0gMm4gKiogNDhuIC0gMW47CiAgICAgIG1heFVpbnQ1NiA9IDJuICoqIDU2biAtIDFuOwogICAgICBtYXhVaW50NjQgPSAybiAqKiA2NG4gLSAxbjsKICAgICAgbWF4VWludDcyID0gMm4gKiogNzJuIC0gMW47CiAgICAgIG1heFVpbnQ4MCA9IDJuICoqIDgwbiAtIDFuOwogICAgICBtYXhVaW50ODggPSAybiAqKiA4OG4gLSAxbjsKICAgICAgbWF4VWludDk2ID0gMm4gKiogOTZuIC0gMW47CiAgICAgIG1heFVpbnQxMDQgPSAybiAqKiAxMDRuIC0gMW47CiAgICAgIG1heFVpbnQxMTIgPSAybiAqKiAxMTJuIC0gMW47CiAgICAgIG1heFVpbnQxMjAgPSAybiAqKiAxMjBuIC0gMW47CiAgICAgIG1heFVpbnQxMjggPSAybiAqKiAxMjhuIC0gMW47CiAgICAgIG1heFVpbnQxMzYgPSAybiAqKiAxMzZuIC0gMW47CiAgICAgIG1heFVpb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gIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJhbGxvd0ZhaWx1cmUiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJjYWxsRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJjYWxscyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiYWdncmVnYXRlMyIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdWNjZXNzIiwKICAgICAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJyZXR1cm5EYXRhIiwKICAgICAgICAgICAgICB0eXBlOiAidHVwbGVbXSIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0KICAgICAgXTsKICAgICAgdW5pdmVyc2FsUmVzb2x2ZXJFcnJvcnMgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG5hbWU6ICJSZXNvbHZlck5vdEZvdW5kIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBuYW1lOiAiUmVzb2x2ZXJXaWxkY2FyZE5vdFN1cHBvcnRlZCIsCiAgICAgICAgICB0eXBlOiAiZXJyb3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyTm90Q29udHJhY3QiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyRXJyb3IiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdGF0dXMiLAogICAgICAgICAgICAgICAgICB0eXBlOiAidWludDE2IgogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgbmFtZTogIm1lc3NhZ2UiLAogICAgICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgbmFtZTogImVycm9ycyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiSHR0cEVycm9yIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmVzb2x2ZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmVzb2x2ZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlcyIgfSwKICAgICAgICAgICAgeyBuYW1lOiAiZGF0YSIsIHR5cGU6ICJieXRlcyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJyZXNvbHZlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7IG5hbWU6ICJuYW1lIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJkYXRhIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJnYXRld2F5cyIsIHR5cGU6ICJzdHJpbmdbXSIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmV2ZXJzZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmV2ZXJzZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFt7IHR5cGU6ICJieXRlcyIsIG5hbWU6ICJyZXZlcnNlTmFtZSIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogInN0cmluZyIsIG5hbWU6ICJyZXNvbHZlZE5hbWUiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmVzb2x2ZWRBZGRyZXNzIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJldmVyc2VSZXNvbHZlciIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlciIgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgbmFtZTogInJldmVyc2UiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogImJ5dGVzIiwgbmFtZTogInJldmVyc2VOYW1lIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJzdHJpbmdbXSIsIG5hbWU6ICJnYXRld2F5cyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyB0eXBlOiAic3RyaW5nIiwgbmFtZTogInJlc29sdmVkTmFtZSIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlZEFkZHJlc3MiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmV2ZXJzZVJlc29sdmVyIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJlc29sdmVyIiB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICB0ZXh0UmVzb2x2ZXJBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgbmFtZTogInRleHQiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfSwKICAgICAgICAgICAgeyBuYW1lOiAia2V5IiwgdHlwZTogInN0cmluZyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgIH0KICAgICAgXTsKICAgICAgYWRkcmVzc1Jlc29sdmVyQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJhZGRyIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbeyBuYW1lOiAiIiwgdHlwZTogImFkZHJlc3MiIH1dCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAiYWRkciIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJjb2luVHlwZSIsIHR5cGU6ICJ1aW50MjU2IiB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJieXRlcyIgfV0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFNpZ25hdHVyZVZhbGlkYXRvckFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiY29uc3RydWN0b3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiaXNWYWxpZFNpZyIKICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzIwQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic3ltYm9sIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXIiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICBlcmMyMEFiaV9ieXRlczMyID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJieXRlczMyIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYnl0ZXMzMiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0b3RhbFN1cHBseSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmVjaXBpZW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhbW91bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzcyMUFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZXZlbnQiLAogICAgICAgICAgbmFtZTogIkFwcHJvdmFsIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImV2ZW50IiwKICAgICAgICAgIG5hbWU6ICJBcHByb3ZhbEZvckFsbCIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm9wZXJhdG9yIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhcHByb3ZlZCIsCiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRva2VuSWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImFwcHJvdmUiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAicGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiZ2V0QXBwcm92ZWQiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImlzQXBwcm92ZWRGb3JBbGwiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAibmFtZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogIm93bmVyT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic2FmZVRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJwYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImZyb20iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNhZmVUcmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiaWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImRhdGEiLAogICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNldEFwcHJvdmFsRm9yQWxsIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFwcHJvdmVkIiwKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImluZGV4IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJpbmRleCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG9rZW5JZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG9rZW5VUkkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRva2VJZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbXQogICAgICAgIH0KICAgICAgXTsKICAgICAgZXJjNDYyNkFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiRGVwb3NpdCIsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiV2l0aGRyYXciLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImFsbG93YW5jZSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJhcHByb3ZlIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogImFzc2V0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldFRva2VuQWRkcmVzcyIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJjb252ZXJ0VG9Bc3NldHMiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiY29udmVydFRvU2hhcmVzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJkZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJjYWxsZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heERlcG9zaXQiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm1heEFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImNhbGxlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAibWF4TWludCIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFJlZGVlbSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFdpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJtYXhBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJtaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdEZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdNaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdSZWRlZW0iLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicHJldmlld1dpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicmVkZWVtIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsQXNzZXRzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b3RhbE1hbmFnZWRBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsU3VwcGx5IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiZnJvbSIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG8iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAid2l0aGRyYXciLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9CiAgICAgIF07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AgICAgICB9CiAgICAgIH07CiAgICAgIENoYWluTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICAgICAgICJObyBjaGFpbiB3YXMgcHJvdmlkZWQgdG8gdGhlIHJlcXVlc3QuIiwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgY2hhaW4gd2l0aCB0aGUgYGNoYWluYCBhcmd1bWVudCBvbiB0aGUgQWN0aW9uLCBvciBieSBzdXBwbHlpbmcgYSBgY2hhaW5gIHRvIFdhbGxldENsaWVudC4iCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkNoYWluTm90Rm91bmRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ2xpZW50Q2hhaW5Ob3RDb25maWd1cmVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoIk5vIGNoYWluIHdhcyBwcm92aWRlZCB0byB0aGUgQ2xpZW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIkNsaWVudENoYWluTm90Q29uZmlndXJlZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkQ2hhaW5JZEVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IGNoYWluSWQgfSkgewogICAgICAgICAgc3VwZXIodHlwZW9mIGNoYWluSWQgPT09ICJudW1iZXIiID8gYENoYWluIElEICIke2NoYWluSWR9IiBpcyBpbnZhbGlkLmAgOiAiQ2hhaW4gSUQgaXMgaW52YWxpZC4iLCB7IG5hbWU6ICJJbnZhbGlkQ2hhaW5JZEVycm9yIiB9KTsKICAgICAg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gdmFyIGluaXRfZW5jb2RlRGVwbG95RGF0YSA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvYWJpL2VuY29kZURlcGxveURhdGEuanMiKCkgewogICAgICBpbml0X2FiaSgpOwogICAgICBpbml0X2NvbmNhdCgpOwogICAgICBpbml0X2VuY29kZUFiaVBhcmFtZXRlcnMoKTsKICAgICAgZG9jc1BhdGg1ID0gIi9kb2NzL2NvbnRyYWN0L2VuY29kZURlcGxveURhdGEiOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2hhaW4vZ2V0Q2hhaW5Db250cmFjdEFkZHJlc3MuanMKICBmdW5jdGlvbiBnZXRDaGFpbkNvbnRyYWN0QWRkcmVzcyh7IGJsb2NrTnVtYmVyLCBjaGFpbiwgY29udHJhY3Q6IG5hbWUgfSkgewogICAgY29uc3QgY29udHJhY3QgPSBjaGFpbj8uY29udHJhY3RzPy5bbmFtZV07CiAgICBpZiAoIWNvbnRyYWN0KQogICAgICB0aHJvdyBuZXcgQ2hhaW5Eb2VzTm90U3VwcG9ydENvbnRyYWN0KHsKICAgICAgICBjaGFpbiwKICAgICAgICBjb250cmFjdDogeyBuYW1lIH0KICAgICAgfSk7CiAgICBpZiAoYmxvY2tOdW1iZXIgJiYgY29udHJhY3QuYmxvY2tDcmVhdGVkICYmIGNvbnRyYWN0LmJsb2NrQ3JlYXRlZCA+IGJsb2NrTnVtYmVyKQogICAgICB0aHJvdyBuZXcgQ2hhaW5Eb2VzTm90U3VwcG9ydENvbnRyYWN0KHsKICAgICAgICBibG9ja051bWJlciwKICAgICAgICBjaGFpbiwKICAgICAgICBjb250cmFjdDogewogICAgICAgICAgbmFtZSwKICAgICAgICAgIGJsb2NrQ3JlYXRlZDogY29udHJhY3QuY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jogJHtzZW5kZXJ9YCwKICAgICAgICAgICAgICBgICBEYXRhOiAke2RhdGF9YCwKICAgICAgICAgICAgICBgICBDYWxsYmFjayBzZWxlY3RvcjogJHtjYWxsYmFja1NlbGVjdG9yfWAsCiAgICAgICAgICAgICAgYCAgRXh0cmEgZGF0YTogJHtleHRyYURhdGF9YAogICAgICAgICAgICBdLmZsYXQoKSwKICAgICAgICAgICAgbmFtZTogIk9mZmNoYWluTG9va3VwRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwUmVzcG9uc2VNYWxmb3JtZWRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyByZXN1bHQsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiT2ZmY2hhaW4gZ2F0ZXdheSByZXNwb25zZSBpcyBtYWxmb3JtZWQuIFJlc3BvbnNlIGRhdGEgbXVzdCBiZSBhIGhleCB2YWx1ZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBHYXRld2F5IFVSTDogJHtnZXRVcmwodXJsKX1gLAogICAgICAgICAgICAgIGBSZXNwb25zZTogJHtzdHJpbmdpZnkocmVzdWx0KX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cFJlc3BvbnNlTWFsZm9ybWVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwU2VuZGVyTWlzbWF0Y2hFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzZW5kZXIsIHRvIH0pIHsKICAgICAgICAgIHN1cGVyKCJSZXZlcnRlZCBzZW5kZXIgYWRkcmVzcyBkb2VzIG5vdCBtYXRjaCB0YXJnZXQgY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JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgIGRldGFpbHM6IHJlc3VsdD8uZXJyb3IgPyBzdHJpbmdpZnkocmVzdWx0LmVycm9yKSA6IHJlc3BvbnNlLnN0YXR1c1RleHQsCiAgICAgICAgICAgIGhlYWRlcnM6IHJlc3BvbnNlLmhlYWRlcnMsCiAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICghaXNIZXgocmVzdWx0KSkgewogICAgICAgICAgZXJyb3IgPSBuZXcgT2ZmY2hhaW5Mb29rdXBSZXNwb25zZU1hbGZvcm1lZEVycm9yKHsKICAgICAgICAgICAgcmVzdWx0LAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgIGVycm9yID0gbmV3IEh0dHBSZXF1ZXN0RXJyb3IoewogICAgICAgICAgYm9keSwKICAgICAgICAgIGRldGFpbHM6IGVyci5tZXNzYWdlLAogICAgICAgICAgdXJsCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIHRocm93IGVycm9yOwogIH0KICB2YXIgb2ZmY2hhaW5Mb29rdXBTaWduYXR1cmUsIG9mZmNoYWluTG9va3VwQWJpSXRlbTsKICB2YXIgaW5pdF9jY2lwMiA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2NpcC5qcyIoKSB7CiAgICAgIGluaXRfY2FsbCgpOwogICAgICBpbml0X2NjaXAoKTsKICAgICAgaW5pdF9yZXF1ZXN0KCk7CiAgICAgIGluaXRfZGVjb2RlRXJyb3JSZXN1bHQoKTsKICAgICAgaW5pdF9lbmNvZGVBYmlQYXJhbWV0ZXJzKCk7CiAgICAgIGluaXRfaXNBZGRyZXNzRXF1YWwoKTsKICAgICAgaW5pdF9jb25jYXQoKTsKICAgICAgaW5pdF9pc0hleCgpOwogICAgICBpbml0X3N0cmluZ2lmeSgpOwogICAgICBvZmZjaGFpbkxvb2t1cFNpZ25hdHVyZSA9ICIweDU1NmYxODMwIjsKICAgICAgb2ZmY2hhaW5Mb29rdXBBYmlJdGVtID0gewogICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cCIsCiAgICAgICAgdHlwZTogImVycm9yIiwKICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInVybHMiLAogICAgICAgICAgICB0eXBlOiAic3RyaW5nW10iCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbERhdGEiLAogICAgICAgICAgICB0eXBlOiAiYnl0ZXMiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiY2FsbGJhY2tGdW5jdGlvbiIsCiAgICAgICAgICAgIHR5cGU6ICJieXRlczQiCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAiZXh0cmFEYXRhIiwKICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgfQogICAgICAgIF0KICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL2NhbGwuanMKICBhc3luYyBmdW5jdGlvbiBjYWxsKGNsaWVudCwgYXJncykgewogICAgY29uc3QgeyBhY2NvdW50OiBhY2NvdW50X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xBZGRyZXNzID0gZ2V0Q2hhaW5Db250cmFjdEFkZHJlc3MoewogICAgICAgIGJsb2NrTnVtYmVyLAogICAgICAgIGNoYWluOiBjbGllbnQuY2hhaW4sCiAgICAgICAgY29udHJhY3Q6ICJtdWx0aWNhbGwzIgogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGJsb2NrTnVtYmVySGV4ID0gYmxvY2tOdW1iZXIgPyBudW1iZXJUb0hleChibG9ja051bWJlcikgOiB2b2lkIDA7CiAgICBjb25zdCBibG9jayA9IGJsb2NrTnVtYmVySGV4IHx8IGJsb2NrVGFnOwogICAgY29uc3QgeyBzY2hlZHVsZSB9ID0gY3JlYXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICBpZDogYCR7Y2xpZW50LnVpZH0uJHtibG9ja31gLAogICAgICB3YWl0OiB3YWl0MiwKICAgICAgc2hvdWxkU3BsaXRCYXRjaChhcmdzMikgewogICAgICAgIGNvbnN0IHNpemUzID0gYXJnczIucmVkdWNlKChzaXplNCwgeyBkYXRhOiBkYXRhMiB9KSA9PiBzaXplNCArIChkYXRhMi5sZW5ndGggLSAyKSwgMCk7CiAgICAgICAgcmV0dXJuIHNpemUzID4gYmF0Y2hTaXplICogMjsKICAgICAgfSwKICAgICAgZm46IGFzeW5jIChyZXF1ZXN0cykgPT4gewogICAgICAgIGNvbnN0IGNhbGxzID0gcmVxdWVzdHMubWFwKChyZXF1ZXN0KSA9PiAoewogICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgY2FsbERhdGE6IHJlcXVlc3QuZGF0YSwKICAgICAgICAgIHRhcmdldDogcmVxdWVzdC50bwogICAgICAgIH0pKTsKICAgICAgICBjb25zdCBjYWxsZGF0YSA9IGVuY29kZUZ1bmN0aW9uRGF0YSh7CiAgICAgICAgICBhYmk6IG11bHRpY2FsbDNBYmksCiAgICAgICAgICBhcmdzOiBbY2FsbHNdLAogICAgICAgICAgZnVuY3Rpb25OYW1lOiAiYWdncmVnYXRlMyIKICAgICAgICB9KTsKICAgICAgICBjb25zdCBkYXRhMiA9IGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgIG1ldGhvZDogImV0aF9jYWxsIiwKICAgICAgICAgIHBhcmFtczogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgZGF0YTogY2FsbGRhdGEsCiAgICAgICAgICAgICAgdG86IG11bHRpY2FsbEFkZHJlc3MKICAgICAgICAgICAgfSwKICAgICAgICAgICAgYmxvY2sKICAgICAgICAgIF0KICAgICAgICB9KTsKICAgICAgICByZXR1cm4gZGVjb2RlRnVuY3Rpb25SZXN1bHQoewogICAgICAgICAgYWJpOiBtdWx0aWNhbGwzQWJpLAogICAgICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgICAgIGZ1bmN0aW9uTmFtZTogImFnZ3JlZ2F0ZTMiLAogICAgICAgICAgZGF0YTogZGF0YTIgfHwgIjB4IgogICAgICAgIH0pOwogICAgICB9CiAgICB9KTsKICAgIGNvbnN0IFt7IHJldHVybkRhdGEsIHN1Y2Nlc3MgfV0gPSBhd2FpdCBzY2hlZHVsZSh7IGRhdGEsIHRvIH0pOwogICAgaWYgKCFzdWNjZXNzKQogICAgICB0aHJvdyBuZXcgUmF3Q29udHJhY3RFcnJvcih7IGRhdGE6IHJldHVybkRhdGEgfSk7CiAgICBpZiAocmV0dXJuRGF0YSA9PT0gIjB4IikKICAgICAgcmV0dXJuIHsgZGF0YTogdm9pZCAwIH07CiAgICByZXR1cm4geyBkYXRhOiByZXR1cm5EYXRhIH07CiAgfQogIGZ1bmN0aW9uIHRvRGVwbG95bGVzc0NhbGxWaWFCeXRlY29kZURhdGEocGFyYW1ldGVycykgewogICAgY29uc3QgeyBjb2RlLCBkYXRhIH0gPSBwYXJhbWV0ZXJzOwogICAgcmV0dXJuIGVuY29kZURlcGxveURhdGEoewogICAgICBhYmk6IHBhcnNlQWJpKFsiY29uc3RydWN0b3IoYnl0ZXMsIGJ5dGVzKSJdKSwKIC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xMjg6ICgpID0+IG1heEludDEyOCwKICAgIG1heEludDEzNjogKCkgPT4gbWF4SW50MTM2LAogICAgbWF4SW50MTQ0OiAoKSA9PiBtYXhJbnQxNDQsCiAgICBtYXhJbnQxNTI6ICgpID0+IG1heEludDE1MiwKICAgIG1heEludDE2OiAoKSA9PiBtYXhJbnQxNiwKICAgIG1heEludDE2MDogKCkgPT4gbWF4SW50MTYwLAogICAgbWF4SW50MTY4OiAoKSA9PiBtYXhJbnQxNjgsCiAgICBtYXhJbnQxNzY6ICgpID0+IG1heEludDE3NiwKICAgIG1heEludDE4NDogKCkgPT4gbWF4SW50MTg0LAogICAgbWF4SW50MTkyOiAoKSA9PiBtYXhJbnQxOTIsCiAgICBtYXhJbnQyMDA6ICgpID0+IG1heEludDIwMCwKICAgIG1heEludDIwODogKCkgPT4gbWF4SW50MjA4LAogICAgbWF4SW50MjE2OiAoKSA9PiBtYXhJbnQyMTYsCiAgICBtYXhJbnQyMjQ6ICgpID0+IG1heEludDIyNCwKICAgIG1heEludDIzMjogKCkgPT4gbWF4SW50MjMyLAogICAgbWF4SW50MjQ6ICgpID0+IG1heEludDI0LAogICAgbWF4SW50MjQwOiAoKSA9PiBtYXhJbnQyNDAsCiAgICBtYXhJbnQyNDg6ICgpID0+IG1heEludDI0OCwKICAgIG1heEludDI1NjogKCkgPT4gbWF4SW50MjU2LAogICAgbWF4SW50MzI6ICgpID0+IG1heEludDMyLAogICAgbWF4SW50NDA6ICgpID0+IG1heEludDQwLAogICAgbWF4SW50NDg6ICgpID0+IG1heEludDQ4LAogICAgbWF4SW50NTY6ICgpID0+IG1heEludDU2LAogICAgbWF4SW50NjQ6ICgpID0+IG1heEludDY0LAogICAgbWF4SW50NzI6ICgpID0+IG1heEludDcyLAogICAgbWF4SW50ODogKCkgPT4gbWF4SW50OCwKICAgIG1heEludDgwOiAoKSA9PiBtYXhJbnQ4MCwKICAgIG1heEludDg4OiAoKSA9PiBtYXhJbnQ4OCwKICAgIG1heEludDk2OiAoKSA9PiBtYXhJbnQ5NiwKICAgIG1heFVpbnQxMDQ6ICgpID0+IG1heFVpbnQxMDQsCiAgICBtYXhVaW50MTEyOiAoKSA9PiBtYXhVaW50MTEyLAogICAgbWF4VWludDEyMDogKCkgPT4gbWF4VWludDEyMCwKICAgIG1heFVpbnQxMjg6ICgpID0+IG1heFVpbnQxMjgsCiAgICBtYXhVaW50MTM2OiAoKSA9PiBtYXhVaW50MTM2LAogICAgbWF4VWludDE0NDogKCkgPT4gbWF4VWludDE0NCwKICAgIG1heFVpbnQxNTI6ICgpID0+IG1heFVpbnQxNTIsCiAgICBtYXhVaW50MTY6ICgpID0+IG1heFVpbnQxNiwKICAgIG1heFVpbnQxNjA6ICgpID0+IG1heFVpbnQxNjAsCiAgICBtYXhVaW50MTY4OiAoKSA9PiBtYXhVaW50MTY4LAogICAgbWF4VWludDE3NjogKCkgPT4gbWF4VWludDE3NiwKICAgIG1heFVpbnQxODQ6ICgpID0+IG1heFVpbnQxODQsCiAgICBtYXhVaW50MTkyOiAoKSA9PiBtYXhVaW50MTkyLAogICAgbWF4VWludDIwMDogKCkgPT4gbWF4VWludDIwMCwKICAgIG1heFVpbnQyMDg6ICgpID0+IG1heFVpbnQyMDgsCiAgICBtYXhVaW50MjE2OiAoKSA9PiBtYXhVaW50MjE2LAogICAgbWF4VWludDIyNDogKCkgPT4gbWF4VWludDIyNCwKICAgIG1heFVpbnQyMzI6ICgpID0+IG1heFVpbnQyMzIsCiAgICBtYXhVaW50MjQ6ICgpID0+IG1heFVpbnQyNCwKICAgIG1heFVpbnQyNDA6ICgpID0+IG1heFVpbnQyNDAsCiAgICBtYXhVaW50MjQ4OiAoKSA9PiBtYXhVaW50MjQ4LAogICAgbWF4VWludDI1NjogKCkgPT4gbWF4VWludDI1NiwKICAgIG1heFVpbnQzMjogKCkgPT4gbWF4VWludDMyLAogICAgbWF4VWludDQwOiAoKSA9PiBtYXhVaW50NDAsCiAgICBtYXhVaW50NDg6ICgpID0+IG1heFVpbnQ0OCwKICAgIG1heFVpbnQ1NjogKCkgPT4gbWF4VWludDU2LAogICAgbWF4VWludDY0OiAoKSA9PiBtYXhVaW50NjQsCiAgICBtYXhVaW50NzI6ICgpID0+IG1heFVpbnQ3MiwKICAgIG1heFVpbnQ4OiAoKSA9PiBtYXhVaW50OCwKICAgIG1heFVpbnQ4MDogKCkgPT4gbWF4VWludDgwLAogICAgbWF4VWludDg4OiAoKSA9PiBtYXhVaW50ODgsCiAgICBtYXhVaW50OTY6ICgpID0+IG1heFVpbnQ5NiwKICAgIG1pbkludDEwNDogKCkgPT4gbWluSW50MTA0LAogICAgbWluSW50MTEyOiAoKSA9PiBtaW5JbnQxMTIsCiAgICBtaW5JbnQxMjA6ICgpID0+IG1pbkludDEyMCwKICAgIG1pbkludDEyODogKCkgPT4gbWluSW50MTI4LAogICAgbWluSW50MTM2OiAoKSA9PiBtaW5JbnQxMzYsCiAgICBtaW5JbnQxNDQ6ICgpID0+IG1pbkludDE0NCwKICAgIG1pbkludDE1MjogKCkgPT4gbWluSW50MTUyLAogICAgbWluSW50MTY6ICgpID0+IG1pbkludDE2LAogICAgbWluSW50MTYwOiAoKSA9PiBtaW5JbnQxNjAsCiAgICBtaW5JbnQxNjg6ICgpID0+IG1pbkludDE2OCwKICAgIG1pbkludDE3NjogKCkgPT4gbWluSW50MTc2LAogICAgbWluSW50MTg0OiAoKSA9PiBtaW5JbnQxODQsCiAgICBtaW5JbnQxOTI6ICgpID0+IG1pbkludDE5MiwKICAgIG1pbkludDIwMDogKCkgPT4gbWluSW50MjAwLAogICAgbWluSW50MjA4OiAoKSA9PiBtaW5JbnQyMDgsCiAgICBtaW5JbnQyMTY6ICgpID0+IG1pbkludDIxNiwKICAgIG1pbkludDIyNDogKCkgPT4gbWluSW50MjI0LAogICAgbWluSW50MjMyOiAoKSA9PiBtaW5JbnQyMzIsCiAgICBtaW5JbnQyNDogKCkgPT4gbWluSW50MjQsCiAgICBtaW5JbnQyNDA6ICgpID0+IG1pbkludD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ZXRob2Q6ICJldGhfbmV3RmlsdGVyIgogICAgfSk7CiAgICBjb25zdCB0b3BpY3MgPSBldmVudE5hbWUgPyBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lCiAgICB9KSA6IHZvaWQgMDsKICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgdG9waWNzCiAgICAgICAgfQogICAgICBdCiAgICB9KTsKICAgIHJldHVybiB7CiAgICAgIGFiaTogYWJpMiwKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lLAogICAgICBpZCwKICAgICAgcmVxdWVzdDogZ2V0UmVxdWVzdChpZCksCiAgICAgIHN0cmljdDogQm9vbGVhbihzdHJpY3QpLAogICAgICB0eXBlOiAiZXZlbnQiCiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL2VzdGltYXRlQ29udHJhY3RHYXMuanMKICBpbml0X3BhcnNlQWNjb3VudCgpOwogIGluaXRfZW5jb2RlRnVuY3Rpb25EYXRhKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9lcn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llbnQuY2hhaW4sIHJlcXVlc3QgfSA9IGFyZ3MgfHwge307CiAgICB0cnkgewogICAgICBjb25zdCBtYXhQcmlvcml0eUZlZVBlckdhcyA9IGNoYWluPy5mZWVzPy5tYXhQcmlvcml0eUZlZVBlckdhcyA/PyBjaGFpbj8uZmVlcz8uZGVmYXVsdFByaW9yaXR5RmVlOwogICAgICBpZiAodHlwZW9mIG1heFByaW9yaXR5RmVlUGVyR2FzID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgY29uc3QgYmxvY2sgPSBibG9ja18gfHwgYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHt9KTsKICAgICAgICBjb25zdCBtYXhQcmlvcml0eUZlZVBlckdhc18gPSBhd2FpdCBtYXhQcmlvcml0eUZlZVBlckdhcyh7CiAgICAgICAgICBibG9jaywKICAgICAgICAgIGNsaWVudCwKICAgICAgICAgIHJlcXVlc3QKICAgICAgICB9KTsKICAgICAgICBpZiAobWF4UHJpb3JpdHlGZWVQZXJHYXNfID09PSBudWxsKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCk7CiAgICAgICAgcmV0dXJuIG1heFByaW9yaXR5RmVlUGVyR2FzXzsKICAgICAgfQogICAgICBpZiAodHlwZW9mIG1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZpbmVkIikKICAgICAgICByZXR1cm4gbWF4UHJpb3JpdHlGZWVQZXJHYXM7CiAgICAgIGNvbnN0IG1heFByaW9yaXR5RmVlUGVyR2FzSGV4ID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9tYXhQcmlvcml0eUZlZVBlckdhcyIKICAgICAgfSk7CiAgICAgIHJldHVybiBoZXhUb0JpZ0ludChtYXhQcmlvcml0eUZlZVBlckdhc0hleCk7CiAgICB9IGNhdGNoIHsKICAgICAgY29uc3QgW2Jsb2NrLCBnYXNQcmljZV0gPSBhd2FpdCB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SGFzaGVzID0gdmVyc2lvbmVkSGFzaGVzOwogICAgICB9CiAgICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJzaWRlY2FycyIpKSB7CiAgICAgICAgY29uc3QgcHJvb2ZzID0gYmxvYnNUb1Byb29mcyh7IGJsb2JzLCBjb21taXRtZW50cywga3pnIH0pOwogICAgICAgIGNvbnN0IHNpZGVjYXJzID0gdG9CbG9iU2lkZWNhcnMoewogICAgICAgICAgYmxvYnMsCiAgICAgICAgICBjb21taXRtZW50cywKICAgICAgICAgIHByb29mcywKICAgICAgICAgIHRvOiAiaGV4IgogICAgICAgIH0pOwogICAgICAgIHJlcXVlc3Quc2lkZWNhcnMgPSBzaWRlY2FyczsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImNoYWluSWQiKSkKICAgICAgcmVxdWVzdC5jaGFpbklkID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJub25jZSIpICYmIHR5cGVvZiBub25jZSA9PT0gInVuZGVmaW5lZCIgJiYgYWNjb3VudCkgewogICAgICBpZiAobm9uY2VNYW5hZ2VyMikgewogICAgICAgIGNvbnN0IGNoYWluSWQyID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgICAgICByZXF1ZXN0Lm5vbmNlID0gYXdhaXQgbm9uY2VNYW5hZ2VyMi5jb25zdW1lKHsKICAgICAgICAgIGFkZHJlc3M6IGFjY291bnQuYWRkcmVzcywKICAgICAgICAgIGNoYWluSWQ6IGNoYWluSWQyLAogICAgICAgICAgY2xpZW50CiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmVxdWVzdC5ub25jZSA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uQ291bnQsICJnZXRUcmFuc2FjdGlvbkNvdW50IikoewogICAgICAgICAgYWRkcmVzczogYWNjb3VudC5hZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBpZiAoKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSB8fCBwYXJhbWV0ZXJzLmluY2x1ZGVzKCJ0eXBlIikpICYmIHR5cGVvZiB0eXBlID09PSAidW5kZWZpbmVkIikgewogICAgICB0cnkgewogICAgICAgIHJlcXVlc3QudHlwZSA9IGdldFRyYW5zYWN0aW9uVHlwZShyZXF1ZXN0KTsKICAgICAgfSBjYXRjaCB7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgcmVxdWVzdC50eXBlID0gdHlwZW9mIGJsb2NrMj8uYmFzZUZlZVBlckdhcyA9PT0gImJpZ2ludCIgPyAiZWlwMTU1OSIgOiAibGVnYWN5IjsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSkgewogICAgICBpZiAocmVxdWVzdC50eXBlICE9PSAibGVnYWN5IiAmJiByZXF1ZXN0LnR5cGUgIT09ICJlaXAyOTMwIikgewogICAgICAgIGlmICh0eXBlb2YgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiByZXF1ZXN0Lm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgICBjb25zdCB7IG1heEZlZVBlckdhcywgbWF4UHJpb3JpdHlGZWVQZXJHYXMgfSA9IGF3YWl0IGludGVybmFsX2VzdGltYXRlRmVlc1BlckdhcyhjbGllbnQsIHsKICAgICAgICAgICAgYmxvY2s6IGJsb2NrMiwKICAgICAgICAgICAgY2hhaW4sCiAgICAgICAgICAgIHJlcXVlc3QKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIiAmJiBhcmdzLm1heEZlZVBlckdhcyAmJiBhcmdzLm1heEZlZVBlckdhcyA8IG1heFByaW9yaXR5RmVlUGVyR2FzKQogICAgICAgICAgICB0aHJvdyBuZXcgTWF4RmVlUGVyR2FzVG9vTG93RXJyb3IoewogICAgICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzCiAgICAgICAgICAgIH0pOwogICAgICAgICAgcmVxdWVzdC5tYXhQcmlvcml0eUZlZVBlckdhcyA9IG1heFByaW9yaXR5RmVlUGVyR2FzOwogICAgICAgICAgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPSBtYXhGZWVQZXJHYXM7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICh0eXBlb2YgYXJncy5tYXhGZWVQZXJHYXMgIT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZpbmVkIikKICAgICAgICAgIHRocm93IG5ldyBFaXAxNTU5RmVlc05vdFN1cHBvcnRlZEVycm9yKCk7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgY29uc3QgeyBnYXNQcmljZTogZ2FzUHJpY2VfIH0gPSBhd2FpdCBpbnRlcm5hbF9lc3RpbWF0ZUZlZXNQZXJHYXMoY2xpZW50LCB7CiAgICAgICAgICBibG9jazogYmxvY2syLAogICAgICAgICAgY2hhaW4sCiAgICAgICAgICByZXF1ZXN0LAogICAgICAgICAgdHlwZTogImxlZ2FjeSIKICAgICAgICB9KTsKICAgICAgICByZXF1ZXN0Lmdhc1ByaWNlID0gZ2FzUHJpY2VfOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyYW1ldGVycy5pbmNsdWRlcygiZ2FzIikgJiYgdHlwZW9mIGdhcyA9PT0gInVuZGVm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ldGVyczogKAogICAgICAgICAgLy8gU29tZSBSUEMgUHJvdmlkZXJzIGRvIG5vdCBjb21wdXRlIHZlcnNpb25lZCBoYXNoZXMgZnJvbSBibG9icy4gV2Ugd2lsbCBuZWVkCiAgICAgICAgICAvLyB0byBjb21wdXRlIHRoZW0uCiAgICAgICAgICBhY2NvdW50Py50eXBlID09PSAibG9jYWwiID8gdm9pZCAwIDogWyJibG9iVmVyc2lvbmVkSGFzaGVzIl0KICAgICAgICApCiAgICAgIH0pOwogICAgICBjb25zdCBibG9ja051bWJlckhleCA9IGJsb2NrTnVtYmVyID8gbnVtYmVyVG9IZXgoYmxvY2tOdW1iZXIpIDogdm9pZCAwOwogICAgICBjb25zdCBibG9jayA9IGJsb2NrTnVtYmVySGV4IHx8IGJsb2NrVGFnOwogICAgICBjb25zdCBycGNTdGF0ZU92ZXJyaWRlID0gc2VyaWFsaXplU3RhdGVPdmVycmlkZShzdGF0ZU92ZXJyaWRlKTsKICAgICAgY29uc3QgdG8gPSBhd2FpdCAoYXN5bmMgKCkgPT4gewogICAgICAgIGlmIChyZXN0LnRvKQogICAgICAgICAgcmV0dXJuIHJlc3QudG87CiAgICAgICAgaWYgKGF1dGhvcml6YXRpb25MaXN0ICYmIGF1dGhvcml6YXRpb25MaXN0Lmxlbmd0aCA+IDApCiAgICAgICAgICByZXR1cm4gYXdhaXQgcmVjb3ZlckF1dGhvcml6YXRpb25BZGRyZXNzKHsKICAgICAgICAgICAgYXV0aG9yaXphdGlvbjogYXV0aG9yaXphdGlvbkxpc3RbMF0KICAgICAgICAgIH0pLmNhdGNoKCgpID0+IHsKICAgICAgICAgICAgdGhyb3cgbmV3IEJhc2VFcnJvcjIoImB0b2AgaXMgcmVxdWlyZWQuIENvdWxkIG5vdCBpbmZlciBmcm9tIGBhdXRob3JpemF0aW9uTGlzdGAiKTsKICAgICAgICAgIH0pOwogICAgICAgIHJldHVybiB2b2lkIDA7CiAgICAgIH0pKCk7CiAgICAgIGFzc2VydFJlcXVl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XN0aW1hdGVzID0gYXdhaXQgUHJvbWlzZS5hbGwoYXV0aG9yaXphdGlvbkxpc3QubWFwKGFzeW5jIChhdXRob3JpemF0aW9uKSA9PiB7CiAgICAgICAgICBjb25zdCB7IGNvbnRyYWN0QWRkcmVzcyB9ID0gYXV0aG9yaXphdGlvbjsKICAgICAgICAgIGNvbnN0IGVzdGltYXRlMiA9IGF3YWl0IGVzdGltYXRlR2FzX3JwYyh7CiAgICAgICAgICAgIGJsb2NrLAogICAgICAgICAgICByZXF1ZXN0OiB7CiAgICAgICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3Q6IHZvaWQgMCwKICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgIGZyb206IGFjY291bnQ/LmFkZHJlc3MsCiAgICAgICAgICAgICAgdG86IGNvbnRyYWN0QWRkcmVzcywKICAgICAgICAgICAgICB2YWx1ZTogbnVtYmVyVG9IZXgodmFsdWUyKQogICAgICAgICAgICB9LAogICAgICAgICAgICBycGNTdGF0ZU92ZXJyaWRlCiAgICAgICAgICB9KS5jYXRjaCgoKSA9PiAxMDAwMDBuKTsKICAgICAgICAgIHJldHVybiAybiAqIEJpZ0ludChlc3RpbWF0ZTIpOwogICAgICAgIH0pKTsKICAgICAgICBlc3RpbWF0ZSArPSBlc3RpbWF0ZXMucmVkdWNlKChhY2MsIGN1cnIpID0+IGFjYyArIGN1cnIsIDBuKTsKICAgICAgfQogICAgICByZXR1cm4gZXN0aW1hdGU7CiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgdGhyb3cgZ2V0RXN0aW1hdGVHYXNFcnJvcihlcnIsIHsKICAgICAgICAuLi5hcmdzLAogICAgICAgIGFjY291bnQsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbgogICAgICB9KTsKICAgIH0KICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL3B1YmxpYy9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wYXJhbSwgdmFsdWU6IHRvcGljIH0pOwogICAgfQogICAgY29uc3Qgbm9uSW5kZXhlZElucHV0cyA9IGlucHV0cy5maWx0ZXIoKHgpID0+ICEoImluZGV4ZWQiIGluIHggJiYgeC5pbmRleGVkKSk7CiAgICBpZiAobm9uSW5kZXhlZElucHV0cy5sZW5ndGggPiAwKSB7CiAgICAgIGlmIChkYXRhICYmIGRhdGEgIT09ICIweCIpIHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgZGVjb2RlZERhdGEgPSBkZWNvZGVBYmlQYXJhbWV0ZXJzKG5vbkluZGV4ZWRJbnB1dHMsIGRhdGEpOwogICAgICAgICAgaWYgKGRlY29kZWREYXRhKSB7CiAgICAgICAgICAgIGlmIChpc1VubmFtZWQpCiAgICAgICAgICAgICAgYXJncyA9IFsuLi5hcmdzLCAuLi5kZWNvZGVkRGF0YV07CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbm9uSW5kZXhlZElucHV0cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgYXJnc1tub25JbmRleGVkSW5wdXRzW2ldLm5hbWVdID0gZGVjb2RlZERhdGFbaV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICBpZiAoc3RyaWN0KSB7CiAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBBYmlEZWNvZGluZ0RhdGFTaXplVG9vU21hbGxFcnJvciB8fCBlcnIgaW5zdGFuY2VvZiBQb3NpdGlvbk91dE9mQm91bmRzRXJyb3IpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ0RhdGFNaXNtYXRjaCh7CiAgICAgICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgIHBhcmFtczogbm9uSW5kZXhlZElucHV0cywKICAgICAgICAgICAgICAgIHNpemU6IHNpemUoZGF0YSkKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChzdHJpY3QpIHsKICAgICAgICB0aHJvdyBuZXcgRGVjb2RlTG9nRGF0YU1pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBkYXRhOiAiMHgiLAogICAgICAgICAgcGFyYW1zOiBub25JbmRleGVkSW5wdXRzLAogICAgICAgICAgc2l6ZTogMAogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBldmVudE5hbWU6IG5hbWUsCiAgICAgIGFyZ3M6IE9iamVjdC52YWx1ZXMoYXJncykubGVuZ3RoID4gMCA/IGFyZ3MgOiB2b2lkIDAKICAgIH07CiAgfQogIGZ1bmN0aW9uIGRlY29kZVRvcGljKHsgcGFyYW0sIHZhbHVlIH0pIHsKICAgIGlmIChwYXJhbS50eXBlID09PSAic3RyaW5nIiB8fCBwYXJhbS50eXBlID09PSAiYnl0ZXMiIHx8IHBhcmFtLnR5cGUgPT09ICJ0dXBsZSIgfHwgcGFyYW0udHlwZS5tYXRjaCgvXiguKilcWyhcZCspP1xdJC8pKQogICAgICByZXR1cm4gdmFsdWU7CiAgICBjb25zdCBkZWNvZGVkQXJnID0gZGVjb2RlQWJpUGFyYW1ldGVycyhbcGFyYW1dLCB2YWx1ZSkgfHwgW107CiAgICByZXR1cm4gZGVjb2RlZEFyZ1swXTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9hYmkvcGFyc2VFdmVudExvZ3MuanMKICBmdW5jdGlvbiBwYXJzZUV2ZW50TG9ncyhwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCB7IGFiaTogYWJpMiwgYXJncywgbG9ncywgc3RyaWN0ID0gdHJ1ZSB9ID0gcGFyYW1ldGVyczsKICAgIGNvbnN0IGV2ZW50TmFtZSA9ICgoKSA9PiB7CiAgICAgIGlmICghcGFyYW1ldGVycy5ldmVudE5hbWUpCiAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkocGFyYW1ldGVycy5ldmVudE5hbWUpKQogICAgICAgIHJldHVybiBwYXJhbWV0ZXJzLmV2ZW50TmFtZTsKICAgICAgcmV0dXJuIFtwYXJhbWV0ZXJzLmV2ZW50TmFtZV07CiAgICB9KSgpOwogICAgcmV0dXJuIGxvZ3MubWFwKChsb2cpID0+IHsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBhYmlJdGVtID0gYWJpMi5maW5kKChhYmlJdGVtMikgPT4gYWJpSXRlbTIudHlwZSA9PT0gImV2ZW50IiAmJiBsb2cudG9waWNzWzBdID09PSB0b0V2ZW50U2VsZWN0b3IoYWJpSXRlbTIpKTsKICAgICAgICBpZiAoIWFiaUl0ZW0pCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICBjb25zdCBldmVudCA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgIC4uLmxvZywKICAgICAgICAgIGFiaTogW2FiaUl0ZW1dLAogICAgICAgICAgc3RyaWN0CiAgICAgICAgfSk7CiAgICAgICAgaWYgKGV2ZW50TmFtZSAmJiAhZXZlbnROYW1lLmluY2x1ZGVzKGV2ZW50LmV2ZW50TmFtZSkpCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICBpZiAoIWluY2x1ZGVzQXJncyh7CiAgICAgICAgICBhcmdzOiBldmVudC5hcmdzLAogICAgICAgICAgaW5wdXRzOiBhYmlJdGVtLmlucHV0cywKICAgICAgICAgIG1hdGNoQXJnczogYXJncwogICAgICAgIH0pKQogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgcmV0dXJuIHsgLi4uZXZlbnQsIC4uLmxvZyB9OwogICAgICB9I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G9kOiAiZXRoX2dldExvZ3MiLAogICAgICAgIHBhcmFtczogW3sgYWRkcmVzcywgdG9waWNzLCBibG9ja0hhc2ggfV0KICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBsb2dzID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9nZXRMb2dzIiwKICAgICAgICBwYXJhbXM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgdG9waWNzLAogICAgICAgICAgICBmcm9tQmxvY2s6IHR5cGVvZiBmcm9tQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgoZnJvbUJsb2NrKSA6IGZyb21CbG9jaywKICAgICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGZvcm1hdHRlZExvZ3MgPSBsb2dzLm1hcCgobG9nKSA9PiBmb3JtYXRMb2cobG9nKSk7CiAgICBpZiAoIWV2ZW50cykKICAgICAgcmV0dXJuIGZvcm1hdHRlZExvZ3M7CiAgICByZXR1cm4gcGFyc2VFdmVudExvZ3MoewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgbG9nczogZm9ybWF0dGVkTG9ncywKICAgICAgc3RyaWN0CiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL3B1YmxpYy9nZXRDb250cmFjdEV2ZW50cy5qcwogIGFzeW5jIGZ1bmN0aW9uIGdldENvbnRyYWN0RXZlbnRzKGNsaWVudCwgcGFyYW1ldGVycykgewogICAgY29uc3QgeyBhYmk6IGFiaTIsIGFkZHJlc3MsIGFyZ3Ms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HlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAoY2xpZW50LnRyYW5zcG9ydC50eXBlID09PSAiZmFsbGJhY2siICYmIGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0c1swXS5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0pKCk7CiAgICBjb25zdCBwb2xsQ29udHJhY3RFdmVudCA9ICgpID0+IHsKICAgICAgY29uc3Qgc3RyaWN0ID0gc3RyaWN0XyA/PyBmYWxzZTsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQ29udHJhY3RFdmVudCIsCiAgICAgICAgYWRkcmVzcywKICAgICAgICBhcmdzLAogICAgICAgIGJhdGNoLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZXZlbnROYW1lLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBzdHJpY3QsCiAgICAgICAgZnJvbUJsb2NrCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uTG9ncywgb25FcnJvciB9LCAoZW1pdCkgPT4gewogICAgICAgIGxldCBwcmV2aW91c0Jsb2NrTnVtYmVyOwogICAgICAgIGlmIChmcm9tQmxvY2sgIT09IHZvaWQgMCkKICAgICAgICAgIHByZXZpb3VzQmxvY2tOdW1iZXIgPSBmcm9tQmxvY2sgLSAxbjsKICAgICAgICBsZXQgZmlsdGVyOwogICAgICAgIGxldCBpbml0aWFsaXplZCA9IGZhbHNlOwogICAgICAgIGNvbnN0IHVud2F0Y2ggPSBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmICghaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBmaWx0ZXIgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyLCAiY3JlYXRlQ29udHJhY3RFdmVudEZpbHRlciIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciA8IGJsb2NrTnVtYmVyKSB7CiAgICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICAgIGZyb21CbG9jazogcHJldmlvdXNCbG9ja051bWJlciArIDFuLAogICAgICAgICAgICAgICAgICB0b0Jsb2NrOiBibG9ja051bWJlciwKICAgICAgICAgICAgICAgICAgc3RyaWN0CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUNvbnRyYWN0RXZlbnQgPSAoKSA9PiB7CiAgICAgIGNvbnN0IHN0cmljdCA9IHN0cmljdF8gPz8gZmFsc2U7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaENvbnRyYWN0RXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50TmFtZSwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgc3RyaWN0CiAgICAgIF0pOwogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgOwogICAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQgPSAoKCkgPT4gewogICAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHMuZmluZCgodHJhbnNwb3J0MykgPT4gdHJhbnNwb3J0My5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpOwogICAgICAgICAgICAgICAgaWYgKCF0cmFuc3BvcnQyKQogICAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIHJldHVybiB0cmFuc3BvcnQyLnZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgY29uc3QgdG9waWNzID0gZXZlbnROYW1lID8gZW5jb2RlRXZlbnRUb3BpY3MoewogICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgYXJncwogICAgICAgICAgICB9KSA6IFtdOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJsb2dzIiwgeyBhZGRyZXNzLCB0b3BpY3MgfV0sCiAgICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBjb25zdCBsb2cgPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgIGNvbnN0IHsgZXZlbnROYW1lOiBldmVudE5hbWUyLCBhcmdzOiBhcmdzMiB9ID0gZGVjb2RlRXZlbnRMb2coewogICAgICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgICB0b3BpY3M6IGxvZy50b3BpY3MsCiAgICAgICAgICAgICAgICAgICAgc3RyaWN0OiBzdHJpY3RfCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBjb25zdCBmb3JtYXR0ZWQgPSBmb3JtYXRMb2cobG9nLCB7CiAgICAgICAgICAgICAgICAgICAgYXJnczogYXJnczIsCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgICAgbGV0IGV2ZW50TmFtZTI7CiAgICAgICAgICAgICAgICAgIGxldCBpc1VubmFtZWQ7CiAgICAgICAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dEYXRhTWlzbWF0Y2ggfHwgZXJyIGluc3RhbmNlb2YgRGVjb2RlTG9nVG9waWNzTWlzbWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBldmVudE5hbWUyID0gZXJyLmFiaUl0ZW0ubmFtZTsKICAgICAgICAgICAgICAgICAgICBpc1VubmFtZWQgPSBlcnIuYWJpSXRlbS5pbnB1dHM/LnNvbWUoKHgpID0+ICEoIm5hbWUiIGluIHggJiYgeC5uYW1lKSk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgewogICAgICAgICAgICAgICAgICAgIGFyZ3M6IGlzVW5uYW1lZCA/IFtdIDoge30sCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAg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vbnMvd2FsbGV0L3NlbmRUcmFuc2FjdGlvbiIKICAgICAgfSk7CiAgICBjb25zdCBhY2NvdW50ID0gYWNjb3VudF8gPyBwYXJzZUFjY291bnQoYWNjb3VudF8pIDogbnVsbDsKICAgIHRyeSB7CiAgICAgIGFzc2VydFJlcXVlc3QocGFyYW1ldGVycyk7CiAgICAgIGNvbnN0IHRvID0gYXdhaXQgKGFzeW5jICgpID0+IHsKICAgICAgICBpZiAocGFyYW1ldGVycy50bykKICAgICAgICAgIHJldHVybiBwYXJhbWV0ZXJzLnRvOwogICAgICAgIGlmIChhdXRob3JpemF0aW9uTGlzdCAmJiBhdXRob3JpemF0aW9uTGlzdC5sZW5ndGggPiAwKQogICAgICAgICAgcmV0dXJuIGF3YWl0IHJlY292ZXJBdXRob3JpemF0aW9uQWRkcmVzcyh7CiAgICAgICAgICAgIGF1dGhvcml6YXRpb246IGF1dGhvcml6YXRpb25MaXN0WzBdCiAgICAgICAgICB9KS5jYXRjaCgoKSA9PiB7CiAgICAgICAgICAgIHRocm93IG5ldyBCYXNlRXJyb3IyKCJgdG9gIGlzIHJlcXVpcmVkLiBDb3VsZCBub3QgaW5mZXIgZnJvbSBgYXV0aG9yaXphdGlvbkxpc3RgLiIpOwogICAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgfSkoKTsKICAgICAgaWYgKGFjY291bnQ/LnR5cGUgPT09ICJqc29uLXJwYyIgfHwgYWNjb3VudCA9PT0gbnVsbCkgewogICAgICAgIGxldCBjaGFpbklkOwogICAgICAgIGlmIChjaGFpbiAhPT0gbnVsbCkgewogICAgICAgICAgY2hhaW5JZCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldENoYWluSWQsICJnZXRDaGFpbklkIikoe30pOwogICAgICAgICAgYXNzZXJ0Q3VycmVudENoYWluKHsKICAgICAgICAgICAgY3VycmVudENoYWluSWQ6IGNoYWluSWQsCiAgICAgICAgICAgIGNoYWluCiAgICAgICAgICB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wKICAgICAgICAgICAgcGFyYW1zOiBbcmVxdWVzdF0KICAgICAgICAgIH0sIHsgcmV0cnlDb3VudDogMCB9KTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgICAgICBpZiAoZXJyb3IubmFtZSA9PT0gIkludmFsaWRJbnB1dFJwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiTWV0aG9kTm90Rm91bmRScGNFcnJvciIgfHwgZXJyb3IubmFtZSA9PT0gIk1ldGhvZE5vdFN1cHBvcnRlZFJwY0Vycm9yIikKICAgICAgICAgICAgcmV0dXJuIGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBtZXRob2Q6ICJ3YWxsZXRfc2VuZFRyYW5zYWN0aW9uIiwKICAgICAgICAgICAgICBwYXJhbXM6IFtyZXF1ZXN0XQogICAgICAgICAgICB9LCB7IHJldHJ5Q291bnQ6IDAgfSkudGhlbigoaGFzaDMpID0+IHsKICAgICAgICAgICAgICBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5zZXQoY2xpZW50LnVpZCwgdHJ1ZSk7CiAgICAgICAgICAgICAgcmV0dXJuIGhhc2gzOwogICAgICAgICAgICB9KTsKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gImxvY2FsIikgewogICAgICAgIGNvbnN0IHJlcXVlc3QgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBwcmVwYXJlVHJhbnNhY3Rpb25SZXF1ZXN0LCAicHJlcGFyZVRyYW5zYWN0aW9uUmVxdWVzdCIpKHsKICAgICAgICAgIGFjY291bnQsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3QsCiAgICAgICAgICBibG9icywKICAgICAgICAgIGNoYWluLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGdhcywKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgbWF4RmVlUGVyQmxvYkdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBub25jZU1hbmFnZXI6IGFjY291bnQubm9uY2VNYW5hZ2VyLAogICAgICAgICAgcGFyYW1ldGVyczogWy4uLmRlZmF1bHRQYXJhbWV0ZXJzLCAic2lkZWNhcnMiXSwKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgLi4ucmVzdCwKICAgICAgICAgIHRvCiAgICAgICAgfSk7CiAgICAgICAgY29uc3Qgc2VyaWFsaXplciA9IGNoYWluPy5zZXJpYWxpemVycz8udHJhbnNhY3Rpb247CiAgICAgICAgY29uc3Qgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gYXdhaXQgYWNjb3VudC5zaWduVHJhbnNhY3Rpb24ocmVxdWVzdCwgewogICAgICAgICAgc2VyaWFsaXplcgogICAgICAgIH0pOwogICAgICAgIHJldHVybiBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBzZW5kUmF3VHJhbnNhY3Rpb24sICJzZW5kUmF3VHJhbnNhY3Rpb24iKSh7CiAgICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24KICAgICAgICB9KTsKICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gInNtYXJ0IikKICAgICAgICB0aHJvdyBuZXcgQWNjb3VudFR5cGVOb3RTdXBwb3J0ZWRFcnJvcih7CiAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgIkNvbnNpZGVyIHVzaW5nIHRoZSBgc2VuZFVzZXJPcGVyYXRpb25gIEFjdGlvbiBpbnN0ZWFkLiIKICAgICAgICAgIF0sCiAgICAgICAgICBkb2NzUGF0aDogIi9kb2NzL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hhc1dyaXRlRnVuY3Rpb24gPSB0cnVlOwogICAgICBlbHNlIGlmIChpdGVtLnR5cGUgPT09ICJldmVudCIpCiAgICAgICAgaGFzRXZlbnQgPSB0cnVlOwogICAgICBpZiAoaGFzUmVhZEZ1bmN0aW9uICYmIGhhc1dyaXRlRnVuY3Rpb24gJiYgaGFzRXZlbnQpCiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBpZiAoaGFzUHVibGljQ2xpZW50KSB7CiAgICAgIGlmIChoYXNSZWFkRnVuY3Rpb24pCiAgICAgICAgY29udHJhY3QucmVhZCA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgcmVhZENvbnRyYWN0LCAicmVhZENvbnRyYWN0IikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGZ1bmN0aW9uTmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LnNpbXVsYXRlID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCBzaW11bGF0ZUNvbnRyYWN0LCAic2ltdWxhdGVDb250cmFjdCIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBmdW5jdGlvbk5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICBpZiAoaGFzRXZlbnQpIHsKICAgICAgICBjb250cmFjdC5jcmVhdGVFdmVudEZpbHRlciA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGV2ZW50TmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCBhYmlFdmVudCA9IGFiaTIuZmluZCgoeCkgPT4geC50eXBlID09PSAiZXZlbnQiICYmIHgubmFtZSA9PT0gZXZlbnROYW1lKTsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEV2ZW50UGFyYW1ldGVycyhwYXJhbWV0ZXJzLCBhYmlFdmVudCk7CiAgICAgICAgICAgICAgcmV0dXJuIGdldEFjdGlvbihwdWJsaWNDbGllbnQsIGNyZWF0ZUNvbnRyYWN0RXZlbnRGaWx0ZXIsICJjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyIikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgY29udHJhY3QuZ2V0RXZlbnRzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZXZlbnROYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IGFiaUV2ZW50ID0gYWJpMi5maW5kKCh4KSA9PiB4LnR5cGUgPT09ICJldmVudCIgJiYgeC5uYW1lID09PSBldmVudE5hbWUpOwogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RXZlbnRQYXJhbWV0ZXJzKHBhcmFtZXRlcnMsIGFiaUV2ZW50KTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIGNvbnRyYWN0LndhdGNoRXZlbnQgPSBuZXcgUHJveHkoe30sIHsKICAgICAgICAgIGdldChfLCBldmVudE5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuICguLi5wYXJhbWV0ZXJzKSA9PiB7CiAgICAgICAgICAgICAgY29uc3QgYWJpRXZlbnQgPSBhYmkyLmZpbmQoKHgpID0+IHgudHlwZSA9PT0gImV2ZW50IiAmJiB4Lm5hbWUgPT09IGV2ZW50TmFtZSk7CiAgICAgICAgICAgICAgY29uc3QgeyBhcmdzLCBvcHRpb25zIH0gPSBnZXRFdmVudFBhcmFtZXRlcnMocGFyYW1ldGVycywgYWJpRXZlbnQpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCB3YXRjaENvbnRyYWN0RXZlbnQsICJ3YXRjaENvbnRyYWN0RXZlbnQiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfQogICAgfQogICAgaWYgKGhhc1dhbGxldENsaWVudCkgewogICAgICBpZiAoaGFzV3JpdGVGdW5jdGlvbikKICAgICAgICBjb250cmFjdC53cml0ZSA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHdhbGxldENsaWVudCwgd3JpdGVDb250cmFjdCwgIndyaXRlQ29udHJhY3QiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGlmIChoYXNQdWJsaWNDbGllbnQgfHwgaGFzV2FsbGV0Q2xpZW50KSB7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LmVzdGltYXRlR2FzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIGNvbnN0IGNsaWVudDIgPSBwdWJsaWNDbGllbnQgPz8gd2FsbGV0Q2xpZW50OwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24oY2xpZW50MiwgZXN0aW1hdGVDb250cmFjdEdhcywgImVzdGltYXRlQ29udHJhY3RHYXMiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMsCiAgICAgICAgICAgICAgICBhY2NvdW50OiBvcHRpb25zLmFjY291bnQgPz8gd2FsbGV0Q2xpZW50LmFjY291bnQKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGNvbnRyYWN0LmFkZHJlc3MgPSBhZGRyZXNzOwogICAgY29udHJhY3QuYWJpID0gYWJpMjsKICAgIHJldHVybiBjb250cmFjdDsKICB9CiAgZnVuY3Rpb24gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHZhbHVlcykgewogICAgY29uc3QgaGFzQXJncyA9IHZhbHVlcy5sZW5ndGggJiYgQXJyYXkuaXNBcnJheSh2YWx1ZXNbMF0pOwogICAgY29uc3QgYXJncyA9IGhhc0FyZ3MgPyB2YWx1ZXNbMF0gOiBbXTsKICAg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IHZlcnNpb246IHZlcnNpb24zLAogICAgICAgICAgY2hhaW5JZDogTnVtYmVyKGNoYWluSWQpLAogICAgICAgICAgdmVyaWZ5aW5nQ29udHJhY3QsCiAgICAgICAgICBzYWx0CiAgICAgICAgfSwKICAgICAgICBleHRlbnNpb25zLAogICAgICAgIGZpZWxkcwogICAgICB9OwogICAgfSBjYXRjaCAoZSkgewogICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgIGlmIChlcnJvci5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvbkV4ZWN1dGlvbkVycm9yIiAmJiBlcnJvci5jYXVzZS5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvblplcm9EYXRhRXJyb3IiKSB7CiAgICAgICAgdGhyb3cgbmV3IEVpcDcxMkRvbWFpbk5vdEZvdW5kRXJyb3IoeyBhZGRyZXNzIH0pOwogICAgICB9CiAgICAgIHRocm93IGVycm9yOwogICAgfQogIH0KICB2YXIgYWJpID0gWwogICAgewogICAgICBpbnB1dHM6IFtdLAogICAgICBuYW1lOiAiZWlwNzEyRG9tYWluIiwKICAgICAgb3V0cHV0czogWwogICAgICAgIHsgbmFtZTogImZpZWxkcyIsIHR5cGU6ICJieXRlczEiIH0sCiAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAidmVyc2lvbiIsIHR5cGU6ICJzdHJpbmciIH0sCiAgICAgICAgeyBuYW1lOiAiY2hhaW5JZCIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgIHsgbmFtZTogInZlcmlmeWluZ0NvbnRyYWN0IiwgdHlwZTogImFkZHJlc3MiIH0sCiAgICAgICAgeyBuYW1lOiAic2FsdCIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgIHsgbmFtZTogImV4dGVuc2lvbnMiLCB0eXBlOiAidWludDI1NltdIiB9CiAgICAgIF0sCiAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogIC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yYW1ldGVycy50cmFuc3BvcnQoewogICAgICBjaGFpbiwKICAgICAgcG9sbGluZ0ludGVydmFsCiAgICB9KTsKICAgIGNvbnN0IHRyYW5zcG9ydCA9IHsgLi4uY29uZmlnLCAuLi52YWx1ZSB9OwogICAgY29uc3QgY2xpZW50ID0gewogICAgICBhY2NvdW50LAogICAgICBiYXRjaCwKICAgICAgY2FjaGVUaW1lLAogICAgICBjY2lwUmVhZCwKICAgICAgY2hhaW4sCiAgICAgIGtleSwKICAgICAgbmFtZSwKICAgICAgcG9sbGluZ0ludGVydmFsLAogICAgICByZXF1ZXN0LAogICAgICB0cmFuc3BvcnQsCiAgICAgIHR5cGUsCiAgICAgIHVpZDogdWlkKCkKICAgIH07CiAgICBmdW5jdGlvbiBleHRlbmQoYmFzZTIpIHsKICAgICAgcmV0dXJuIChleHRlbmRGbikgPT4gewogICAgICAgIGNvbnN0IGV4dGVuZGVkID0gZXh0ZW5kRm4oYmFzZTIpOwogICAgICAgIGZvciAoY29uc3Qga2V5MiBpbiBjbGllbnQpCiAgICAgICAgICBkZWxldGUgZXh0ZW5kZWRba2V5Ml07CiAgICAgICAgY29uc3QgY29tYmluZWQgPSB7IC4uLmJhc2UyLCAuLi5leHRlbmRlZCB9OwogICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNvbWJpbmVkLCB7IGV4dGVuZDogZXh0ZW5kKGNvbWJpbmVkKSB9KTsKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBPYmplY3QuYXNzaWduKGNsaWVudCwgeyBleHRlbmQ6IGV4dGVuZChjbGllbnQpIH0pOwogIH0KICBmdW5jdGlvbiBycGNTY2hlbWEoKSB7CiAgICByZXR1cm4gbnVsbDsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9idWlsZFJlcXVlc3QuanMKICBpbml0X2Jhc2UoKTsKICBpbml0X3JlcXVlc3QoKT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AgIC4uLm92ZXJyaWRlT3B0aW9ucwogICAgICB9OwogICAgICBjb25zdCByZXF1ZXN0SWQgPSBkZWR1cGUgPyBrZWNjYWsyNTYoc3RyaW5nVG9IZXgoYCR7dWlkMn0uJHtzdHJpbmdpZnkoYXJncyl9YCkpIDogdm9pZCAwOwogICAgICByZXR1cm4gd2l0aERlZHVwZSgoKSA9PiB3aXRoUmV0cnkoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICByZXR1cm4gYXdhaXQgcmVxdWVzdChhcmdzKTsKICAgICAgICB9IGNhdGNoIChlcnJfKSB7CiAgICAgICAgICBjb25zdCBlcnIgPSBlcnJfOwogICAgICAgICAgc3dpdGNoIChlcnIuY29kZSkgewogICAgICAgICAgICAvLyAtMzI3MDAKICAgICAgICAgICAgY2FzZSBQYXJzZVJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFBhcnNlUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyNjAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFJlcXVlc3RScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBJbnZhbGlkUmVxdWVzdFJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjYwMQogICAgICAgICAgICBjYXNlIE1ldGhvZE5vdEZvdW5kUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90Rm91bmRScGNFcnJvcihlcnIsIHsgbWV0aG9kOiBhcmdzLm1ldGhvZCB9KTsKICAgICAgICAgICAgLy8gLTMyNjAyCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFBhcmFtc1JwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRQYXJhbXNScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzI2MDMKICAgICAgICAgICAgY2FzZSBJbnRlcm5hbFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludGVybmFsUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZElucHV0UnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZElucHV0UnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAxCiAgICAgICAgICAgIGNhc2UgUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFJlc291cmNlTm90Rm91bmRScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzIwMDIKICAgICAgICAgICAgY2FzZSBSZXNvdXJjZVVuYXZhaWxhYmxlUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgUmVzb3VyY2VVbmF2YWlsYWJsZVJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjAwMwogICAgICAgICAgICBjYXNlIFRyYW5zYWN0aW9uUmVqZWN0ZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA0CiAgICAgICAgICAgIGNhc2UgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IoZXJyLCB7CiAgICAgICAgICAgICAgICBtZXRob2Q6IGFyZ3MubWV0aG9kCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIC8vIC0zMjAwNQogICAgICAgICAgICBjYXNlIExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBMaW1pdEV4Y2VlZGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA2CiAgICAgICAgICAgIGNhc2UgSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpzb25ScGNWZXJzaW9uVW5zdXBwb3J0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MDAxCiAgICAgICAgICAgIGNhc2UgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFVzZXJSZWplY3RlZFJlcXVlc3RFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MTAwCiAgICAgICAgICAgIGNhc2UgVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBVbmF1dGhvcml6ZWRQcm92aWRlckVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQyMDAKICAgICAgICAgICAgY2FzZSBVbnN1cHBvcnRlZFByb3ZpZGVyTWV0aG9kRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRQcm92aWRlck1ldGhvZEVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQ5MDAKICAgICAgICAgICAgY2FzZSBQcm92aWRlckRpc2Nvbm5lY3RlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gNDkwMQogICAgICAgICAgICBjYXNlIENoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2hhaW5EaXNjb25uZWN0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0OTAyCiAgICAgICAgICAgIGNhc2UgU3dpdGNoQ2hhaW5FcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBTd2l0Y2hDaGFpbkVycm9yKGVycik7CiAgICAgICAgICAgIC8vIENBSVAtMjU6IFVzZXIgUmVqZWN0ZWQgRXJyb3IKICAgICAgICAgICAgLy8gaHR0cHM6Ly9kb2NzLndhbGxldGNvbm5lY3QuY29tLzIuMC9zcGVjcy9jbGllbnRzL3NpZ24vZXJyb3ItY29kZXMjcmVqZWN0ZWQtY2FpcC0yNQogICAgICAgICAgICBjYXNlIDVlMzoKICAgICAgICAgICAgICB0aHJvdyBuZXcgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yKGVycik7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGVycl8gaW5zdGFuY2VvZiBCYXNlRXJyb3IyKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyXzsKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5rbm93blJwY0Vycm9yKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9LCB7CiAgICAgICAgZGVsYXk6ICh7IGNvdW50LCBlcnJvciB9KSA9PiB7CiAgICAgICAgICBpZiAoZXJyb3IgJiYgZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yKSB7CiAgICAgICAgICAgIGNvbnN0IHJldHJ5QWZ0ZXIgPSBlcnJvcj8uaGVhZGVycz8uZ2V0KCJSZXRyeS1BZnRlciIpOwogICAgICAgICAgICBpZiAocmV0cnlBZnRlcj8ubWF0Y2goL1xkLykpCiAgICAgICAgICAgICAgcmV0dXJuIE51bWJlci5wYXJzZUludChyZXRyeUFmdGVyKSAqIDFlMzsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB+figxIDw8IGNvdW50KSAqIHJldHJ5RGVsYXk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHNob3VsZFJldHJ5OiAoeyBlcnJvciB9KSA9PiBzaG91bGRSZXRyeShlcnJvcikKICAgICAgfSksIHsgZW5hYmxlZDogZGVkdXBlLCBpZDogcmVxdWVzdElkIH0pOwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkUmV0cnkoZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSAtMSkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLmNvZGUgPT09IExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3IuY29kZSA9PT0gSW50ZXJuYWxScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yICYmIGVycm9yLnN0YXR1cykgewogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDQwOCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNDEzKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MjkpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwMCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNTAyKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA1MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwNCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQog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JlcXVlc3QuYmluZChwcm92aWRlciksCiAgICAgIHJldHJ5Q291bnQ6IGNvbmZpZy5yZXRyeUNvdW50ID8/IGRlZmF1bHRSZXRyeUNvdW50LAogICAgICByZXRyeURlbGF5LAogICAgICB0eXBlOiAiY3VzdG9tIgogICAgfSk7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2xpZW50cy90cmFuc3BvcnRzL2ZhbGxiYWNrLmpzCiAgaW5pdF9ycGMoKTsKICBmdW5jdGlvbiBmYWxsYmFjayh0cmFuc3BvcnRzXywgY29uZmlnID0ge30pIHsKICAgIGNvbnN0IHsga2V5ID0gImZhbGxiYWNrIiwgbmFtZSA9ICJGYWxsYmFjayIsIHJhbmsgPSBmYWxzZSwgcmV0cnlDb3VudCwgcmV0cnlEZWxheSB9ID0gY29uZmlnOwogICAgcmV0dXJuICh7IGNoYWluLCBwb2xsaW5nSW50ZXJ2YWwgPSA0ZTMsIHRpbWVvdXQsIC4uLnJlc3QgfSkgPT4gewogICAgICBsZXQgdHJhbnNwb3J0cyA9IHRyYW5zcG9ydHNfOwogICAgICBsZXQgb25SZXNwb25zZSA9ICgpID0+IHsKICAgICAgfTsKICAgICAgY29uc3QgdHJhbnNwb3J0ID0gY3JlYXRlVHJhbnNwb3J0KHsKICAgICAgICBrZXksCiAgICAgICAgbmFtZSwKICAgICAgICBhc3luYyByZXF1ZXN0KHsgbWV0aG9kLCBwYXJhbXMgfSkgewogICAgICAgICAgY29uc3QgZmV0Y2gyID0gYXN5bmMgKGkgPSAwKSA9PiB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSB0cmFuc3BvcnRzW2ldKHsKICAgICAgICAgICAgICAuLi5yZXN0LAogICAgICAgICAgICAgIGNoYWluLAogICAgICAgICAgICAgIHJldHJ5Q291bnQ6IDAsCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IHRyYW5zcG9ydDIucmVxdWVzdCh7CiAgICAgICAgICAgICAgICBtZXRob2QsCiAgICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBvblJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHJlc3BvbnNlLAogICAgICAgICAgICAgICAgdHJhbnNwb3J0OiB0cmFuc3BvcnQyLAogICAgICAgICAgICAgICAgc3RhdHVzOiAic3VjY2VzcyIKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIG9uUmVzcG9uc2UoewogICAgICAgICAgICAgICAgZXJyb3I6IGVyciwKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHRyYW5zcG9ydDogdHJhbnNwb3J0MiwKICAgICAgICAgICAgICAgIHN0YXR1czogImVycm9yIgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChzaG91bGRUaHJvdyhlcnIpKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgICAgIGlmIChpID09PSB0cmFuc3BvcnRzLmxlbmd0aCAtIDEpCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgcmV0dXJuIGZldGNoMihpICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH07CiAgICAgICAgICByZXR1cm4gZmV0Y2gyKCk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHJldHJ5RGVsYXksCiAgICAgICAgdHlwZTogImZhbGxiYWNrIgogICAgICB9LCB7CiAgICAgICAgb25SZXNwb25zZTogKGZuKSA9PiBvblJlc3BvbnNlID0gZm4sCiAgICAgICAgdHJhbnNwb3J0czogdHJhbnNwb3J0cy5tYXAoKGZuKSA9PiBmbih7IGNoYWluLCByZXRyeUNvdW50OiAwIH0pKQogICAgICB9KTsKICAgICAgaWYgKHJhbmspIHsKICAgICAgICBjb25zdCByYW5rT3B0aW9ucyA9IHR5cGVvZiByYW5rID09PSAib2JqZWN0IiA/IHJhbmsgOiB7fTsKICAgICAgICByYW5rVHJhbnNwb3J0cyh7CiAgICAgICAgICBjaGFpbiwKICAgICAgICAgIGludGVydmFsOiByYW5rT3B0aW9ucy5pbnRlcnZhbCA/PyBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgICBvblRyYW5zcG9ydHM6ICh0cmFuc3BvcnRzXzIpID0+IHRyYW5zcG9ydHMgPSB0cmFuc3BvcnRzXzIsCiAgICAgICAgICBzYW1wbGVDb3VudDogcmFua09wdGlvbnMuc2FtcGxlQ291bnQsCiAgICAgICAgICB0aW1lb3V0OiByYW5rT3B0aW9ucy50aW1lb3V0LAogICAgICAgICAgdHJhbnNwb3J0cywKICAgICAgICAgIHdlaWdodHM6IHJhbmtPcHRpb25zLndlaWdodHMKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm4gdHJhbnNwb3J0OwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkVGhyb3coZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IuY29kZSB8fCBlcnJvci5jb2RlID09PSBVc2VyUmVqZWN0ZWRSZXF1ZXN0RXJyb3IuY29kZSB8fCBlcnJvci5jb2RlID09PSA1ZTMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gZmFsc2U7CiAgfQog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9fZXNtL3V0aWxzL3JwYy9odHRwLmpzCiAgaW5pdF9yZXF1ZXN0KCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9wcm9taXNlL3dpdGhUaW1lb3V0LmpzCiAgZnVuY3Rpb24gd2l0aFRpbWVvdXQoZm4sIHsgZXJyb3JJbnN0YW5jZSA9IG5ldyBFcnJvcigidGltZWQgb3V0IiksIHRpbWVvdXQsIHNpZ25hbCB9KSB7CiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICA7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgbGV0IHRpbWVvdXRJZDsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgY29udHJvbGxlciA9IG5ldyBBYm9ydENvbnRyb2xsZXIoKTsKICAgICAgICAgIGlmICh0aW1lb3V0ID4gMCkgewogICAgICAgICAgICB0aW1lb3V0SWQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgICAgICBjb250cm9sbGVyLmFib3J0KCk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJlamVjdChlcnJvckluc3RhbmNlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sIHRpbWVvdXQpOwogICAgICAgICAgfQogICAgICAgICAgcmVzb2x2ZShhd2FpdCBmbih7IHNpZ25hbDogY29udHJvbGxlcj8uc2lnbmFsIHx8IG51bGwgfSkpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVycj8ubmFtZSA9PT0gIkFib3J0RXJyb3IiKQogICAgICAgICAgICByZWplY3QoZXJyb3JJbnN0YW5jZSk7CiAgICAgICAgICByZWplY3QoZXJyKTsKICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgY2xl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C4uLnBhcmFtcy5mZXRjaE9wdGlvbnMgPz8ge30KICAgICAgICB9OwogICAgICAgIGNvbnN0IHsgaGVhZGVycywgbWV0aG9kLCBzaWduYWw6IHNpZ25hbF8gfSA9IGZldGNoT3B0aW9uczsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB3aXRoVGltZW91dChhc3luYyAoeyBzaWduYWwgfSkgPT4gewogICAgICAgICAgICBjb25zdCBpbml0ID0gewogICAgICAgICAgICAgIC4uLmZldGNoT3B0aW9ucywKICAgICAgICAgICAgICBib2R5OiBBcnJheS5pc0FycmF5KGJvZHkpID8gc3RyaW5naWZ5KGJvZHkubWFwKChib2R5MikgPT4gKHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkyLmlkID8/IGlkQ2FjaGUudGFrZSgpLAogICAgICAgICAgICAgICAgLi4uYm9keTIKICAgICAgICAgICAgICB9KSkpIDogc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkuaWQgPz8gaWRDYWNoZS50YWtlKCksCiAgICAgICAgICAgICAgICAuLi5ib2R5CiAgICAgICAgICAgICAgfSksCiAgICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICAgIkNvbnRlbnQtVHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgICAgIC4uLmhlYWRlcnMKICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgIG1ldGhvZDogbWV0aG9kIHx8ICJQT1NUIiwKICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbF8gfHwgKHRpbWVvdXQgPiAwID8gc2lnbmFsIDogbnVsbCkKICAgICAgICAgICAgfTsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdCA9IG5ldyBSZXF1ZXN0KHVybCwgaW5pdCk7CiAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhd2FpdCBvblJlcXVlc3Q/LihyZXF1ZXN0LCBpbml0KSA/PyB7IC4uLmluaXQsIHVybCB9OwogICAgICAgICAgICBjb25zdCByZXNwb25zZTIgPSBhd2FpdCBmZXRjaChhcmdzLnVybCA/PyB1cmwsIGFyZ3MpOwogICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UyOwogICAgICAgICAgfSwgewogICAgICAgICAgICBlcnJvckluc3RhbmNlOiBuZXcgVGltZW91dEVycm9yKHsgYm9keSwgdXJsIH0pLAogICAgICAgICAgICB0aW1lb3V0LAogICAgICAgICAgICBzaWduYWw6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKG9uUmVzcG9uc2UpCiAgICAgICAgICAgIGF3YWl0IG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpCiAgICAgICAgICAgIGRhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgZGF0YSA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBkYXRhID0gSlNPTi5wYXJzZShkYXRhIHx8ICJ7fSIpOwogICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uub2spCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgZGF0YSA9IHsgZXJyb3I6IGRhdGEgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICB0aHJvdyBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBkZXRhaWxzOiBzdHJpbmdpZnkoZGF0YS5lcnJvcikgfHwgcmVzcG9uc2Uuc3RhdHVzVGV4dCwKICAgICAgICAgICAgICBoZWFkZXJzOiByZXNwb25zZS5oZWFkZXJzLAogICAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICAgIHVybAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBkYXRhOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIEh0dHBSZXF1ZXN0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBUaW1lb3V0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIHRocm93IG5ldyBIdHRwUmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgY2F1c2U6IGVyciwKICAgICAgICAgICAgdXJsCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2xpZW50cy90cmFuc3BvcnRzL2h0dHAuanMKICBmdW5jdGlvbiBodHRwKHVybCwgY29uZmlnID0ge30pIHsKICAgIGNvbnN0IHsgYmF0Y2gsIGZldGNoT3B0aW9ucywga2V5ID0gImh0dHAiLCBuYW1lID0gIkhUVFAgSlNPTi1SUEMiLCBvbkZldGNoUmVxdWVzdCwgb25GZXRjaFJlc3BvbnNlLCByZXRyeURlbGF5IH0gPSBjb25maWc7CiAgICByZXR1cm4gKHsgY2hhaW4sIHJldHJ5Q291bnQ6IHJldHJ5Q291bnRfLCB0aW1lb3V0OiB0aW1lb3V0XyB9KSA9PiB7CiAgICAgIGNvbnN0IHsgYmF0Y2hTaXplID0gMWUzLCB3YWl0OiB3YWl0MiA9IDAgfSA9IHR5cGVvZiBiYXRjaCA9PT0gIm9iamVjdCIgPyBiYXRjaCA6IHt9OwogICAgICBjb25zdCByZXRyeUNvdW50ID0gY29uZmlnLnJldHJ5Q291bnQgPz8gcmV0cnlDb3VudF87CiAgICAgIGNvbnN0IHRpbWVvdXQgPSB0aW1lb3V0XyA/PyBjb25maWcudGltZW91dCA/PyAxZTQ7CiAgICAgIGNvbnN0IHVybF8gPSB1cmwgfHwgY2hhaW4/LnJwY1VybHMuZGVmYXVsdC5odHRwWzBdOwogICAgICBpZiAoIXVybF8pCiAgICAgICAgdGhyb3cgbmV3IFVybFJlcXVpcmVkRXJyb3IoKTsKICAgICAgY29uc3QgcnBjQ2xpZW50ID0gZ2V0SHR0cFJwY0NsaWVudCh1cmxfLCB7CiAgICAgICAgZmV0Y2hPcHRpb25zLAogICAgICAgIG9uUmVxdWVzdDogb25GZXRjaFJlcXVlc3QsCiAgICAgICAgb25SZXNwb25zZTogb25GZXRjaFJlc3BvbnNlLAogICAgICAgIHRpbWVvdXQKICAgICAgfSk7CiAgICAgIHJldHVybiBjcmVhdGVUcmFuc3BvcnQoewogICAgICAgIGtleSwKICAgICAgICBuYW1lLAogICAgICAgIGFzeW5jIHJlcXVlc3QoeyBtZXRob2QsIHBhcmFtcyB9KSB7CiAgICAgICAgICBjb25zdCBib2R5ID0geyBtZXRob2QsIHBhcmFtcyB9OwogICAgICAgICAgY29uc3QgeyBzY2hlZHVsZSB9ID0gY3JlYXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICAgICAgICBpZDogdXJsXywKICAgICAgICAgICAgd2FpdDogd2FpdDIsCiAgICAgICAgICAgIHNob3VsZFNwbGl0QmF0Y2gocmVxdWVzdHMpIHsKICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdHMubGVuZ3RoID4gYmF0Y2hTaXplOwogICAgICAgICAgICB9LAogICAgICAgICAgICBmbjogKGJvZHkyKSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgICAgYm9keTogYm9keTIKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNvcnQ6IChhLCBiKSA9PiBhLmlkIC0gYi5pZAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCBmbiA9IGFzeW5jIChib2R5MikgPT4gYmF0Y2ggPyBzY2hlZHVsZShib2R5MikgOiBbCiAgICAgICAgICAgIGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBib2R5OiBib2R5MgogICAgICAgICAgICB9KQogICAgICAgICAgXTsKICAgICAgICAgIGNvbnN0IFt7IGVycm9yLCByZXN1bHQgfV0gPSBhd2FpdCBmbihib2R5KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogImh0dHAiCiAgICAgIH0sIHsKICAgICAgICBmZXRjaE9wdGlvbnMsCiAgICAgICAgdXJsOiB1cmxfCiAgICAgIH0pOwogICAgfTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3Rpb25zL2Vucy9nZXRFbnNBZGRyZXNzLmpzCiAgaW5pdF9hYmlzKCk7CiAgaW5pdF9kZWNvZGVGdW5jdGlvblJlc3VsdCgpOwogIGluaXRfZW5jb2RlRnVuY3Rpb25EYXRhKCk7CiAgaW5pdF9nZXRDaGFpbkNvbnRyYWN0QWRkcmVzcygpOwogIGluaX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JhbWV0ZXJzLmFyZ3MsIGdhdGV3YXlVcmxzXQogICAgICB9KSA6IGF3YWl0IHJlYWRDb250cmFjdEFjdGlvbihyZWFkQ29udHJhY3RQYXJhbWV0ZXJzKTsKICAgICAgaWYgKHJlc1swXSA9PT0gIjB4IikKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgY29uc3QgYWRkcmVzcyA9IGRlY29kZUZ1bmN0aW9uUmVzdWx0KHsKICAgICAgICBhYmk6IGFkZHJlc3NSZXNvbHZlckFiaSwKICAgICAgICBhcmdzOiBjb2luVHlwZSAhPSBudWxsID8gW25hbWVoYXNoKG5hbWUpLCBCaWdJbnQoY29pblR5cGUpXSA6IHZvaWQgMCwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJhZGRyIiwKICAgICAgICBkYXRhOiByZXNbMF0KICAgICAgfSk7CiAgICAgIGlmIChhZGRyZXNzID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBpZiAodHJpbShhZGRyZXNzKSA9PT0gIjB4MDAiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gYWRkcmVzczsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICBpZiAoc3RyaWN0KQogICAgICAgIHRocm93IGVycjsKICAgICAgaWYgKGlzTnVsbFVuaXZlcnNhbFJlc29sdmVyRXJyb3IoZXJyLCAicmVzb2x2ZSIpKQogICAgICAgIHJldHVybiBudWxsOwogICAgICB0aHJvdyBlcnI7CiAgICB9CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL2Vucy5qcwogIGluaXRfYmFzZSgpOwogIHZhciBFbnNBdmF0YXJJbnZhbGlkTWV0YWRhdGFFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICBjb25zdHJ1Y3Rvcih7IGRhdGEgfSkgewogICAgICBzdXBlcigiVW5hYmxlIHRvI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IoeyByZWFzb246ICJDaGFpbiBJRCBub3QgZm91bmQiIH0pOwogICAgaWYgKCFjb250cmFjdEFkZHJlc3MpCiAgICAgIHRocm93IG5ldyBFbnNBdmF0YXJJbnZhbGlkTmZ0VXJpRXJyb3IoewogICAgICAgIHJlYXNvbjogIkNvbnRyYWN0IGFkZHJlc3Mgbm90IGZvdW5kIgogICAgICB9KTsKICAgIGlmICghdG9rZW5JRCkKICAgICAgdGhyb3cgbmV3IEVuc0F2YXRhckludmFsaWROZnRVcmlFcnJvcih7IHJlYXNvbjogIlRva2VuIElEIG5vdCBmb3VuZCIgfSk7CiAgICBpZiAoIWVyY19uYW1lc3BhY2UpCiAgICAgIHRocm93IG5ldyBFbnNBdmF0YXJJbnZhbGlkTmZ0VXJpRXJyb3IoeyByZWFzb246ICJFUkMgbmFtZXNwYWNlIG5vdCBmb3VuZCIgfSk7CiAgICByZXR1cm4gewogICAgICBjaGFpbklEOiBOdW1iZXIucGFyc2VJbnQoY2hhaW5JRCksCiAgICAgIG5hbWVzcGFjZTogZXJjX25hbWVzcGFjZS50b0xvd2VyQ2FzZSgpLAogICAgICBjb250cmFjdEFkZHJlc3MsCiAgICAgIHRva2VuSUQKICAgIH07CiAgfQogIGFzeW5jIGZ1bmN0aW9uIGdldE5mdFRva2VuVXJpKGNsaWVudCwgeyBuZnQgfSkgewogICAgaWYgKG5mdC5uYW1lc3BhY2UgPT09ICJlcmM3MjEiKSB7CiAgICAgIHJldHVybiByZWFkQ29udHJhY3QoY2xpZW50LCB7CiAgICAgICAgYWRkcmVzczogbmZ0LmNvbnRyYWN0QWRkcmVzcywKICAgICAgICBhYmk6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInRva2VuVVJJIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogInRva2VuSWQiLCB0eXBlOiAidWludDI1NiIgfV0sCiAgICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgICAgfQogICAgICAgIF0sCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidG9rZW5VUkkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIGlmIChuZnQubmFtZXNwYWNlID09PSAiZXJjMTE1NSIpIHsKICAgICAgcmV0dXJuIHJlYWRDb250cmFjdChjbGllbnQsIHsKICAgICAgICBhZGRyZXNzOiBuZnQuY29udHJhY3RBZGRyZXNzLAogICAgICAgIGFiaTogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAidXJpIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIl9pZCIsIHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJzdHJpbmciIH1dCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBmdW5jdGlvbk5hbWU6ICJ1cmkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBFbnNBdmF0YXJVbnN1cHBvcnRlZE5hbWVzcGFjZUVycm9yKHsgbmFtZXNwYWNlOiBuZnQubmFtZXNwYWNlIH0pOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL2Vucy9hdmF0YXIvcGFyc2VBdmF0YXJSZWNvcmQuanMKICBhc3luYyBmdW5jdGlvbiBwYXJzZUF2YXRhclJlY29yZChjbGllbnQsIHsgZ2F0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QWRkcmVzcyA9IHVuaXZlcnNhbFJlc29sdmVyQWRkcmVzc187CiAgICBpZiAoIXVuaXZlcnNhbFJlc29sdmVyQWRkcmVzcykgewogICAgICBpZiAoIWNsaWVudC5jaGFpbikKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImNsaWVudCBjaGFpbiBub3QgY29uZmlndXJlZC4gdW5pdmVyc2FsUmVzb2x2ZXJBZGRyZXNzIGlzIHJlcXVpcmVkLiIpOwogICAgICB1bml2ZXJzYWxSZXNvbHZlckFkZHJlc3MgPSBnZXRDaGFpbkNvbnRyYWN0QWRkcmVzcyh7CiAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbiwKICAgICAgICBjb250cmFjdDogImVuc1VuaXZlcnNhbFJlc29sdmVyIgogICAgICB9KTsKICAgIH0KICAgIHRyeSB7CiAgICAgIGNvbnN0IHJlYWRDb250cmFjdFBhcmFtZXRlcnMgPSB7CiAgICAgICAgYWRkcmVzczogdW5pdmVyc2FsUmVzb2x2ZXJBZGRyZXNzLAogICAgICAgIGFiaTogdW5pdmVyc2FsUmVzb2x2ZXJSZXNvbHZlQWJpLAogICAgICAgIGZ1bmN0aW9uTmFtZTogInJlc29sdmUiLAogICAgICAgIGFyZ3M6IFsKICAgICAgICAgIHRvSGV4KHBhY2tldFRvQnl0ZXMobmFtZSkpLAogICAgICAgICAgZW5jb2RlRnVuY3Rpb25EYXRhKHsKICAgICAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgICAgIGZ1bmN0aW9uTmFtZTogInRleHQiLAogICAgICAgICAgICBhcmdzOiBbbmFtZWhhc2gobmFtZSksIGtleV0KICAgICAgICAgIH0pCiAgICAgICAgXSwKICAgICAgICBibG9ja051bWJlciwKICAgICAgICBibG9ja1RhZwogICAgICB9OwogICAgICBjb25zdCByZWFkQ29udHJhY3RBY3Rpb24gPSBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udH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3QgZW5jb2RlZCA9IGV2ZW50cy5mbGF0TWFwKChldmVudDIpID0+IGVuY29kZUV2ZW50VG9waWNzKHsKICAgICAgICBhYmk6IFtldmVudDJdLAogICAgICAgIGV2ZW50TmFtZTogZXZlbnQyLm5hbWUsCiAgICAgICAgYXJncwogICAgICB9KSk7CiAgICAgIHRvcGljcyA9IFtlbmNvZGVkXTsKICAgICAgaWYgKGV2ZW50KQogICAgICAgIHRvcGljcyA9IHRvcGljc1swXTsKICAgIH0KICAgIGNvbnN0IGlkID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICBtZXRob2Q6ICJldGhfbmV3RmlsdGVyIiwKICAgICAgcGFyYW1zOiBbCiAgICAgICAgewogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGZyb21CbG9jazogdHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIgPyBudW1iZXJUb0hleChmcm9tQmxvY2spIDogZnJvbUJsb2NrLAogICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrLAogICAgICAgICAgLi4udG9waWNzLmxlbmd0aCA/IHsgdG9waWNzIH0gOiB7fQogICAgICAgIH0KICAgICAgXQogICAgfSk7CiAgICByZXR1cm4gewogICAgICBhYmk6IGV2ZW50cywKICAgICAgYXJncywKICAgICAgZXZlbnROYW1lOiBldmVudCA/IGV2ZW50Lm5hbWUgOiB2b2lkIDAsCiAgICAgIGZyb21CbG9jaywKICAgICAgaWQsCiAgICAgIHJlcXVlc3Q6IGdldFJlcXVlc3QoaWQpLAogICAgICBzdHJpY3Q6IEJvb2xlYW4oc3RyaWN0KSwKICAgICAgdG9CbG9jaywKICAgICAgdHlwZTogImV2ZW50IgogICAgfTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9hY3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HVybCB9KSk7CiAgICAgICAgICAgICAgcmVxdWVzdHMuY2xlYXIoKTsKICAgICAgICAgICAgICBzdWJzY3JpcHRpb25zLmNsZWFyKCk7CiAgICAgICAgICAgICAgaWYgKHJlY29ubmVjdCAmJiByZWNvbm5lY3RDb3VudCA8IGF0dGVtcHRzKQogICAgICAgICAgICAgICAgc2V0VGltZW91dChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgIHJlY29ubmVjdENvdW50Kys7CiAgICAgICAgICAgICAgICAgIGF3YWl0IHNldHVwKCkuY2F0Y2goY29uc29sZS5lcnJvcik7CiAgICAgICAgICAgICAgICB9LCBkZWxheSk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uRXJyb3IoZXJyb3JfKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSBlcnJvcl87CiAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0IG9mIHJlcXVlc3RzLnZhbHVlcygpKQogICAgICAgICAgICAgICAgcmVxdWVzdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXF1ZXN0cy5jbGVhcigpOwogICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuY2xlYXIoKTsKICAgICAgICAgICAgICBpZiAocmVjb25uZWN0ICYmIHJlY29ubmVjdENvdW50IDwgYXR0ZW1wdHMpCiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGFzeW5jICgpID0+IHsKICAgICAgICAgICAgICAgICAgcmVjb25uZWN0Q291bnQrKzsKICAgICAgICAgICAgICAgICAgYXdhaXQgc2V0dXAoKS5jYXRjaChjb25zb2xlLmVycm9yKTsKICAgICAgICAgICAgICAgIH0sIGRlbGF5KTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25PcGVuKCkgewogICAgICAgICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgICAgICAgIHJlY29ubmVjdENvdW50ID0gMDsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25SZXNwb25zZShkYXRhKSB7CiAgICAgICAgICAgICAgY29uc3QgaXNTdWJzY3JpcHRpb24gPSBkYXRhLm1ldGhvZCA9PT0gImV0aF9zdWJzY3JpcHRpb24iOwogICAgICAgICAgICAgIGNvbnN0IGlkID0gaXNTdWJzY3JpcHRpb24gPyBkYXRhLnBhcmFtcy5zdWJzY3JpcHRpb24gOiBkYXRhLmlkOwogICAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gaXNTdWJzY3JpcHRpb24gPyBzdWJzY3JpcHRpb25zIDogcmVxdWVzdHM7CiAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2sgPSBjYWNoZS5nZXQoaWQpOwogICAgICAgICAgICAgIGlmIChjYWxsYmFjaykKICAgICAgICAgICAgICAgIGNhbGxiYWNrLm9uUmVzcG9uc2UoZGF0YSk7CiAgICAgICAgICAgICAgaWYgKCFpc1N1YnNjcmlwdGlvbikKICAgICAgICAgICAgICAgIGNhY2hlLmRlbGV0ZShpZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgc29ja2V0ID0gcmVzdWx0OwogICAgICAgICAgaWYgKGtlZXBBbGl2ZSkgewogICAgICAgICAgICBpZiAoa2VlcEFsaXZlVGltZXIpCiAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChrZWVwQWxpdmVUaW1lcik7CiAgICAgICAgICAgIGtlZXBBbGl2ZVRpbWVyID0gc2V0SW50ZXJ2YWwoKCkgPT4gc29ja2V0LnBpbmc/LigpLCBrZWVwQWxpdmVJbnRlcnZhbCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0KICAgICAgICBhd2FpdCBzZXR1cCgpOwogICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgIHNvY2tldENsaWVudCA9IHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBrZWVwQWxpdmVUaW1lciAmJiBjbGVhckludGVydmFsKGtlZXBBbGl2ZVRpbWVyKTsKICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7CiAgICAgICAgICAgIHNvY2tldENsaWVudENhY2hlLmRlbGV0ZShgJHtrZXl9OiR7dXJsfWApOwogICAgICAgICAgfSwKICAgICAgICAgIGdldCBzb2NrZXQoKSB7CiAgICAgICAgICAgIHJldHVybiBzb2NrZXQ7CiAgICAgICAgICB9LAogICAgICAgICAgcmVxdWVzdCh7IGJvZHksIG9uRXJyb3IsIG9uUmVzcG9uc2UgfSkgewogICAgICAgICAgICBpZiAoZXJyb3IgJiYgb25FcnJvcikKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKTsKICAgICAgICAgICAgY29uc3QgaWQgPSBib2R5LmlkID8/IGlkQ2FjaGUudGFrZSgpOwogICAgICAgICAgICBjb25zdCBjYWxsYmFjayA9IChyZXNwb25zZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzcG9uc2UuaWQgPT09ICJudW1iZXIiICYmIGlkICE9PSByZXNwb25zZS5pZCkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBpZiAoYm9keS5tZXRob2QgPT09ICJldGhfc3Vic2NyaWJlIiAmJiB0eXBlb2YgcmVzcG9uc2UucmVzdWx0ID09PSAic3RyaW5nIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuc2V0KHJlc3BvbnNlLnJlc3VsdCwgewogICAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiBjYWxsYmFjaywKICAgICAgICAgICAgICAgICAgb25FcnJvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgaWYgKGJvZHkubWV0aG9kID09PSAiZXRoX3Vuc3Vic2NyaWJlIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuZGVsZXRlKGJvZHkucGFyYW1zPy5bMF0pOwogICAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgICB9OwogICAgICAgICAgICByZXF1ZXN0cy5zZXQoaWQsIHsgb25SZXNwb25zZTogY2FsbGJhY2ssIG9uRXJyb3IgfSk7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgc29ja2V0LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBqc29ucnBjOiAiMi4wIiwKICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgIC4uLmJvZHkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yMik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0QXN5bmMoeyBib2R5LCB0aW1lb3V0ID0gMWU0IH0pIHsKICAgICAgICAgICAgcmV0dXJuIHdpdGhUaW1lb3V0KCgpID0+IG5ldyBQcm9taXNlKChvblJlc3BvbnNlLCBvbkVycm9yKSA9PiB0aGlzLnJlcXVlc3QoewogICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgb25FcnJvciwKICAgICAgICAgICAgICBvblJlc3BvbnNlCiAgICAgICAgICAgIH0pKSwgewogICAgICAgICAgICAgIGVycm9ySW5zdGFuY2U6IG5ldyBUaW1lb3V0RXJyb3IoeyBib2R5LCB1cmwgfSksCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0cywKICAgICAgICAgIHN1YnNjcmlwdGlvbnMsCiAgICAgICAgICB1cmwKICAgICAgICB9OwogICAgICAgIHNvY2tldENsaWVudENhY2hlLnNldChgJHtrZXl9OiR7dXJsfW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BvbkVycm9yKTsKICAgICAgICAgIHNvY2tldC5yZW1vdmVFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25NZXNzYWdlKHsgZGF0YSB9KSB7CiAgICAgICAgICBvblJlc3BvbnNlKEpTT04ucGFyc2UoZGF0YSkpOwogICAgICAgIH0KICAgICAgICBzb2NrZXQuYWRkRXZlbnRMaXN0ZW5lcigiY2xvc2UiLCBvbkNsb3NlXyk7CiAgICAgICAgc29ja2V0LmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBvbk1lc3NhZ2UpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsIG9uRXJyb3IpOwogICAgICAgIHNvY2tldC5hZGRFdmVudExpc3RlbmVyKCJvcGVuIiwgb25PcGVuKTsKICAgICAgICBpZiAoc29ja2V0LnJlYWR5U3RhdGUgPT09IFdlYlNvY2tldDMuQ09OTkVDVElORykgewogICAgICAgICAgYXdhaXQgbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICBpZiAoIXNvY2tldCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHNvY2tldC5vbm9wZW4gPSByZXNvbHZlOwogICAgICAgICAgICBzb2NrZXQub25lcnJvciA9IHJlamVjdDsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBjb25zdCB7IGNsb3NlOiBjbG9zZV8gfSA9IHNvY2tldDsKICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihzb2NrZXQsIHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBjbG9zZV8uYmluZChzb2NrZXQpKCk7CiAgICAgICAgICAgIG9uQ2xvc2UoKTsKICAgICAgICAgIH0sCiAgICAgICAgICBwaW5nKCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgV2ViU29ja2V0UmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgICBjYXVzZTogbmV3IFNvY2tldENsb3NlZEVycm9yKHsgdXJsOiBzb2NrZXQudXJsIH0pCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBjb25zdCBib2R5ID0gewogICAgICAgICAgICAgICAganNvbnJwYzogIjIuMCIsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICJuZXRfdmVyc2lvbiIsCiAgICAgICAgICAgICAgICBwYXJhbXM6IFtdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICBzb2NrZXQuc2VuZChKU09OLnN0cmluZ2lmeShib2R5KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0KHsgYm9keSB9KSB7CiAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IFdlYlNvY2tldFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgICBib2R5LAogICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgY2F1c2U6IG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybDogc29ja2V0LnVybCB9KQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gc29ja2V0LnNlbmQoSlNPTi5zdHJpbmdpZnkoYm9keS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HBhcmFtZXRlcnM7CiAgICBjb25zdCB0eXBlcyA9IHsKICAgICAgRUlQNzEyRG9tYWluOiBnZXRUeXBlc0ZvckVJUDcxMkRvbWFpbih7IGRvbWFpbiB9KSwKICAgICAgLi4ucGFyYW1ldGVycy50eXBlcwogICAgfTsKICAgIHZhbGlkYXRlVHlwZWREYXRhKHsKICAgICAgZG9tYWluLAogICAgICBtZXNzYWdlLAogICAgICBwcmltYXJ5VHlwZSwKICAgICAgdHlwZXMKICAgIH0pOwogICAgY29uc3QgcGFydHMgPSBbIjB4MTkwMSJdOwogICAgaWYgKGRvbWFpbikKICAgICAgcGFydHMucHVzaChoYXNoRG9tYWluKHsKICAgICAgICBkb21haW4sCiAgICAgICAgdHlwZXMKICAgICAgfSkpOwogICAgaWYgKHByaW1hcnlUeXBlICE9PSAiRUlQNzEyRG9tYWluIikKICAgICAgcGFydHMucHVzaChoYXNoU3RydWN0KHsKICAgICAgICBkYXRhOiBtZXNzYWdlLAogICAgICAgIHByaW1hcnlUeXBlLAogICAgICAgIHR5cGVzCiAgICAgIH0pKTsKICAgIHJldHVybiBrZWNjYWsyNTYoY29uY2F0KHBhcnRzKSk7CiAgfQogIGZ1bmN0aW9uIGhhc2hEb21haW4oeyBkb21haW4sIHR5cGVzIH0pIHsKICAgIHJldHVybiBoYXNoU3RydWN0KHsKICAgICAgZGF0YTogZG9tYWluLAogICAgICBwcmltYXJ5VHlwZTogIkVJUDcxMkRvbWFpbiIsCiAgICAgIHR5cGVzCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gaGFzaFN0cnVjdCh7IGRhdGEsIHByaW1hcnlUeXBlLCB0eXBlcyB9KSB7CiAgICBjb25zdCBlbmNvZGVkID0gZW5jb2RlRGF0YSh7CiAgICAgIGRhdGEsCiAgICAgIHByaW1hcnlUeXBlLAogICAgICB0eXBlcwogICAgfSk7CiAgICByZXR1cm4ga2VjY2FrMjU2KGVuY29kZWQpOwogIH0KICBmdW5jdGlvbiBlbmNvZGVEYXRh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ICJib29sIikKICAgICAgcmV0dXJuIHBhZChib29sVG9IZXgodmFsdWUpLCB7IHNpemU6IGlzQXJyYXkgPyAzMiA6IDEgfSk7CiAgICBjb25zdCBpbnRNYXRjaCA9IHR5cGUubWF0Y2goaW50ZWdlclJlZ2V4Mik7CiAgICBpZiAoaW50TWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBiYXNlVHlwZSwgYml0cyA9ICIyNTYiXSA9IGludE1hdGNoOwogICAgICBjb25zdCBzaXplMyA9IE51bWJlci5wYXJzZUludChiaXRzKSAvIDg7CiAgICAgIHJldHVybiBudW1iZXJUb0hleCh2YWx1ZSwgewogICAgICAgIHNpemU6IGlzQXJyYXkgPyAzMiA6IHNpemUzLAogICAgICAgIHNpZ25lZDogYmFzZVR5cGUgPT09ICJpbnQiCiAgICAgIH0pOwogICAgfQogICAgY29uc3QgYnl0ZXNNYXRjaCA9IHR5cGUubWF0Y2goYnl0ZXNSZWdleDIpOwogICAgaWYgKGJ5dGVzTWF0Y2gpIHsKICAgICAgY29uc3QgW190eXBlLCBzaXplM10gPSBieXRlc01hdGNoOwogICAgICBpZiAoTnVtYmVyLnBhcnNlSW50KHNpemUzKSAhPT0gKHZhbHVlLmxlbmd0aCAtIDIpIC8gMikKICAgICAgICB0aHJvdyBuZXcgQnl0ZXNTaXplTWlzbWF0Y2hFcnJvcih7CiAgICAgICAgICBleHBlY3RlZFNpemU6IE51bWJlci5wYXJzZUludChzaXplMyksCiAgICAgICAgICBnaXZlblNpemU6ICh2YWx1ZS5sZW5ndGggLSAyKSAvIDIKICAgICAgICB9KTsKICAgICAgcmV0dXJuIHBhZCh2YWx1ZSwgeyBkaXI6ICJyaWdodCIsIHNpemU6IGlzQXJyYXkgPyAzMiA6IG51bGwgfSk7CiAgICB9CiAgICBjb25zdCBhcnJheU1hdGNoID0gdHlwZS5tYXRjaChhcnJheVJlZ2V4KTsKICAgIGlmIChhcnJheU1hdGNoICYmIEFycmF5LmlzQXJyYXkodmFsdWU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Fyc2VUcmFuc2FjdGlvbkVJUDc3MDIoc2VyaWFsaXplZFRyYW5zYWN0aW9uKTsKICAgIHJldHVybiBwYXJzZVRyYW5zYWN0aW9uTGVnYWN5KHNlcmlhbGl6ZWRUcmFuc2FjdGlvbik7CiAgfQogIGZ1bmN0aW9uIHBhcnNlVHJhbnNhY3Rpb25FSVA3NzAyKHNlcmlhbGl6ZWRUcmFuc2FjdGlvbikgewogICAgY29uc3QgdHJhbnNhY3Rpb25BcnJheSA9IHRvVHJhbnNhY3Rpb25BcnJheShzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogICAgY29uc3QgW2NoYWluSWQsIG5vbmNlLCBtYXhQcmlvcml0eUZlZVBlckdhcywgbWF4RmVlUGVyR2FzLCBnYXMsIHRvLCB2YWx1ZSwgZGF0YSwgYWNjZXNzTGlzdCwgYXV0aG9yaXphdGlvbkxpc3QsIHYsIHIsIHNdID0gdHJhbnNhY3Rpb25BcnJheTsKICAgIGlmICh0cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCAhPT0gMTAgJiYgdHJhbnNhY3Rpb25BcnJheS5sZW5ndGggIT09IDEzKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBjaGFpbklkLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBtYXhQcmlvcml0eUZlZVBlckdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIGdhcywKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUsCiAgICAgICAgICBkYXRhLAogICAgICAgICAgYWNjZXNzTGlzdCwKICAgICAgICAgIGF1dGhvcml6YXRpb25MaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICA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jdGlvbk9yV3JhcHBlckFycmF5LnNsaWNlKDEpIDogW107CiAgICBjb25zdCBbY2hhaW5JZCwgbm9uY2UsIG1heFByaW9yaXR5RmVlUGVyR2FzLCBtYXhGZWVQZXJHYXMsIGdhcywgdG8sIHZhbHVlLCBkYXRhLCBhY2Nlc3NMaXN0LCBtYXhGZWVQZXJCbG9iR2FzLCBibG9iVmVyc2lvbmVkSGFzaGVzLCB2LCByLCBzXSA9IHRyYW5zYWN0aW9uQXJyYXk7CiAgICBjb25zdCBbYmxvYnMsIGNvbW1pdG1lbnRzLCBwcm9vZnNdID0gd3JhcHBlckFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDExIHx8IHRyYW5zYWN0aW9uQXJyYXkubGVuZ3RoID09PSAxNCkpCiAgICAgIHRocm93IG5ldyBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uRXJyb3IoewogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGNoYWluSWQsCiAgICAgICAgICBub25jZSwKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAiZWlwNDg0NCIKICAgICAgfSk7CiAgICBjb25zdCB0cmFuc2FjdGlvbiA9IHsKICAgICAgYmxvYlZlcnNpb25lZEhhc2hlcywKICAgICAgY2hhaW5JZDogaGV4VG9OdW1iZXIoY2hhaW5JZCks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AgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2hhaW5JZCwKICAgICAgICAgIG5vbmNlLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBtYXhGZWVQZXJHYXMsCiAgICAgICAgICBnYXMsCiAgICAgICAgICB0bywKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGFjY2Vzc0xpc3QsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDkgPyB7CiAgICAgICAgICAgIHYsCiAgICAgICAgICAgIHIsCiAgICAgICAgICAgIHMKICAgICAgICAgIH0gOiB7fQogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uLAogICAgICAgIHR5cGU6ICJlaXAxNTU5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICBjaGFpbklkOiBoZXhUb051bWJlcihjaGFpbklkKSwKICAgICAgdHlwZTogImVpcDE1NTkiCiAgICB9OwogICAgaWYgKGlzSGV4KHRvKSAmJiB0byAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24udG8gPSB0bzsKICAgIGlmIChpc0hleChnYXMpICYmIGdhcyAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZ2FzID0gaGV4VG9CaWdJbnQoZ2FzKTsKICAgIGlmIChpc0hleChkYXRhKSAmJiBkYXRhICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5kYXRhID0gZGF0YTsKICAgIGlmIChpc0hleChub25jZSkgJiYgbm9uY2UgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLm5vbmNlID0gaGV4VG9OdW1iZXIobm9uY2UpOwogICAgaWYgKGlzSGV4KHZhbHVlKSAmJiB2YWx1ZSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24udmFsdWUgPSBoZXhUb0JpZ0ludCh2YWx1ZSk7CiAgICBpZiAo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pZiAoISh0cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA9PT0gOCB8fCB0cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA9PT0gMTEpKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBjaGFpbklkLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBnYXNQcmljZSwKICAgICAgICAgIGdhcywKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUsCiAgICAgICAgICBkYXRhLAogICAgICAgICAgYWNjZXNzTGlzdCwKICAgICAgICAgIC4uLnRyYW5zYWN0aW9uQXJyYXkubGVuZ3RoID4gOCA/IHsKICAgICAgICAgICAgdiwKICAgICAgICAgICAgciwKICAgICAgICAgICAgcwogICAgICAgICAgfSA6IHt9CiAgICAgICAgfSwKICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdHlwZTogImVpcDI5MzAiCiAgICAgIH0pOwogICAgY29uc3QgdHJhbnNhY3Rpb24gPSB7CiAgICAgIGNoYWluSWQ6IGhleFRvTnVtYmVyKGNoYWluSWQpLAogICAgICB0eXBlOiAiZWlwMjkzMCIKICAgIH07CiAgICBpZiAoaXNIZXgodG8pICYmIHRvICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi50byA9IHRvOwogICAgaWYgKGlzSGV4KGdhcykgJiYgZ2FzICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5nYXMgPSBoZXhUb0JpZ0ludChnYXMpOwogICAgaWYgKGlzSGV4KGRhdGEpICYmIGRhdGEgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmRhdGEgPSBkYXRhOwogICAgaWYgKGlzSGV4KG5vbmNlKSAmJiBub25jZSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24ubm9uY2UgPSBoZXhUb051bWJlcihub25jZSk7C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ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBub25jZSwKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDYgPyB7CiAgICAgICAgICAgIHY6IGNoYWluSWRPclZfLAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAibGVnYWN5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICB0eXBlOiAibGVnYWN5IgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvTnVtYmVyKG5vbmNlKTsKICAgIGlmIChpc0hleCh2YWx1ZSkgJiYgdmFsdWUgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnZhbHVlID0gaGV4VG9CaWdJbnQodmFsdWUpOwogICAgaWYgKGlzSGV4KGdhc1ByaWNlKSAmJiBnYXNQcmljZSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZ2FzUHJpY2UgPSBoZXh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CiAgICAgIG5vbmNlID8gdG9IZXgobm9uY2UpIDogIjB4IiwKICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMgPyB0b0hleChtYXhQcmlvcml0eUZlZVBlckdhcykgOiAiMHgiLAogICAgICBtYXhGZWVQZXJHYXMgPyB0b0hleChtYXhGZWVQZXJHYXMpIDogIjB4IiwKICAgICAgZ2FzID8gdG9IZXgoZ2FzKSA6ICIweCIsCiAgICAgIHRvID8/ICIweCIsCiAgICAgIHZhbHVlID8gdG9IZXgodmFsdWUpIDogIjB4IiwKICAgICAgZGF0YSA/PyAiMHgiLAogICAgICBzZXJpYWxpemVkQWNjZXNzTGlzdCwKICAgICAgbWF4RmVlUGVyQmxvYkdhcyA/IHRvSGV4KG1heEZlZVBlckJsb2JHYXMpIDogIjB4IiwKICAgICAgYmxvYlZlcnNpb25lZEhhc2hlcyA/PyBbXSwKICAgICAgLi4udG9ZUGFyaXR5U2lnbmF0dXJlQXJyYXkodHJhbnNhY3Rpb24sIHNpZ25hdHVyZSkKICAgIF07CiAgICBjb25zdCBibG9icyA9IFtdOwogICAgY29uc3QgY29tbWl0bWVudHMgPSBbXTsKICAgIGNvbnN0IHByb29mcyA9IFtdOwogICAgaWYgKHNpZGVjYXJzKQogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNpZGVjYXJzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgY29uc3QgeyBibG9iLCBjb21taXRtZW50LCBwcm9vZiB9ID0gc2lkZWNhcnNbaV07CiAgICAgICAgYmxvYnMucHVzaChibG9iKTsKICAgICAgICBjb21taXRtZW50cy5wdXNoKGNvbW1pdG1lbnQpOwogICAgICAgIHByb29mcy5wdXNoKHByb29mKTsKICAgICAgfQogICAgcmV0dXJuIGNvbmNhdEhleChbCiAgICAgICIweDAzIiwKICAgICAgc2lkZWNhcnMgPyAoCiAgICAgICAgLy8gSWYgc2lkZWNhcnMgYXJlIGVuYWJsZWQsIGVudmVsb3BlIHR1cm5zIGludG8gYS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DI3biA/IDBuIDogMW4pOwogICAgICAgIGlmIChzaWduYXR1cmUudiAhPT0gdjIpCiAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZExlZ2FjeVZFcnJvcih7IHY6IHNpZ25hdHVyZS52IH0pOwogICAgICAgIHJldHVybiB2MjsKICAgICAgfSkoKTsKICAgICAgY29uc3QgciA9IHRyaW0oc2lnbmF0dXJlLnIpOwogICAgICBjb25zdCBzID0gdHJpbShzaWduYXR1cmUucyk7CiAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiA9IFsKICAgICAgICAuLi5zZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdG9IZXgodiksCiAgICAgICAgciA9PT0gIjB4MDAiID8gIjB4IiA6IHIsCiAgICAgICAgcyA9PT0gIjB4MDAiID8gIjB4IiA6IHMKICAgICAgXTsKICAgIH0gZWxzZSBpZiAoY2hhaW5JZCA+IDApIHsKICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gWwogICAgICAgIC4uLnNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0b0hleChjaGFpbklkKSwKICAgICAgICAiMHgiLAogICAgICAgICIweCIKICAgICAgXTsKICAgIH0KICAgIHJldHVybiB0b1JscChzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogIH0KICBmdW5jdGlvbiB0b1lQYXJpdHlTaWduYXR1cmVBcnJheSh0cmFuc2FjdGlvbiwgc2lnbmF0dXJlXykgewogICAgY29uc3Qgc2lnbmF0dXJlID0gc2lnbmF0dXJlXyA/PyB0cmFuc2FjdGlvbjsKICAgIGNvbnN0IHsgdiwgeVBhcml0eSB9ID0gc2lnbmF0dXJlOwogICAgaWYgKHR5cGVvZiBzaWduYXR1cmUuciA9PT0gInVuZGVmaW5lZCIpCiAgICAgIHJldHVybiBbXTsKICAgIGlmICh0eXBlb2Ygc2lnbmF0dXJlLnMgPT09ICJ1bmRlZmluZWQiKQogICAgICByZXR1cm4gW107CiAgIC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ZXkoeyBhZGRyZXNzLCBjaGFpbklkIH0pOwogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICBkZWx0YU1hcC5zZXQoa2V5LCBkZWx0YSArIDEpOwogICAgICB9LAogICAgICBhc3luYyBnZXQoeyBhZGRyZXNzLCBjaGFpbklkLCBjbGllbnQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgbGV0IHByb21pc2UgPSBwcm9taXNlTWFwLmdldChrZXkpOwogICAgICAgIGlmICghcHJvbWlzZSkgewogICAgICAgICAgcHJvbWlzZSA9IChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgY29uc3Qgbm9uY2UgPSBhd2FpdCBzb3VyY2UuZ2V0KHsgYWRkcmVzcywgY2hhaW5JZCwgY2xpZW50IH0pOwogICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzTm9uY2UgPSBub25jZU1hcC5nZXQoa2V5KSA/PyAwOwogICAgICAgICAgICAgIGlmIChwcmV2aW91c05vbmNlID4gMCAmJiBub25jZSA8PSBwcmV2aW91c05vbmNlKQogICAgICAgICAgICAgICAgcmV0dXJuIHByZXZpb3VzTm9uY2UgKyAxOwogICAgICAgICAgICAgIG5vbmNlTWFwLmRlbGV0ZShrZXkpOwogICAgICAgICAgICAgIHJldHVybiBub25jZTsKICAgICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgICB0aGlzLnJlc2V0KHsgYWRkcmVzcywgY2hhaW5JZCB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkoKTsKICAgICAgICAgIHByb21pc2VNYXAuc2V0KGtleSwgcHJvbWlzZSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICByZXR1cm4gZGVsdGEgKyBhd2FpdCBwcm9taXNlOwogICAgICB9LAogICAgICByZXNldCh7IGFkZHJlc3MsIGNoYWluSWQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgZGVsdGFNYXAuZGVsZXRlKGtleSk7CiAgICAgICAgcHJvbWlzZU1hcC5kZWxldGUoa2V5KTsKICAgICAgfQogICAgfTsKICB9CiAgZnVuY3Rpb24ganNvblJwYygpIHsKICAgIHJldHVybiB7CiAgICAgIGFzeW5jIGdldChwYXJhbWV0ZXJzKSB7CiAgICAgICAgY29uc3QgeyBhZGRyZXNzLCBjbGllbnQgfSA9IHBhcmFtZXRlcnM7CiAgICAgICAgcmV0dXJuIGdldFRyYW5zYWN0aW9uQ291bnQoY2xpZW50LCB7CiAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9LAogICAgICBzZXQoKSB7CiAgICAgIH0KICAgIH07CiAgfQogIHZhciBub25jZU1hbmFnZXIgPSAvKiBAX19QVVJFX18gKi8gY3JlYXRlTm9uY2VNYW5hZ2VyKHsKICAgIHNvdXJjZToganNvblJwYygpCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9mb3JtYXR0ZXJzL3Byb29mLmpzCiAgZnVuY3Rpb24gZm9ybWF0U3RvcmFnZVByb29mKHN0b3JhZ2VQcm9vZikgewogICAgcmV0dXJuIHN0b3JhZ2VQcm9vZi5tYXAoKHByb29mKSA9PiAoewogICAgICAuLi5wcm9vZiwKICAgICAgdmFsdWU6IEJpZ0ludChwcm9vZi52YWx1ZSkKICAgIH0pKTsKICB9CiAgZnVuY3Rpb24gZm9ybWF0UHJvb2YocHJvb2YpIHsKICAgIHJldHVybiB7CiAgICAgIC4uLnByb29mLAogICAgICBiYWxhbm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9IChjYWxsRGF0YS5sZW5ndGggLSAyKSAvIDI7CiAgICAgICAgaWYgKAogICAgICAgICAgLy8gQ2hlY2sgaWYgYmF0Y2hpbmcgaXMgZW5hYmxlZC4KICAgICAgICAgIGJhdGNoU2l6ZSA+IDAgJiYgLy8gQ2hlY2sgaWYgdGhlIGN1cnJlbnQgc2l6ZSBvZiB0aGUgYmF0Y2ggZXhjZWVkcyB0aGUgc2l6ZSBsaW1pdC4KICAgICAgICAgIGN1cnJlbnRDaHVua1NpemUgPiBiYXRjaFNpemUgJiYgLy8gQ2hlY2sgaWYgdGhlIGN1cnJlbnQgY2h1bmsgaXMgbm90IGFscmVhZHkgZW1wdHkuCiAgICAgICAgICBjaHVua2VkQ2FsbHNbY3VycmVudENodW5rXS5sZW5ndGggPiAwCiAgICAgICAgKSB7CiAgICAgICAgICBjdXJyZW50Q2h1bmsrKzsKICAgICAgICAgIGN1cnJlbnRDaHVua1NpemUgPSAoY2FsbERhdGEubGVuZ3RoIC0gMikgLyAyOwogICAgICAgICAgY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10gPSBbXTsKICAgICAgICB9CiAgICAgICAgY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10gPSBbCiAgICAgICAgICAuLi5jaHVua2VkQ2FsbHNbY3VycmVudENodW5rXSwKICAgICAgICAgIHsKICAgICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgICBjYWxsRGF0YSwKICAgICAgICAgICAgdGFyZ2V0OiBhZGRyZXNzCiAgICAgICAgICB9CiAgICAgICAgXTsKICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGFyZ3MsCiAgICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2NvbnRyYWN0L211bHRpY2FsbCIsCiAgICAgICAgICBmdW5jdGlvbk5hbWUKICAgICAgICB9KTsKICAgICAgICBpZiAoIWFsbG93RmFpbHVyZSkKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIGNodW5rZWRDYWxsc1tjdXJyZW50Q2h1bmtdID0gWwogICAgICAgICAgLi4uY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10sCiAgICAgICAgICB7CiAgICAgICAgICAgIGFsbG93RmFpbHVyZTogdHJ1ZSwKICAgICAgICAgICAgY2FsbERhdGE6ICIweCIsCiAgICAgICAgICAgIHRhcmdldDogYWRkcmVzcwogICAgICAgICAgfQogICAgICAgIF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGFnZ3JlZ2F0ZTNSZXN1bHRzID0gYXdhaXQgUHJvbWlzZS5hbGxTZXR0bGVkKGNodW5rZWRDYWxscy5tYXAoKGNhbGxzKSA9PiBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKSh7CiAgICAgIGFiaTogbXVsdGljYWxsM0FiaSwKICAgICAgYWRkcmVzczogbXVsdGljYWxsQWRkcmVzcywKICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgYmxvY2tOdW1iZXIsCiAgICAgIGJsb2NrVGFnLAogICAgICBmdW5jdGlvbk5hbWU6ICJhZ2dyZWdhdGUzIiwKICAgICAgc3RhdGVPdmVycmlkZQogICAgfSkpKTsKICAgIGNvbnN0IHJlc3VsdHMgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYWdncmVnYXRlM1Jlc3VsdHMubGVuZ3RoOyBpKyspIHsKICAgICAgY29uc3QgcmVzdWx0ID0gYWdncmVnYXRlM1Jlc3VsdHNbaV07CiAgICAgIGlmIChyZXN1bHQuc3RhdHVzID09PSAicmVqZWN0ZWQiKSB7CiAgICAgICAgaWYgKCFhbGxvd0ZhaWx1cmUpCiAgICAgICAgICB0aHJvdyByZXN1bHQucmVhc29uOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY2h1bmtlZENhbGxzW2ldLmxlbmd0aDsgaisrKSB7CiAgICAgICAgICByZXN1bHRzLnB1c2goewogICAgICAgICAgICBzdGF0dXM6ICJmYWlsdXJlIiwKICAgICAgICAgICAgZXJyb3I6IHJlc3VsdC5yZWFzb24sCiAgICAgICAgICAgIHJlc3VsdDogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QgYWdncmVnYXRlM1Jlc3VsdCA9IHJlc3VsdC52YWx1ZTsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBhZ2dyZWdhdGUzUmVzdWx0Lmxlbmd0aDsgaisrKSB7CiAgICAgICAgY29uc3QgeyByZXR1cm5EYXRhLCBzdWNjZXNzIH0gPSBhZ2dyZWdhdGUzUmVzdWx0W2pdOwogICAgICAgIGNvbnN0IHsgY2FsbERhdGEgfSA9IGNodW5rZWRDYWxsc1tpXVtqXTsKICAgICAgICBjb25zdCB7IGFiaTogYWJpMiwgYWRkcmVzcywgZnVuY3Rpb25OYW1lLCBhcmdzIH0gPSBjb250cmFjdHMyW3Jlc3VsdHMubGVuZ3RoXTsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGNhbGxEYXRhID09PSAiMHgiKQogICAgICAgICAgICB0aHJvdyBuZXcgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yKCk7CiAgICAgICAgICBpZiAoIXN1Y2Nlc3MpCiAgICAgICAgICAgIHRocm93IG5ldyBSYXdDb250cmFjdEVycm9yKHsgZGF0YTogcmV0dXJuRGF0YSB9KTsKICAgICAgICAgIGNvbnN0IHJlc3VsdDIgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgZGF0YTogcmV0dXJuRGF0YSwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIHJlc3VsdHMucHVzaChhbGxvd0ZhaWx1cmUgPyB7IHJlc3VsdDogcmVzdWx0Miwgc3RhdHVzOiAic3VjY2VzcyIgfSA6IHJlc3VsdDIpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2RvY3MvY29udHJhY3QvbXVsdGljYWxsIiwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIGlmICghYWxsb3dGYWlsdXJlKQogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIHJlc3VsdHMucHVzaCh7IGVycm9yLCByZXN1bHQ6IHZvaWQgMCwgc3RhdHVzOiAiZmFpbHVyZSIgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAocmVzdWx0cy5sZW5ndGggIT09IGNvbnRyYWN0czIubGVuZ3RoKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigibXVsdGljYWxsIHJlc3VsdHMgbWlzbWF0Y2giKTsKICAgIHJldHVybiByZXN1bHRzOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL3ZlcmlmeUhhc2guanMKICBpbml0X2FiaXMoKTsKICBpbml0X2NvbnRyYWN0cygpOwogIGluaXRfY29udHJhY3QoKTsKICBpbml0X2VuY29kZURlcGxveURhdGEoKTsKICBpbml0X2dldEFkZHJlc3MoKTsKICBpbml0X2lzQWRkcmVzc0VxdWFsKCk7CiAgaW5pdF9pc0hleCgpOwogIGluaXRfdG9IZXgoKTsKCiAgLy8gbm9kZV9tb2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ZmFsc2U7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIgJiYgY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzWzBdLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIHJldHVybiB0cnVlOwogICAgfSkoKTsKICAgIGxldCBwcmV2QmxvY2tOdW1iZXI7CiAgICBjb25zdCBwb2xsQmxvY2tOdW1iZXIgPSAoKSA9PiB7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaEJsb2NrTnVtYmVyIiwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGVtaXRPbkJlZ2luLAogICAgICAgIGVtaXRNaXNzZWQsCiAgICAgICAgcG9sbGluZ0ludGVydmFsCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uQmxvY2tOdW1iZXIsIG9uRXJyb3IgfSwgKGVtaXQpID0+IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7IGNhY2hlVGltZTogMCB9KTsKICAgICAgICAgIGlmIChwcmV2QmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgaWYgKGJsb2NrTnVtYmVyID09PSBwcmV2QmxvY2tOdW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2tOdW1iZXIgLSBwcmV2QmxvY2tOdW1iZXIgPiAxICYmIGVtaXRNaXNzZWQpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBpID0gcHJldkJsb2NrTnVtYmVyICsgMW47IGkgPCBibG9ja051bWJlcjsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoaSwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoIXByZXZCbG9ja051bWJlciB8fCBibG9ja051bWJlciA+IHByZXZCbG9ja051bWJlcikgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoYmxvY2tOdW1iZXIsIHByZXZCbG9ja051bWJlcik7CiAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja051bWJlciA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQmxvY2tOdW1iZXIiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZW1pdE9uQmVnaW4sCiAgICAgICAgZW1pdE1pc3NlZAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrTnVtYmVyLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IGFjdGl2ZSA9IHRydWU7CiAgICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIikgewogICAgICAgICAgICAgICAgY29uc3QgdHJhbnNwb3J0MiA9IGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0cy5maW5kKCh0cmFuc3BvcnQzKSA9PiB0cmFuc3BvcnQzLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0Iik7CiAgICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICAgICAgcmV0dXJuIHRyYW5zcG9ydDIudmFsdWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJuZXdIZWFkcyJdLAogICAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2tOdW1iZXIgPSBoZXhUb0JpZ0ludChkYXRhLnJlc3VsdD8ubnVtYmVyKTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9ja051bWJlcihibG9ja051bWJlciwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH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ZWNlaXB0LmJsb2NrTnVtYmVyIHx8IGJsb2NrTnVtYmVyIC0gcmVjZWlwdC5ibG9ja051bWJlciArIDFuIDwgY29uZmlybWF0aW9ucykpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgZG9uZSgoKSA9PiBlbWl0LnJlc29sdmUocmVjZWlwdCkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgIGF3YWl0IHdpdGhSZXRyeShhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uLCAiZ2V0VHJhbnNhY3Rpb24iKSh7IGhhc2g6IGhhc2gzIH0pOwogICAgICAgICAgICAgICAgaWYgKHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyKQogICAgICAgICAgICAgICAgICBibG9ja051bWJlciA9IHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgcmV0cnlDb3VudAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIHJldHJ5aW5nID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVjZWlwdCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uUmVjZWlwdCwgImdldFRyYW5zYWN0aW9uUmVjZWlwdCIpKHsgaGFzaDogaGFzaDMgfSk7CiAgICAgICAgICAgIGlmIChjb25maXJtYXRpb25zID4gMSAmJiAoIXJlY2VpcHQuYmxvY2tOdW1iZXIgfHwgYmxvY2tOdW1iZXIgLSByZWNlaXB0LmJsb2NrTnVtYmVyICsgMW4gPCBjb25maXJtYXRpb25zKSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZXNvbHZlKHJlY2VpcHQpKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVHJhbnNhY3Rpb25Ob3RGb3VuZEVycm9yIHx8IGVyciBpbnN0YW5jZW9mIFRyYW5zYWN0aW9uUmVjZWlwdE5vdEZvdW5kRXJyb3IpIHsKICAgICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgICByZXRyeWluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiA9IHRyYW5zYWN0aW9uOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCB3aXRoUmV0cnkoKCkgPT4gZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHsKICAgICAgICAgICAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVUcmFuc2FjdGlvbnM6IHRydWUKICAgICAgICAgICAgICAgIH0pLCB7CiAgICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgICByZXRyeUNvdW50LAogICAgICAgICAgICAgICAgICBzaG91bGRSZXRyeTogKHsgZXJyb3IgfSkgPT4gZXJyb3IgaW5zdGFuY2VvZiBCbG9ja05vdEZvdW5kRXJyb3IKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcGxhY2VtZW50VHJhbnNhY3Rpb24gPSBibG9jay50cmFuc2FjdGlvbnMuZmluZCgoeyBmcm9tLCBub25jZSB9KSA9PiBmcm9tID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLmZyb20gJiYgbm9uY2UgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24ubm9uY2UpOwogICAgICAgICAgICAgICAgaWYgKCFyZXBsYWNlbWVudFRyYW5zYWN0aW9uKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICByZWNlaXB0ID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0VHJhbnNhY3Rpb25SZWNlaXB0LCAiZ2V0VHJhbnNhY3Rpb25SZWNlaXB0IikoewogICAgICAgICAgICAgICAgICBoYXNoOiByZXBsYWNlbWVudFRyYW5zYWN0aW9uLmhhc2gKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgaWYgKGNvbmZpcm1hdGlvbnMgPiAxICYmICghcmVjZWlwdC5ibG9ja051bWJlciB8fCBibG9ja051bWJlciAtIHJlY2VpcHQuYmxvY2tOdW1iZXIgKyAxbiA8IGNvbmZpcm1hdGlvbnMpKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgcmVhc29uID0gInJlcGxhY2VkIjsKICAgICAgICAgICAgICAgIGlmIChyZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24udmFsdWUpIHsKICAgICAgICAgICAgICAgICAgcmVhc29uID0gInJlcHJpY2VkIjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVwbGFjZW1lbnRUcmFuc2FjdGlvbi5mcm9tID09PSByZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IDBuKSB7CiAgICAgICAgICAgICAgICAgIHJlYXNvbiA9ICJjYW5jZWxsZWQiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZG9uZSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgIGVtaXQub25SZXBsYWNlZD8uKHsKICAgICAgICAgICAgICAgICAgICByZWFzb24sCiAgICAgICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbjogcmVwbGFjZW1lbnRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvblJlY2VpcHQ6IHJlY2VpcHQKICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgIGVtaXQucmVzb2x2ZShyZWNlaXB0KTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0gY2F0Y2ggKGVycl8pIHsKICAgICAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZWplY3QoZXJyXykpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBkb25lKCgpID0+IGVtaXQucmVqZWN0KGVycikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9KTsKICAgIH0pOwogICAgcmV0dXJuIHByb21pc2U7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vYWN0aW9ucy9wdWJsaWMvd2F0Y2hCbG9ja3MuanMKICBpbml0X3N0cmluZ2lmeSgpOwogIGZ1bmN0aW9uIHdhdGNoQmxvY2tzKGNsaWVudCwgeyBibG9ja1RhZyA9ICJsYXRlc3QiLCBlbWl0TWlzc2VkID0gZmFsc2UsIGVtaXRPbkJlZ2luID0gZmFsc2UsIG9uQmxvY2ssIG9uRXJyb3IsIGluY2x1ZGVUcmFuc2FjdGlvbnM6IGluY2x1ZGVUcmFuc2FjdGlvbnNfLCBwb2xsOiBwb2xsXywgcG9sbGluZ0ludGVydmFsID0gY2xpZW50LnBvbGxpbmdJbnRlcnZhbCB9KSB7CiAgICBjb25zdCBlbmFibGVQb2xsaW5nID0gKCgpID0+IHsKICAgICAgaWYgKHR5cGVvZiBwb2xsXyAhPT0gInVuZGVmaW5lZCIpCiAgICAgICAgcmV0dXJuIHBvbGxfOwogICAgICBpZiAoY2xpZW50LnRyYW5zcG9ydC50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIgJiYgY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzWzBdLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0IikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIHJldHVybiB0cnVlOwogICAgfSkoKTsKICAgIGNvbnN0IGluY2x1ZGVUcmFuc2FjdGlvbnMgPSBpbmNsdWRlVHJhbnNhY3Rpb25zXyA/PyBmYWxzZTsKICAgIGxldCBwcmV2QmxvY2s7CiAgICBjb25zdCBwb2xsQmxvY2tzID0gKCkgPT4gewogICAgICBjb25zdCBvYnNlcnZlcklkID0gc3RyaW5naWZ5KFsKICAgICAgICAid2F0Y2hCbG9ja3MiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgZW1pdE1pc3NlZCwKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrLCBvbkVycm9yIH0sIChlbWl0KSA9PiBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRCbG9jaywgImdldEJsb2NrIikoewogICAgICAgICAgICBibG9ja1RhZywKICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoYmxvY2subnVtYmVyICYmIHByZXZCbG9jaz8ubnVtYmVyKSB7CiAgICAgICAgICAgIGlmIChibG9jay5udW1iZXIgPT09IHByZXZCbG9jay5udW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2subnVtYmVyIC0gcHJldkJsb2NrLm51bWJlciA+IDEgJiYgZW1pdE1pc3NlZCkgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSBwcmV2QmxvY2s/Lm51bWJlciArIDFuOyBpIDwgYmxvY2subnVtYmVyOyBpKyspIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrMiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgICAgIGJsb2NrTnVtYmVyOiBpLAogICAgICAgICAgICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9jayhibG9jazIsIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoCiAgICAgICAgICAgIC8vIElmIG5vIHByZXZpb3VzIGJsb2NrIGV4aXN0cywgZW1pdC4KICAgICAgICAgICAgIXByZXZCbG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBibG9jayB0YWcgaXMgInBlbmRpbmciIHdpdGggbm8gYmxvY2sgbnVtYmVyLCBlbWl0LgogICAgICAgICAgICBibG9ja1RhZyA9PT0gInBlbmRpbmciICYmICFibG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBuZXh0IGJsb2NrIG51bWJlciBpcyBncmVhdGVyIHRoYW4gdGhlIHByZXZpb3VzIGJsb2NrIG51bWJlciwgZW1pdC4KICAgICAgICAgICAgLy8gV2UgZG9uJ3Qgd2FudCB0byBlbWl0IGJsb2NrcyBpbiB0aGUgcGFzdC4KICAgICAgICAgICAgYmxvY2subnVtYmVyICYmIGJsb2NrLm51bWJlciA+IHByZXZCbG9jay5udW1iZXIKICAgICAgICAgICkgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgIHByZXZCbG9jayA9IGJsb2NrOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja3MgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgZW1pdEZldGNoZWQgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGVtaXRPbkJlZ2luKSB7CiAgICAgICAgICAgIGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgICB9KS50aGVuKChibG9jaykgPT4gewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGlmICghZW1pdEZldGNoZWQpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgb25CbG9jayhibG9jaywgdm9pZCAwKTsKICAgICAgICAgICAgICBlbWl0RmV0Y2hlZCA9IGZhbHNlOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibmV3SGVhZHMiXSwKICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBjb25zdCBmb3JtYXQgPSBjbGllbnQuY2hhaW4/LmZvcm1hdHRlcnM/LmJsb2NrPy5mb3JtYXQgfHwgZm9ybWF0QmxvY2s7CiAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBmb3JtYXQoZGF0YS5yZXN1bHQpOw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cGVvZiBwb2xsXyAhPT0gInVuZGVmaW5lZCIpCiAgICAgICAgcmV0dXJuIHBvbGxfOwogICAgICBpZiAodHlwZW9mIGZyb21CbG9jayA9PT0gImJpZ2ludCIpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJ3ZWJTb2NrZXQiKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIiAmJiBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHNbMF0uY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9KSgpOwogICAgY29uc3Qgc3RyaWN0ID0gc3RyaWN0XyA/PyBmYWxzZTsKICAgIGNvbnN0IHBvbGxFdmVudCA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoRXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50LAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBmcm9tQmxvY2sKICAgICAgXSk7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IHByZXZpb3VzQmxvY2tOdW1iZXI7CiAgICAgICAgaWYgKGZyb21CbG9jayAhPT0gdm9pZCAwKQogICAgICAgICAgcHJldmlvdXNCbG9ja051bWJlciA9IGZyb21CbG9jayAtIDFuOwogICAgICAgIGxldCBmaWx0ZXI7CiAgICAgICAgbGV0IGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgY29uc3QgdW53YXRjaCA9IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgICAgaWYgKCFpbml0aWFsaXplZCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZUV2ZW50RmlsdGVyLCAiY3JlYXRlRXZlbnRGaWx0ZXIiKSh7CiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIGV2ZW50LAogICAgICAgICAgICAgICAgZXZlbnRzLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciAhPT0gYmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgICAgIGxvZ3MgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRMb2dzLCAiZ2V0TG9ncyIpKHsKICAgICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgICAgZXZlbnQsCiAgICAgICAgICAgICAgICAgIGV2ZW50cywKICAgICAgICAgICAgICAgICAgZnJvbUJsb2NrOiBwcmV2aW91c0Jsb2NrTnVtYmVyICsgMW4sCiAgICAgICAgICAgICAgICAgIHRvQmxvY2s6IGJsb2NrTnVtYmVyCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUV2ZW50ID0gKCkgPT4gewogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBldmVudHNfID0gZXZlbnRzID8/IChldmVudCA/IFtldmVudF0gOiB2b2lkIDApOwogICAgICAgICAgbGV0IHRvcGljcyA9IFtdOwogICAgICAgICAgaWYgKGV2ZW50c18pIHsKICAgICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50c18uZmxhdE1hcCgoZXZlbnQyKSA9PiBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgICAgICAgICAgYWJpOiBbZXZlbnQyXSwKICAgICAgICAgICAgICBldmVudE5hbWU6IGV2ZW50Mi5uYW1lLAogICAgICAgICAgICAgIGFyZ3MKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB0b3BpY3MgPSBbZW5jb2RlZF07CiAgICAgICAgICAgIGlmIChldmVudCkKICAgICAgICAgICAgICB0b3BpY3MgPSB0b3BpY3NbMF07CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibG9ncyIsIHsgYWRkcmVzcywgdG9waWNzIH1dLAogICAgICAgICAgICBvbkRhdGEoZGF0YSkgewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGNvbnN0IGxvZyA9IGRhdGEucmVzdWx0OwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBjb25zdCB7IGV2ZW50TmFtZSwgYXJnczogYXJnczIgfSA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgICAgICAgICAgYWJpOiBldmVudHNfID8/IFtdLAogICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgdG9waWNzOiBsb2cudG9waWNzLAogICAgICAgICAgICAgICAgICBzdHJpY3QKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgeyBhcmdzOiBhcmdzMiwgZXZlbnROYW1lIH0pOwogICAgICAgICAgICAgICAgb25Mb2dzKFtmb3JtYXR0ZWRdKTsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIGxldCBldmVudE5hbWU7CiAgICAgICAgICAgICAgICBsZXQgaXNVbm5hbWVkOwogICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIERlY29kZUxvZ0RhdGFNaXNtYXRjaCB8fCBlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCkgewogICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgIGV2ZW50TmFtZSA9IGVyci5hYmlJdGVtLm5hbWU7CiAgICAgICAgICAgICAgICAgIGlzVW5uYW1lZCA9IGVyci5hYmlJdGVtLmlucHV0cz8uc29tZSgoeCkgPT4gISgibmFtZSIgaW4geCAmJiB4Lm5hbWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZCA9IGZvcm1hdExvZyhsb2csIHsKICAgICAgICAgICAgICAgICAgYXJnczogaXNVbm5hbWVkID8gW10gOiB7fSwKICAgICAgICAgICAgICAgICAgZXZlbnROYW1lCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LAogICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICB1bnN1YnNjcmliZSA9IHVuc3Vic2NyaWJlXzsKICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICB1bnN1YnNjcmliZSgpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgb25FcnJvcj8uKGVycik7CiAgICAgICAgfQogICAgICB9KSgpOwogICAgICByZXR1cm4gKCkgPT4gdW5zdWJzY3JpYmUoKTsKICAgIH07CiAgICByZXR1cm4gZW5hYmxlUG9sbGluZyA/IHBvbGxFdmVudCgpIDogc3Vic2NyaWJlRXZlbnQoKTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjE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mFuc2FjdGlvbkZpbHRlciIpKHt9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIHVud2F0Y2goKTsKICAgICAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgaGFzaGVzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgaWYgKGhhc2hlcy5sZW5ndGggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmF0Y2gpCiAgICAgICAgICAgICAgZW1pdC5vblRyYW5zYWN0aW9ucyhoYXNoZXMpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBoYXNoMyBvZiBoYXNoZXMpCiAgICAgICAgICAgICAgICBlbWl0Lm9uVHJhbnNhY3Rpb25zKFtoYXNoM10pOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZVBlbmRpbmdUcmFuc2FjdGlvbnMgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgeyB1bnN1YnNjcmliZTogdW5zdWJzY3JpYmVfIH0gPSBhd2FpdCBjbGllbnQudHJhbnNwb3J0LnN1YnNjcmliZSh7CiAgICAgICAgICAgIHBhcmFtczogWyJuZXdQZW5kaW5nVHJhbnNhY3Rpb25zIl0sCiAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgaWYgKCFhY3RpdmUpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICBvblRyYW5zYWN0aW9ucyhbdHJhbnNhY3Rpb25dKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIG9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgdW5zdWJzY3JpYmUoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgIH0KICAgICAgfSkoKTsKICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsUGVuZGluZ1RyYW5zYWN0aW9ucygpIDogc3Vic2NyaWJlUGVuZGluZ1RyYW5zYWN0aW9ucygpOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zN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oKTsKICAgICAgcmV0dXJuIGNyZWF0ZVRyYW5zcG9ydCh7CiAgICAgICAga2V5LAogICAgICAgIG5hbWUsCiAgICAgICAgYXN5bmMgcmVxdWVzdCh7IG1ldGhvZCwgcGFyYW1zIH0pIHsKICAgICAgICAgIGNvbnN0IGJvZHkgPSB7IG1ldGhvZCwgcGFyYW1zIH07CiAgICAgICAgICBjb25zdCBycGNDbGllbnQgPSBhd2FpdCBnZXRXZWJTb2NrZXRScGNDbGllbnQodXJsXywgewogICAgICAgICAgICBrZWVwQWxpdmUsCiAgICAgICAgICAgIHJlY29ubmVjdAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCB7IGVycm9yLCByZXN1bHQgfSA9IGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0QXN5bmMoewogICAgICAgICAgICBib2R5LAogICAgICAgICAgICB0aW1lb3V0CiAgICAgICAgICB9KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogIndlYlNvY2tldCIKICAgICAgfSwgewogICAgICAgIGdldFNvY2tldCgpIHsKICAgICAgICAgIHJldHVybiBnZXRTb2NrZXQodXJsXyk7CiAgICAgICAgfSwKICAgICAgICBnZXRScGNDbGllbnQoKSB7CiAgICAgICAgICByZXR1cm4gZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgIH0sCiAgICAgICAgYXN5bmMgc3Vic2NyaWJlKHsgcGFyYW1zLCBvbkRhdGEsIG9uRXJyb3IgfSkgewogICAgICAgICAgY29uc3QgcnBjQ2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgICAgY29uc3QgeyByZXN1bHQ6IHN1YnNjcmlwdGlvbklkIH0gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIGJvZHk6IHsKICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfc3Vic2NyaWJlIiwKICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIHJlamVjdChlcnJvcik7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuZXJyb3IpIHsKICAgICAgICAgICAgICAgIHJlamVjdChyZXNwb25zZS5lcnJvcik7CiAgICAgICAgICAgICAgICBvbkVycm9yPy4ocmVzcG9uc2UuZXJyb3IpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc3BvbnNlLmlkID09PSAibnVtYmVyIikgewogICAgICAgICAgICAgICAgcmVzb2x2ZShyZXNwb25zZSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChyZXNwb25zZS5tZXRob2QgIT09ICJldGhfc3Vic2NyaXB0aW9uIikKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBvbkRhdGEocmVzcG9uc2UucGFyYW1zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgc3Vic2NyaXB0aW9uSWQsCiAgICAgICAgICAgIGFzeW5jIHVuc3Vic2NyaWJlKCkgewogICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4gcnBjQ2xpZW50LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfdW5zdWJzY3JpYmUiLAogICAgICAgICAgICAgICAgICBwYXJhbXM6IFtzdWJzY3JpcHRpb25JZF0KICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiByZXNvbHZlCiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgfSk7CiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2luZGV4LmpzCiAgaW5pdF9hYmlzKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvYWRkcmVzcy5qcwogIHZhciB6ZXJvQWRkcmVzcyA9ICIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAiOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vaW5kZXguanMKICBpbml0X2NvbnRyYWN0cygpOwogIGluaXRfdW5pdCgpOwogIGluaXRfbnVtYmVyKCk7CiAgaW5pdF9hYmkoKTsKICBpbml0X2Jhc2UoKTsKICBpbml0X2NvbnRyYWN0KCk7CiAgaW5pdF9ycGMoKTsKICBpbml0X2NoYWluKCk7CiAgaW5pdF9lbmNvZGluZygpOwogIGluaXRfbm9kZSgpOwogIGluaXRfcmVxdWVzdCgpOwogIGluaXRfYWRkcmVzcygpOw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xQmF0Y2hOdW1iZXIgPyBoZXhUb0JpZ0ludChsb2cubDFCYXRjaE51bWJlcikgOiBudWxsLAogICAgICAgICAgICAgIHRyYW5zYWN0aW9uTG9nSW5kZXg6IGhleFRvTnVtYmVyKGxvZy50cmFuc2FjdGlvbkxvZ0luZGV4KSwKICAgICAgICAgICAgICBsb2dUeXBlOiBsb2cubG9nVHlwZQogICAgICAgICAgICB9OwogICAgICAgICAgfSksCiAgICAgICAgICBsMlRvTDFMb2dzOiBhcmdzLmwyVG9MMUxvZ3MubWFwKChsMlRvTDFMb2cpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICBibG9ja051bWJlcjogaGV4VG9CaWdJbnQobDJUb0wxTG9nLmJsb2NrSGFzaCksCiAgICAgICAgICAgICAgYmxvY2tIYXNoOiBsMlRvTDFMb2cuYmxvY2tIYXNoLAogICAgICAgICAgICAgIGwxQmF0Y2hOdW1iZXI6IGhleFRvQmlnSW50KGwyVG9MMUxvZy5sMUJhdGNoTnVtYmVyKSwKICAgICAgICAgICAgICB0cmFuc2FjdGlvbkluZGV4OiBoZXhUb0JpZ0ludChsMlRvTDFMb2cudHJhbnNhY3Rpb25JbmRleCksCiAgICAgICAgICAgICAgc2hhcmRJZDogaGV4VG9CaWdJbnQobDJUb0wxTG9nLnNoYXJkSWQpLAogICAgICAgICAgICAgIGlzU2VydmljZTogbDJUb0wxTG9nLmlzU2VydmljZSwKICAgICAgICAgICAgICBzZW5kZXI6IGwyVG9MMUxvZy5zZW5kZXIsCiAgICAgICAgICAgICAga2V5OiBsMlRvTDFMb2cua2V5LAogICAgICAgICAgICAgIHZhbHVlOiBsMlRvTDFMb2cudmFsdWUsCiAgICAgICAgICAgICAgdHJhbnNhY3Rpb25IYXNoOiBsMlRvTDFMb2cudHJhbnNhY3Rpb25IYXNoLAogICAgICAgICAgICAgIGxvZ0luZGV4OiBoZXhUb0JpZ0ludChsMlRvTDFMb2cubG9nSW5kZXgpCiAgICAgICAgICAgIH07CiAgICAgICAgICB9KQogICAgICAgIH07CiAgICAgIH0KICAgIH0pLAogICAgdHJhbnNhY3Rpb25SZXF1ZXN0OiAvKiBAX19QVVJFX18gKi8gZGVmaW5lVHJhbnNhY3Rpb25SZXF1ZXN0KHsKICAgICAgZXhjbHVkZTogWwogICAgICAgICJjdXN0b21TaWduYXR1cmUiLAogICAgICAgICJmYWN0b3J5RGVwcyIsCiAgICAgICAgImdhc1BlclB1YmRhdGEiLAogICAgICAgICJwYXltYXN0ZXIiLAogICAgICAgICJwYXltYXN0ZXJJbnB1dCIKICAgICAgXSwKICAgICAgZm9ybWF0KGFyZ3MpIHsKICAgICAgICBpZiAoYXJncy5nYXNQZXJQdWJkYXRhIHx8IGFyZ3MucGF5bWFzdGVyICYmIGFyZ3MucGF5bWFzdGVySW5wdXQgfHwgYXJncy5mYWN0b3J5RGVwcyB8fCBhcmdzLmN1c3RvbVNpZ25hdHVyZSkKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIGVpcDcxMk1ldGE6IHsKICAgICAgICAgICAgICAuLi5hcmdzLmdhc1BlclB1YmRhdGEgPyB7IGdhc1BlclB1YmRhdGE6IHRvSGV4KGFyZ3MuZ2FzUGVyUHViZGF0YSkgfSA6IHsgZ2FzUGVyUHViZGF0YTogdG9IZXgoZ2FzUGVyUHViZGF0YURlZmF1bHQpIH0sCiAgICAgICAgICAgICAgLi4uYXJncy5wYXltYXN0ZXIgJiYgYXJncy5wYXltYXN0ZXJJbnB1dCA/IHsKICAgICAgICAgICAgICAgIHBheW1hc3RlclBhcmFtczogewogICAgICAgICAgICAgICAgICBwYXltYXN0ZXI6IGFyZ3MucGF5bWFzdGVyLAogICAgICAgICAgICAgICAgICBwYXltYXN0ZXJJbnB1dDogQXJyYXkuZnJvbShoZXhUb0J5dGVzKGFyZ3MucGF5bWFzdGVySW5wdXQpKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgICAuLi5hcm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jdGlvblRvTWVzc2FnZSh0cmFuc2FjdGlvbik7CiAgICByZXR1cm4gewogICAgICBkb21haW46IHsKICAgICAgICBuYW1lOiAiemtTeW5jIiwKICAgICAgICB2ZXJzaW9uOiAiMiIsCiAgICAgICAgY2hhaW5JZDogdHJhbnNhY3Rpb24uY2hhaW5JZAogICAgICB9LAogICAgICB0eXBlczogewogICAgICAgIFRyYW5zYWN0aW9uOiBbCiAgICAgICAgICB7IG5hbWU6ICJ0eFR5cGUiLCB0eXBlOiAidWludDI1NiIgfSwKICAgICAgICAgIHsgbmFtZTogImZyb20iLCB0eXBlOiAidWludDI1NiIgfSwKICAgICAgICAgIHsgbmFtZTogInRvIiwgdHlwZTogInVpbnQyNTYiIH0sCiAgICAgICAgICB7IG5hbWU6ICJnYXNMaW1pdCIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgICAgeyBuYW1lOiAiZ2FzUGVyUHViZGF0YUJ5dGVMaW1pdCIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgICAgeyBuYW1lOiAibWF4RmVlUGVyR2FzIiwgdHlwZTogInVpbnQyNTYiIH0sCiAgICAgICAgICB7IG5hbWU6ICJtYXhQcmlvcml0eUZlZVBlckdhcyIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgICAgeyBuYW1lOiAicGF5bWFzdGVyIiwgdHlwZTogInVpbnQyNTYiIH0sCiAgICAgICAgICB7IG5hbWU6ICJub25jZSIsIHR5cGU6ICJ1aW50MjU2IiB9LAogICAgICAgICAgeyBuYW1lOiAidmFsdWUiLCB0eXBlOiAidWludDI1NiIgfSwKICAgICAgICAgIHsgbmFtZTogImRhdGEiLCB0eXBlOiAiYnl0ZXMiIH0sCiAgICAgICAgICB7IG5hbWU6ICJmYWN0b3J5RGVwcyIsIHR5cGU6ICJieXRlczMyW10iIH0sCiAgICAgICAgICB7IG5hbWU6ICJwYXltYXN0ZXJJbnB1dCIsIHR5cGU6ICJieXRlcyIgfQogICAgICAgIF0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HVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2FuY2llbnQ4LmpzCiAgdmFyIHNvdXJjZUlkID0gMTsKICB2YXIgYW5jaWVudDggPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDg4ODg4ODg4OCwKICAgIG5hbWU6ICJBbmNpZW50OCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMuYW5jaWVudDguZ2ciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJBbmNpZW50OCBleHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9zY2FuLmFuY2llbnQ4LmdnIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3NjYW4uYW5jaWVudDguZ2cvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7CiAgICAgICAgW3NvdXJjZUlkXTogewogICAgICAgICAgYWRkcmVzczogIjB4QjA5REMwODQyOEM4YjRFRkI0ZmY5QzA4MjczODZDREYzNDI3Nzk5NiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDYzOUYyQUVDRTM5OEFhNzZiMDdlNTllRjZhYmUyY0ZlMzJiYWNiNjgiLAogICAgICAgICAgYmxvY2tDcmVhdGVk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N5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkF2YWxhbmNoZSBGdWppIiwKICAgICAgc3ltYm9sOiAiQVZBWCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL2FwaS5hdmF4LXRlc3QubmV0d29yay9leHQvYmMvQy9ycGMiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTbm93VHJhY2UiLAogICAgICAgIHVybDogImh0dHBzOi8vdGVzdG5ldC5zbm93dHJhY2UuaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLXRlc3RuZXQuc25vd3RyYWNlLmlvIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDcwOTY5NTkKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9iMy5qcwogIHZhciBzb3VyY2VJZDQgPSA4NDUzOwogIHZhciBiMyA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODMzMywKICAgIG5hbWU6ICJCMyIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0d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JiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAyMzEzMQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDExXTogewogICAgICAgICAgYWRkcmVzczogIjB4ZERhNTNFMjNmOGEzMjY0MGIwNEQ3MjU2ZTY1MUMxZGI5OGRCMTFDMSIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDQ0NjI2MTUKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDExXTogewogICAgICAgICAgYWRkcmVzczogIjB4OEFkZUUxMjQ0NDc0MzVmRTAzZTNDRDI0ZEYzZjRjQUUzMkU2NWEzRSIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDQ0NjI2MTUKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQxMQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2JvYmEuanMKICB2YXIgYm9iYSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMjg4LAogICAgbmFtZTogIkJvYmEgTmV0d29yayIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL21haW5uZXQuYm9iYS5uZXR3b3JrIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiQk9CQVNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vYm9iYXNjY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AogICAgbmFtZTogIkJpdGxheWVyIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIG5hbWU6ICJCaXRjb2luIiwKICAgICAgc3ltYm9sOiAiQlRDIiwKICAgICAgZGVjaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vcnBjLmJpdGxheWVyLm9yZyIsCiAgICAgICAgICAiaHR0cHM6Ly9ycGMuYml0bGF5ZXItcnBjLmNvbSIsCiAgICAgICAgICAiaHR0cHM6Ly9ycGMuYW5rci5jb20vYml0bGF5ZXIiCiAgICAgICAgXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vd3MuYml0bGF5ZXIub3JnIiwgIndzczovL3dzLmJpdGxheWVyLXJwYy5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCaXRsYXllcihCVFIpIFNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vd3d3LmJ0cnNjYW4uY29tIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvYnRyVGVzdG5ldC5qcwogIHZhciBidHJUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMDA4MTAsCiAgICBuYW1lOiAiQml0bGF5ZXIgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiQml0Y29pbiIsCiAgICAgIHN5bWJvbDogIkJUQyIsCiAgICAgIGRlY2ltYWxzOiAxOAogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6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2s6IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVCbG9jayh7CiAgICAgIGZvcm1hdChhcmdzKSB7CiAgICAgICAgY29uc3QgdHJhbnNhY3Rpb25zID0gYXJncy50cmFuc2FjdGlvbnM/Lm1hcCgodHJhbnNhY3Rpb24pID0+IHsKICAgICAgICAgIGlmICh0eXBlb2YgdHJhbnNhY3Rpb24gPT09ICJzdHJpbmciKQogICAgICAgICAgICByZXR1cm4gdHJhbnNhY3Rpb247CiAgICAgICAgICBjb25zdCBmb3JtYXR0ZWQgPSBmb3JtYXRUcmFuc2FjdGlvbih0cmFuc2FjdGlvbik7CiAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAuLi5mb3JtYXR0ZWQsCiAgICAgICAgICAgIC4uLnRyYW5zYWN0aW9uLmdhdGV3YXlGZWUgPyB7CiAgICAgICAgICAgICAgZ2F0ZXdheUZlZTogaGV4VG9CaWdJbnQodHJhbnNhY3Rpb24uZ2F0ZXdheUZlZSksCiAgICAgICAgICAgICAgZ2F0ZXdheUZlZVJlY2lwaWVudDogdHJhbnNhY3Rpb24uZ2F0ZXdheUZlZVJlY2lwaWVudAogICAgICAgICAgICB9IDoge30sCiAgICAgICAgICAgIGZlZUN1cnJlbmN5OiB0cmFuc2FjdGlvbi5mZWVDdXJyZW5jeQogICAgICAgICAgfTsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgdHJhbnNhY3Rpb25zLAogICAgICAgICAgLi4uYXJncy5yYW5kb21uZXNzID8geyByYW5kb21uZXNzOiBhcmdzLnJhbmRvbW5lc3MgfSA6IHt9CiAgICAgICAgfTsKICAgICAgfQogICAgfSksCiAgICB0cmFuc2FjdGlvbjogLyogQF9fUFVSRV9fICovIGRlZmluZVRyYW5zYWN0aW9uKHsKICAgICAgZm9ybWF0KGFyZ3MpIHsKICAgICAgICBpZiAoYXJncy50eXBlID09PSAiMHg3ZSIpCiAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICBpc1N5c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sZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Rvc0NoYWluLmpzCiAgdmFyIGRvc0NoYWluID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA3OTc5LAogICAgbmFtZTogIkRPUyBDaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJET1MgQ2hhaW4iLAogICAgICBzeW1ib2w6ICJET1MiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9tYWluLmRvc2NoYWluLmNvbSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkRPUyBDaGFpbiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9kb3NjYW4uaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLmRvc2Nhbi5pbyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxNjE5MDgKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Rvc0NoYWluVGVzdG5ldC5qcwogIHZhciBkb3NDaGFpblRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDM5MzksCiAgICBuYW1lOiAiRE9TIENoYWluIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRE9TIENoYWluIFRlc3RuZXQiLAogICAgICBzeW1ib2w6ICJET1MiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly90ZXN0LmRvc2NoYWluLmNvbSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkRPUyBDaGFpbiBUZXN0bmV0IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3QuZG9zY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS10ZXN0LmRvc2Nhbi5pbyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA2OTYyMwogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2RyZXllcnhNYWlubmV0LmpzCiAgdmFyIGRyZXllcnhNYWlubmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMzQ1MSwKICAgIG5hbWU6ICJEcmV5ZXJYIE1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgbmFtZTogIkRyZXllclgiLAogICAgICBzeW1ib2w6ICJEUlgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICA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JEWU0iLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vZHltZW5zaW9uLWV2bS1ycGMucHVibGljbm9kZS5jb20iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vZHltZW5zaW9uLWV2bS1ycGMucHVibGljbm9kZS5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJEeW0gRllJIiwKICAgICAgICB1cmw6ICJodHRwczovL2R5bS5meWkiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2VkZ2VsZXNzLmpzCiAgdmFyIGVkZ2VsZXNzID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAyMDI2LAogICAgbmFtZTogIkVkZ2VsZXNzIE5ldHdvcmsiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgbmFtZTogIkVkZ2VsZXNzIFdyYXBwZWQgRVRIIiwKICAgICAgc3ltYm9sOiAiRXdFVEgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLmVkZ2VsZXNzLm5ldHdvcmsvaHR0cCJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly9ycGMuZWRnZWxlc3MubmV0d29yay93cyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkVkZ2VsZXNzIEV4c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E1TY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2Z0bXNjYW4uY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS5mdG1zY2FuLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMzMwMDE5ODcKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2ZhbnRvbVNvbmljVGVzdG5ldC5qcwogIHZhciBmYW50b21Tb25pY1Rlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDY0MjQwLAogICAgbmFtZTogIkZhbnRvbSBTb25pYyBPcGVuIFRlc3RuZXQiLAogICAgbmV0d29yazogImZhbnRvbS1zb25pYy10ZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkZhbnRvbSIsCiAgICAgIHN5bWJvbDogIkZUTSIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL3JwY2FwaS5zb25pYy5mYW50b20ubmV0d29yayJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZhbnRvbSBTb25pYyBPcGVuIFRlc3RuZXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vcHVibGljLXNvbmljLmZhbnRvbS5uZXR3b3JrIgogICAgICB9CiAgICB9LAogICAgdGV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VSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMjMwNiwKICAgIG5hbWU6ICJGaWJvIENoYWluIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogImZpYm8iLAogICAgICBzeW1ib2w6ICJGSUJPIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vbmV0d29yay5oenJvYy5hcnQiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJGaWJvU2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9zY2FuLmZpYm9jaGFpbi5vcmciCiAgICAgIH0KICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9maWxlY29pbi5qcwogIHZhciBmaWxlY29pbiA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMzE0LAogICAgbmFtZTogIkZpbGVjb2luIE1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiZmlsZWNvaW4iLAogICAgICBzeW1ib2w6ICJGSUwiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9hcGkubm9kZS5nbGlmLmlvL3JwYy92MSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZpbGZveCIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9maWxmb3guaW5mby9lbiIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogew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DE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vdGVzdG5ldC5mdXNpb25uZXR3b3JrLmlvIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3Rlc3RuZXQuZnVzaW9ubmV0d29yay5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZTTnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vdGVzdG5ldC5mc25zY2FuLmNvbSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMDQyODMwOQogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2dhcm5ldC5qcwogIHZhciBzb3VyY2VJZDE4ID0gMTdlMzsKICB2YXIgZ2FybmV0ID0gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgbmFtZTogIkdhcm5ldCBUZXN0bmV0IiwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBpZDogMTcwNjksCiAgICBzb3VyY2VJZDogc291cmNlSWQxOCwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5nYXJuZXRjaGFpbi5jb20iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vcnBjLmdhcm5ldGNoYWluLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZ2FybmV0Y2hhaW4uY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQxOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDU3ZWU0MDU4NmZiRTI4NkFmQzc1RTY3Y2I2OTUxMUE2RDlhRjU5MDkiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxMjc0Njg0CiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDE4XTogewogICAgICAgICAgYWRkcmVzczogIjB4Q2I4RTdBQzU2MWI4RUYwNEYyYTE1ODY1ZTlmYmMwNzY2RkVGNTY5QiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDEyNzQ2ODQKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgICAgICBbc291cmNlSWQxOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDA5YmNEZDMxMUZFMzk4RjgwYTc4QkUzN0U0ODlmNUQ0NDBEQjk1REUiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxMjc0Njg0CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGV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jaW1hbHM6IDE4CiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMuYW5rci5jb20vaGFybW9ueSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkhhcm1vbnkgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuaGFybW9ueS5vbmUiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjQxODU3NTMKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hhc2hrZXlDaGFpblRlc3RuZXQuanMKICB2YXIgaGFzaGtleVRlc3RuZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEzMywKICAgIG5hbWU6ICJIYXNoS2V5IENoYWluIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiSGFzaEtleSBFY29Qb2ludHMiLAogICAgICBzeW1ib2w6ICJIU0siCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2hhc2hrZXljaGFpbi10ZXN0bmV0LmFsdC50ZWNobm9sb2d5Il0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSG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aC1ycGMta2FydXJhLmFjYS1hcGkubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkthcnVyYSBCbG9ja3Njb3V0IiwKICAgICAgICB1cmw6ICJodHRwczovL2Jsb2Nrc2NvdXQua2FydXJhLm5ldHdvcmsiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYmxvY2tzY291dC5rYXJ1cmEubmV0d29yay9hcGkiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2tha2Fyb3RTZXBvbGlhLmpzCiAgdmFyIGtha2Fyb3RTZXBvbGlhID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxODAyMjAzNzY0LAogICAgbmFtZTogIktha2Fyb3QgU2Vwb2xpYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vc2Vwb2xpYS1ycGMua2FrYXJvdC5vcmciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJLYWthcm90IFNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vc2Vwb2xpYS5rYWthcm90c2Nhbi5vcmciCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZ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AgICAgIG5hbWU6ICJLbGF5dG4iLAogICAgICBzeW1ib2w6ICJLTEFZIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcHVibGljLWVuLWN5cHJlc3Mua2xheXRuLm5ldCJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIktsYXl0blNjb3BlIiwKICAgICAgICB1cmw6ICJodHRwczovL3Njb3BlLmtsYXl0bi5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogOTYwMDI0MTUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2thaWEuanMKICB2YXIga2FpYSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODIxNywKICAgIG5hbWU6ICJLYWlhIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkthaWEiLAogICAgICBzeW1ib2w6ICJLQUlBIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcHVibGljLWVuLm5vZGUua2FpYS5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkthaWFTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2thaWFzY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1jeXByZXNzLmtsYXl0bnNjb3BlLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogOTYwMDI0MTUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2thaXJvcy5qcwogIHZhciBrYWlyb3MgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEwMDEsCiAgICBuYW1lOiAiS2Fpcm9zIFRlc3RuZXQiLAogICAgbmV0d29yazogImthaXJvcyIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJLYWlyb3MgS0FJQSIsCiAgICAgIHN5bWJvbDogIktBSUEiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9wdWJsaWMtZW4ta2Fpcm9zLm5vZGUua2FpYS5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkthaWFTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2thaXJvcy5rYWlhc2Nhbi5pbyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMjM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gICBkYXRhLAogICAgICAgIGdhcywKICAgICAgICBnYXNQcmljZSwKICAgICAgICBtYXhGZWVQZXJHYXMsCiAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgbm9uY2UsCiAgICAgICAgdG8sCiAgICAgICAgdmFsdWUKICAgICAgfSk7CiAgICAgIGNvbnN0IHsgYmFzZUZlZVBlckdhcywgZ2FzTGltaXQsIHByaW9yaXR5RmVlUGVyR2FzIH0gPSBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgbWV0aG9kOiAibGluZWFfZXN0aW1hdGVHYXMiLAogICAgICAgIHBhcmFtczogYmxvY2sgPyBbcmVxdWVzdCwgYmxvY2tdIDogW3JlcXVlc3RdCiAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGJhc2VGZWVQZXJHYXM6IEJpZ0ludChiYXNlRmVlUGVyR2FzKSwKICAgICAgICBnYXNMaW1pdDogQmlnSW50KGdhc0xpbWl0KSwKICAgICAgICBwcmlvcml0eUZlZVBlckdhczogQmlnSW50KHByaW9yaXR5RmVlUGVyR2FzKQogICAgICB9OwogICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgIHRocm93IGdldENhbGxFcnJvcihlcnIsIHsKICAgICAgICAuLi5hcmdzLAogICAgICAgIGFjY291bnQsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbgogICAgICB9KTsKICAgIH0KICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9saW5lYS9jaGFpbkNvbmZpZy5qcwogIHZhciBjaGFpbkNvbmZpZzQgPSB7CiAgICBmZWVzOiB7CiAgICAgIGVzdGltYXRlRmVlc1BlckdhczogZXN0aW1hdGVGZWVzUGVyR2FzMiwKICAgICAgYXN5bmMgbWF4UHJpb3JpdHlGZWVQZXJHYXMoeyBibG9jaywgY2xpZW50LCByZXF1ZXN0IH0pIHsKICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IGVzdGltYXRlRmVlc1BlckdhczIoewogICAgICAgICAgYmxvY2ssCiAgICAgICAgICBjbGllbnQsCiAgICAgICAgICBtdWx0aXBseTogKHgpID0+IHgsCiAgICAgICAgICByZXF1ZXN0LAogICAgICAgICAgdHlwZTogImVpcDE1NTkiCiAgICAgICAgfSk7CiAgICAgICAgaWYgKCFyZXNwb25zZT8ubWF4UHJpb3JpdHlGZWVQZXJHYXMpCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICByZXR1cm4gcmVzcG9uc2UubWF4UHJpb3JpdHlGZWVQZXJHYXM7CiAgICAgIH0KICAgIH0KICB9OwogIGFzeW5jIGZ1bmN0aW9uIGVzdGltYXRlRmVlc1BlckdhczIoeyBjbGllbnQsIG11bHRpcGx5LCByZXF1ZXN0LCB0eXBlIH0pIHsKICAgIHRyeSB7CiAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZXN0aW1hdGVHYXMyKGNsaWVudCwgewogICAgICAgIC4uLnJlcXVlc3QsCiAgICAgICAgYWNjb3VudDogcmVxdWVzdD8uYWNjb3VudAogICAgICB9KTsKICAgICAgY29uc3QgeyBwcmlvcml0eUZlZVBlckdhczogbWF4UHJpb3JpdHlGZWVQZXJHYXMgfSA9IHJlc3BvbnNlOwogICAgICBjb25zdCBiYXNlRmVlUGVyR2FzID0gbXVsdGlwbHkoQmlnSW50KHJlc3BvbnNlLmJhc2VGZWVQZXJHYXMpKTsKICAgICAgY29uc3QgbWF4RmVlUGVyR2FzID0gYmFzZUZlZVBlckdhcyArIG1heFByaW9yaXR5RmVlUGVyR2FzOwogICAgICBpZiAodHlwZSA9PT0gImxlZ2FjeSIpCiAgICAgICAgcmV0dXJuIHsgZ2FzUHJpY2U6IG1heEZlZVBlckdhcyB9OwogICAgICByZXR1cm4gewogICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICBtYXhQcmlvcml0eUZlZVBlckdhcwogICAgICB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uZXR3b3JrOiAibGlzayIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLmFwaS5saXNrLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vYmxvY2tzY291dC5saXNrLmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9ibG9ja3Njb3V0Lmxpc2suY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4QTlkNzFFMWRkN2NhMjZGMjZlNjU2RTY2ZDZBQTgxZWQ3Zjc0NWJmMCIKICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQxOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDExM2NCOTkyODNBRjI0MkRhMEEwQzU0MzQ3NjY3ZWRGNTMxQWE3ZDYiCiAgICAgICAgfQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQxOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDI2ZEI5M0Y4YjhiNGY3MDE2MjQwYWY2MkY3NzMwOTc5ZDM1M2Y5QTciCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMTldOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHgyNjU4NzIz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mYXVsdDogewogICAgICAgIG5hbWU6ICJNYW50YSBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9wYWNpZmljLWV4cGxvcmVyLm1hbnRhLm5ldHdvcmsiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vcGFjaWZpYy1leHBsb3Jlci5tYW50YS5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAzMzI4OTAKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21hbnRhU2Vwb2xpYVRlc3RuZXQuanMKICB2YXIgbWFudGFTZXBvbGlhVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMzQ0MTAwNiwKICAgIG5hbWU6ICJNYW50YSBQYWNpZmljIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuZXR3b3JrOiAibWFudGEtc2Vwb2xpYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFVEgiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3BhY2lmaWMtcnBjLnNlcG9saWEtdGVzdG5ldC5tYW50YS5uZXR3b3JrL2h0dHAiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNYW50YSBTZXBvbG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wbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vcGFjaWZpYy1leHBsb3Jlci50ZXN0bmV0Lm1hbnRhLm5ldHdvcmsiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vcGFjaWZpYy1leHBsb3Jlci50ZXN0bmV0Lm1hbnRhLm5ldHdvcmsvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHgyMTFCMTY0M2I5NUZlNzZmMTFlRDg4ODBFRTgxMEFCRDlBNGNmNTZDIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDQxOTkxNQogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21hbnRsZS5qcwogIHZhciBtYW50bGUgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDVlMywKICAgIG5hbWU6ICJNYW50bGUiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiTU5UIiwKICAgICAgc3ltYm9sOiAiTU5UIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjLm1hbnRsZS54eXoiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNYW50bGUgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vbWFudGxlc2Nhbi54eXovIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS5tYW50bGVzY2FuLnh5ei9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IH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iLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL3JwYy5tZXJsaW5jaGFpbi5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vc2Nhbi5tZXJsaW5jaGFpbi5pbyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9zY2FuLm1lcmxpbmNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGFjaGFpbi5qcwogIHZhciBtZXRhY2hhaW4gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDU3MSwKICAgIG5hbWU6ICJNZXRhQ2hhaW4gTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiTWV0YXRpbWUgQ29pbiIsIHN5bWJvbDogIk1UQyIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5tZXRhdGltZS5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNZXRhRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubWV0YXRpbWUuY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAw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JFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5taW50Y2hhaW4uaW8iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNaW50Y2hhaW4gZXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubWludGNoYWluLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9taW50U2Vwb2xpYVRlc3RuZXQuanMKICB2YXIgbWludFNlcG9saWFUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxNjg2LAogICAgbmFtZTogIk1pbnQgU2Vwb2xpYSBUZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLm1pbnRjaGFpbi5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1pbnRjaGFpbiBUZXN0bmV0IGV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIubWludGNoYWluLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21vZGUuanMKICB2YXIgc291cmNlSWQyMiA9IDE7CiAgdmFyIG1vZGUgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDM0NDQzLAogICAgbmFtZTogIk1vZGUgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tYWlubmV0Lm1vZGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1vZGVzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL21vZGVzY2FuLmlvIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDI0NjU4ODIKICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyMl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDQzMTdiYTE0NkQ0OTMzRDg4OTUxOGEzZTVFMTFGZTdhNTMxOTliMDQiCiAgICAgICAgfQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQyMl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDhCMzRiMTRjN2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kZWZpbmVDaGFpbih7CiAgICBpZDogMTI4NywKICAgIG5hbWU6ICJNb29uYmFzZSBBbHBoYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJERVYiLAogICAgICBzeW1ib2w6ICJERVYiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5hcGkubW9vbmJhc2UubW9vbmJlYW0ubmV0d29yayJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly93c3MuYXBpLm1vb25iYXNlLm1vb25iZWFtLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNb29uc2NhbiIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9tb29uYmFzZS5tb29uc2Nhbi5pbyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9tb29uYmFzZS5tb29uc2Nhbi5pby9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTg1MDY4NgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21vb25iZWFtLmpzCiAgdmFyIG1vb25iZWFtID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMjg0LAogICAgbmFtZTogIk1vb25iZWFtIiwKICAgIG5hdGl2ZUN1cnJlb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CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJPZHlzc2V5IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL29keXNzZXktZXhwbG9yZXIuaXRoYWNhLnh5eiIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9vZHlzc2V5LWV4cGxvcmVyLml0aGFjYS54eXovYXBpIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL29rYy5qcwogIHZhciBva2MgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDY2LAogICAgbmFtZTogIk9LQyIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJPS1QiLAogICAgICBzeW1ib2w6ICJPS1QiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9leGNoYWlucnBjLm9rZXgub3JnIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAib2tsaW5rIiwKICAgICAgICB1cmw6ICJodHRwczovL3d3dy5va2xpbmsuY29tL29rYyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMDM2NDc5MgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92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Fpbi5vcmciXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJvcEJOQiAoQlNDU2NhbikiLAogICAgICAgIHVybDogImh0dHBzOi8vb3BibmIuYnNjc2Nhbi5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLW9wYm5iLmJzY3NjYW4uY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA1MTI4ODEKICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyNF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDE1M0NBQjc5ZjQ3NjdFMmZmODYyQzk0YWE0OTU3MzI5NEIxM0QxNjkiCiAgICAgICAgfQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQyNF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDE4NzZFQTc3MDJDMGFkMEM2QTJhZTYwMzZERTc3MzNlZGZCY2E1MTkiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMjRdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhGMDVGMGU0MzYyODU5YzMzMzFDYjkzOTVDQkMyMDFFM0ZhNjc1N0VhIgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIHNvdXJjZUlkOiBzb3VyY2VJZDI0CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvb3BCTkJUZXN0bmV0LmpzCiAgdmFyIHNvdXJjZUlkMjUgPSA5NzsKICB2YXIgb3BCTkJUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA1NjExLAogICAgbmFtZTogIm9wQk5CIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAidEJOQiIsCiAgICAgIHN5bWJvbDogInRCTkIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9vcGJuYi10ZXN0bmV0LXJwYy5ibmJjaGFpbi5vcmciXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJvcGJuYnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vdGVzdG5ldC5vcGJuYnNjYW4uY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDM3MDUxMDgKICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyNV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEZmMjM5NEJiODQzMDEyNTYyZjQzNDlDNjYzMmEwRWNCOTJmQzg4MTAiCiAgICAgICAgfQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQyNV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDQzODZDOEFCZjIwMDlhQz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pbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQyNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGU1OTY1QWI1OTYyZURjNzQ3N0M4NTIwMjQzQTk1NTE3Q0QyNTJmQTkiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDI2XTogewogICAgICAgICAgYWRkcmVzczogIjB4ZGZlOTc4NjgyMzNkMWFhMjJlODE1YTI2Njk4MmYyY2YxNzY4NWEyNyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDQyODYyNjMKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjZdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhiRWI1RmM1NzkxMTUwNzE3NjRjNzQyM0E0ZjEyZURkZTQxZjEwNkVkIgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDI2XTogewogICAgICAgICAgYWRkcmVzczogIjB4OTlDOWZjNDZmOTJFOGExYzBkZUMxYjE3NDdkMDEwOTAzRTg4NGJFMSIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICBzb3VyY2VJZDogc291cmNlSWQyNgogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL29wdGltaXNtR29lcmxpLmpzCiAgdmFyIHNvdXJjZUlkMjcgPSA1OwogIHZhciBvcHRpbWlzbUdvZXJsaSA9IC8qI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ybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9ycGMucHVibGljZ29vZHMubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlBHTiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5wdWJsaWNnb29kcy5uZXR3b3JrIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLnB1YmxpY2dvb2RzLm5ldHdvcmsvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7CiAgICAgICAgW3NvdXJjZUlkMjldOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHg5RTYyMDRGNzUwY0Q4NjZiMjk5NTk0ZTJhQzllQTgyNEUyZTVmOTVjIgogICAgICAgIH0KICAgICAgfSwKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMzM4MDIwOQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQyOV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGIyNkZkOTg1YzU5NTliQkIzODJCQUZkRDBiODc5RTE0OWU0ODExNmMiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMjldOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhEMDIwNEI5NTI3QzFiQTdiRDc2NUZhNUNDRDkzNTVkMzgzMzgyNzJiIgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIGZvcm1hdHRlcnM6IGZvcm1hdHRlcnMyLAogICAgc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ICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIucmVkc3RvbmUueHl6IgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzMl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEM3YkNiMGU4ODM5YTI4QTFjRmFkZDFDRjcxNmRlOTAxNkNkQTUxYWUiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTU3ODMyOQogICAgICAgIH0KICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQzMl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGE0MjZBMDUyZjY1N0FFRWVmYzI5OGIzQjVjMzVhNDcwZTQ3MzlkNjkiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAxOTU3ODMzNwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDMyXTogewogICAgICAgICAgYWRkcmVzczogIjB4YzQ3M2NhN0UwMmFmMjRjMTI5YzJlRWY1MUYyYURmMDQxMWMxRGY2OSIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDE5NTc4MzMxCiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGV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ExMTU1MTExOwogIHZhciBzaGFwZVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDExMDExLAogICAgbmFtZTogIlNoYXBlIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiU2Vwb2xpYSBFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEuc2hhcGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXItc2Vwb2xpYS5zaGFwZS5uZXR3b3JrLyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci1zZXBvbGlhLnNoYXBlLm5ldHdvcmsvYXBpL3YyIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDEKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQzNgogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoYXJkZXVtU3BoaW54LmpzCiAgdmFyIHNoYXJkZXVtU3BoaW54ID0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hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlNoaW1tZXIiLAogICAgICBzeW1ib2w6ICJTTVIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS5zaGltbWVyLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTaGltbWVyIE5ldHdvcmsgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZXZtLnNoaW1tZXIubmV0d29yayIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5ldm0uc2hpbW1lci5uZXR3b3JrL2FwaSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NoaW1tZXJUZXN0bmV0LmpzCiAgdmFyIHNoaW1tZXJUZXN0bmV0ID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMDczLAogICAgbmFtZTogIlNoaW1tZXIgVGVzdG5ldCIsCiAgICBuZXR3b3JrOiAic2hpbW1lci10ZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlNoaW1tZXIiLAogICAgICBzeW1ib2w6ICJTTVIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2pzb24tcnBjLmV2bS50ZXN0bmV0LnNoaW1tZXIubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczog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DE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vdGVzdG5ldC5zbmF4Y2hhaW4uaW8iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTbmF4IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIuc25heGNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQzOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDIwNmE3NWQ4OWQ0NUYxNDZDNTQwMjBGMTMyRkY5M2JFREQwOWY1NUUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM4XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjBlM0EzNjhhNGNkQ0VmODVmZkI5NjRlMzcyNzI2RjU2QTQ2MjIxZSIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGI1YWZkZDBFOGRERjA4MUVmOTBlOEEzZTBjN2I1Nzk4ZTY2RTk1NEUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7C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RwczovL3NhdHVybi1leHBsb3Jlci5zd2FuY2hhaW4uaW8iCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvc3lzY29pbi5qcwogIHZhciBzeXNjb2luID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA1NywKICAgIG5hbWU6ICJTeXNjb2luIE1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiU3lzY29pbiIsCiAgICAgIHN5bWJvbDogIlNZUyIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLnN5c2NvaW4ub3JnIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3JwYy5zeXNjb2luLm9yZy93c3MiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTeXNjb2luRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuc3lzY29pbi5vcmciLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuc3lzY29pbi5vcmcvYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDI4NzEzOQogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQD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gKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vc2Vwb2xpYS51bmljaGFpbi5vcmciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJVbmlzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3NlcG9saWEudW5pc2Nhbi54eXoiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLXNlcG9saWEudW5pc2Nhbi54eXoiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMAogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQ0MF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDBkODNkYWI2MjlmMGUwRjlkMzZjMENiYzg5QjY5YTQ4OWYwNzUxYkQiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkNDBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhlYTU4ZmNBNjg0OWQ3OUVBZDFmMjY2MDg4NTVjMkQ2NDA3ZDU0Q2UyIgogICAgICAgIH0KICAgICAgfSwKICAgICAgZGlzcHV0ZUdhbWVGYWN0b3J5OiB7CiAgICAgICAgW3NvdXJjZUlkNDBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhlZmY3M2U1YWEzQjlBRUMzMmM2NTlBYTNFMDA0NDRkMjBhODQzOTRiIgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIHRlc3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VucmVhbCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAicmVFVEgiLAogICAgICBkZWNpbWFsczogMTgsCiAgICAgIHN5bWJvbDogInJlRVRIIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjLnVucmVhbC1vcmJpdC5nZWxhdG8uZGlnaXRhbCJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlVucmVhbCBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly91bnJlYWwuYmxvY2tzY291dC5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vdW5yZWFsLmJsb2Nrc2NvdXQuY29tL2FwaS92MiIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweDhiNkIwZTYwRDhDRDg0ODk4RWE4Yjk4MTA2NUExMkY4NzZlQTU2NzciLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTc0NQogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvdmVjaGFpbi5qcwogIHZhciB2ZWNoYWluID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMDAwMDksCiAgICBuYW1lOiAiVmVjaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiVmVDaGFpbiIsIHN5bWJvbDogIlZFVCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5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ZUNoYWluKHsKICAgIGlkOiA3MDAxLAogICAgbmFtZTogIlpldGFDaGFpbiBBdGhlbnMgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJaZXRhIiwKICAgICAgc3ltYm9sOiAiYVpFVEEiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3pldGFjaGFpbi1hdGhlbnMtZXZtLmJsb2NrcGkubmV0d29yay92MS9ycGMvcHVibGljIl0KICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAyNzE1MjE3CiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlpldGFTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2F0aGVucy5leHBsb3Jlci56ZXRhY2hhaW4uY29tIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3poZWppYW5nLmpzCiAgdmFyIHpoZWppYW5nID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMzM3ODAzLAogICAgbmFtZTogIlpoZWppYW5nIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJaaGVqaWFuZyBFdGhlciIsIHN5bWJvbDogIlpoZWpFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgIC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F1bHQ6IHsKICAgICAgICBuYW1lOiAiWmlyY3VpdCBUZXN0bmV0IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnRlc3RuZXQuemlyY3VpdC5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogNjA0MDI4NwogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3prRmFpci5qcwogIHZhciB6a0ZhaXIgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDQyNzY2LAogICAgbmFtZTogIlpLRmFpciBNYWlubmV0IiwKICAgIG5ldHdvcms6ICJ6a2ZhaXItbWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJVU0QgQ29pbiIsCiAgICAgIHN5bWJvbDogIlVTREMiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy56a2ZhaXIuaW8iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJ6a0ZhaXIgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vc2Nhbi56a2ZhaXIuaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vc2Nhbi56a2ZhaXIuaW8vYXBpIgogICAgICB9CiAgICB9LAogIC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AgICAgIG5hbWU6ICJ6a0xpbmsgTm92YSBCbG9jayBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9zZXBvbGlhLmV4cGxvcmVyLnprbGluay5pbyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3prc3luYy5qcwogIHZhciB6a3N5bmMgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcsCiAgICBpZDogMzI0LAogICAgbmFtZTogIlpLc3luYyBFcmEiLAogICAgbmV0d29yazogInprc3luYy1lcmEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5uZXQuZXJhLnprc3luYy5pbyJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly9tYWlubmV0LmVyYS56a3N5bmMuaW8vd3MiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFdGhlcnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vZXJhLnprc3luYy5uZXR3b3JrLyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9hcGktZXJhLnprc3luYy5uZXR3b3JrL2FwaSIKICAgICAgfSwKICAgICAgbmF0aXZlOiB7CiAgICAgICAgbmFtZTogIlpLc3luYyBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci56a3N5bmMuaW8vIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL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lZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiA3Nzc3Nzc3LAogICAgbmFtZTogIlpvcmEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy56b3JhLmVuZXJneSJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly9ycGMuem9yYS5lbmVyZ3kiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci56b3JhLmVuZXJneSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3Jlci56b3JhLmVuZXJneS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQ0M106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDlFNjIwNEY3NTBjRDg2NmIyOTk1OTRlMmFDOWVBODI0RTJlNWY5NWMiCiAgICAgICAgfQogICAgICB9LAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiRTJhMTczOTc2Q0ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA1ODgyCiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDQzXTogewogICAgICAgICAgYWRkcmVzczogIjB4MWEwYWQwMTE5MTNBMTUwZjY5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ID0gYXJncy5jYXVzZSBpbnN0YW5jZW9mIF9CYXNlRXJyb3IgPyBhcmdzLmNhdXNlLmRvY3NQYXRoIHx8IGFyZ3MuZG9jc1BhdGggOiBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgY29uc3QgbWVzc2FnZSA9IFsKICAgICAgICAgICAgc2hvcnRNZXNzYWdlIHx8ICJBbiBlcnJvciBvY2N1cnJlZC4iLAogICAgICAgICAgICAiIiwKICAgICAgICAgICAgLi4uYXJncy5tZXRhTWVzc2FnZXMgPyBbLi4uYXJncy5tZXRhTWVzc2FnZXMsICIiXSA6IFtdLAogICAgICAgICAgICAuLi5kb2NzUGF0aDkgPyBbYERvY3M6IGh0dHBzOi8vYWJpdHlwZS5kZXYke2RvY3NQYXRoOX1gXSA6IFtdLAogICAgICAgICAgICAuLi5kZXRhaWxzID8gW2BEZXRhaWxzOiAke2RldGFpbHN9YF0gOiBbXSwKICAgICAgICAgICAgYFZlcnNpb246IGFiaXR5cGVAJHt2ZXJzaW9ufWAKICAgICAgICAgIF0uam9pbigiXG4iKTsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkZXRhaWxzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZG9jc1BhdGgiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtZXRhTWVzc2FnZXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaG9ydE1lc3NhZ2UiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkFiaVR5cGVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKGFyZ3MuY2F1c2UpCiAgICAgICAgICAgIHRoaXMuY2F1c2UgPSBhcmdzLmNhdXNlOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5zaG9ydE1lc3NhZ2UgPSBzaG9ydE1lc3NhZ2U7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZH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AgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIlVua25vd25UeXBlRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVua25vd25Tb2xpZGl0eVR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoIlVua25vd24gdHlwZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogW2BUeXBlICIke3R5cGV9IiBpcyBub3QgYSB2YWxpZCBBQkkgdHlwZS5gXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNvbGlkaXR5VHlwZUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9lcnJvcnMvYWJpUGFyYW1ldGVyLmpzCiAgdmFyIEludmFsaWRBYmlQYXJhbWV0ZXJFcnJvciwgSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciwgSW52YWxpZFBhcmFtZXRlckVycm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BCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW1zIH0pIHsKICAgICAgICAgIHN1cGVyKCJGYWlsZWQgdG8gcGFyc2UgQUJJIHBhcmFtZXRlcnMuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBgcGFyc2VBYmlQYXJhbWV0ZXJzKCR7SlNPTi5zdHJpbmdpZnkocGFyYW1zLCBudWxsLCAyKX0pYCwKICAgICAgICAgICAgZG9jc1BhdGg6ICIvYXBpL2h1bWFuI3BhcnNlYWJpcGFyYW1ldGVycy0xIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiSW52YWxpZEFiaVBhcmFtZXRlcnNFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgSW52YWxpZFBhcmFtZXRlckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0gfSkgewogICAgICAgICAgc3VwZXIoIkludmFsaWQgQUJJIHBhcmFtZXRlci4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHBhcmFtCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6ICJJbnZhbGlkUGFyYW1ldGVyRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAg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PyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gCiAgICAgICAgICAgIF0KICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRNb2RpZmllckVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRnVuY3Rpb25Nb2RpZmllckVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgcGFyYW0sIHR5cGUsIG1vZGlmaWVyIH0pIHsKICAgICAgICAgIHN1cGVyKCJJbnZhbGlkIEFCSSBwYXJhbWV0ZXIuIiwgewogICAgICAgICAgICBkZXRhaWxzOiBwYXJhbSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgYE1vZGlmaWVyICIke21vZGlmaWVyfSIgbm90IGFsbG93ZWQke3R5cGUgPyBgIGluICIke3R5cGV9IiB0eXBlYCA6ICIifS5gLAogICAgICAgICAgICAgIGBEYXRhIGxvY2F0aW9uIGNhbiBvbmx5IGJlIHNwZWNpZmllZCBmb3IgYXJyYXksIHN0cnVjdCwgb3IgbWFwcGluZyB0eXBlcywgYnV0ICIke21vZGlmaWVyfSIgd2FzIGdpdmVuLmAKICAgICAgICAgICAgXQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAg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DEuMC42L25vZGVfbW9kdWxlcy9hYml0eXBlL2Rpc3QvZXNtL2h1bWFuLXJlYWRhYmxlL2Vycm9ycy9zaWduYXR1cmUuanMiKCkgewogICAgICBpbml0X2Vycm9ycygpOwogICAgICBJbnZhbGlkU2lnbmF0dXJlRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzaWduYXR1cmUsIHR5cGUgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgJHt0eXBlfSBzaWduYXR1cmUuYCwgewogICAgICAgICAgICBkZXRhaWxzOiBzaWduYXR1cmUKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkludmFsaWRTaWduYXR1cmVFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgVW5rbm93blNpZ25hdHVyZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKHsgc2lnbmF0dXJlIH0pIHsKICAgICAgICAgIHN1cGVyKCJVbmtub3duIHNpZ25hdHVyZS4iLCB7CiAgICAgICAgICAgIGRldGFpbHM6IHNpZ25hdHVyZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiVW5rbm93blNpZ25hdHVyZUVycm9yIgogICA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ID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoWwogICAgICAgIC8vIFVubmFtZWQKICAgICAgICBbImFkZHJlc3MiLCB7IHR5cGU6ICJhZGRyZXNzIiB9XSwKICAgICAgICBbImJvb2wiLCB7IHR5cGU6ICJib29sIiB9XSwKICAgICAgICBbImJ5dGVzIiwgeyB0eXBlOiAiYnl0ZXMiIH1dLAogICAgICAgIFsiYnl0ZXMzMiIsIHsgdHlwZTogImJ5dGVzMzIiIH1dLAogICAgICAgIFsiaW50IiwgeyB0eXBlOiAiaW50MjU2IiB9XSwKICAgICAgICBbImludDI1NiIsIHsgdHlwZTogImludDI1NiIgfV0sCiAgICAgICAgWyJzdHJpbmciLCB7IHR5cGU6ICJzdHJpbmciIH1dLAogICAgICAgIFsidWludCIsIHsgdHlwZTogInVpbnQyNTYiIH1dLAogICAgICAgIFsidWludDgiLCB7IHR5cGU6ICJ1aW50OCIgfV0sCiAgICAgICAgWyJ1aW50MTYiLCB7IHR5cGU6ICJ1aW50MTYiIH1dLAogICAgICAgIFsidWludDI0IiwgeyB0eXBlOiAidWludDI0IiB9XSwKICAgICAgICBbInVpbnQzMiIsIHsgdHlwZTogInVpbnQzMiIgfV0sCiAgICAgICAgWyJ1aW50NjQiLCB7IHR5cGU6ICJ1aW50NjQiIH1dLAogICAgICAgIFsidWludDk2IiwgeyB0eXBlOiAidWludDk2IiB9XSwKICAgICAgICBbInVpbnQxMTIiLCB7IHR5cGU6ICJ1aW50MTEyIiB9XSwKICAgICAgICBbInVpbnQxNjAiLCB7IHR5cGU6ICJ1aW50MTYwIiB9XSwKICAgICAgICBbInVpbnQxOTIiLCB7IHR5cGU6ICJ1aW50MTkyIiB9XSwKICAgICAgICBbInVpbnQyNTYiLCB7IHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgICAvLyBOYW1lZAogICAgICAgIFsiYWRkcmVzcyBvd25lciIsIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAib3duZXIiIH1dLAogICAgICA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ICAgICBtb2RpZmllcnM6IGZ1bmN0aW9uTW9kaWZpZXJzLAogICAgICAgICAgICBzdHJ1Y3RzLAogICAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB7CiAgICAgICAgbmFtZTogbWF0Y2gubmFtZSwKICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgIHN0YXRlTXV0YWJpbGl0eTogbWF0Y2guc3RhdGVNdXRhYmlsaXR5ID8/ICJub25wYXlhYmxlIiwKICAgICAgICBpbnB1dHMsCiAgICAgICAgb3V0cHV0cwogICAgICB9OwogICAgfQogICAgaWYgKGlzRXZlbnRTaWduYXR1cmUoc2lnbmF0dXJlKSkgewogICAgICBjb25zdCBtYXRjaCA9IGV4ZWNFdmVudFNpZ25hdHVyZShzaWduYXR1cmUpOwogICAgICBpZiAoIW1hdGNoKQogICAgICAgIHRocm93IG5ldyBJbnZhbGlkU2lnbmF0dXJlRXJyb3IoeyBzaWduYXR1cmUsIHR5cGU6ICJldmVudCIgfSk7CiAgICAgIGNvbnN0IHBhcmFtcyA9IHNwbGl0UGFyYW1ldGVycyhtYXRjaC5wYXJhbWV0ZXJzKTsKICAgICAgY29uc3QgYWJpUGFyYW1ldGVycyA9IFtdOwogICAgICBjb25zdCBsZW5ndGggPSBwYXJhbXMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgYWJpUGFyYW1ldGVycy5wdXNoKHBhcnNlQWJpUGFyYW1ldGVyKHBhcmFtc1tpXSwgewogICAgICAgICAgbW9kaWZpZXJzOiBldmVudE1vZGlmaWVycywKICAgICAgICAgIHN0cnVjdHMsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiB7IG5hbWU6IG1hdGNoLm5hbWUsIHR5cGU6ICJldmVudCIsIGl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XJyb3IoeyBhYmlQYXJhbWV0ZXIgfSk7CiAgICAgICAgY29uc3QgeyBhcnJheSwgdHlwZSB9ID0gbWF0Y2g7CiAgICAgICAgaWYgKHR5cGUgaW4gc3RydWN0cykgewogICAgICAgICAgaWYgKGFuY2VzdG9ycy5oYXModHlwZSkpCiAgICAgICAgICAgIHRocm93IG5ldyBDaXJjdWxhclJlZmVyZW5jZUVycm9yKHsgdHlwZSB9KTsKICAgICAgICAgIGNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgICAgIC4uLmFiaVBhcmFtZXRlciwKICAgICAgICAgICAgdHlwZTogYHR1cGxlJHthcnJheSA/PyAiIn1gLAogICAgICAgICAgICBjb21wb25lbnRzOiByZXNvbHZlU3RydWN0cyhzdHJ1Y3RzW3R5cGVdID8/IFtdLCBzdHJ1Y3RzLCAvKiBAX19QVVJFX18gKi8gbmV3IFNldChbLi4uYW5jZXN0b3JzLCB0eXBlXSkpCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGlzU29saWRpdHlUeXBlKHR5cGUpKQogICAgICAgICAgICBjb21wb25lbnRzLnB1c2goYWJpUGFyYW1ldGVyKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgdGhyb3cgbmV3IFVua25vd25UeXBlRXJyb3IoeyB0eXBlIH0pOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGNvbXBvbmVudHM7CiAgfQogIHZhciB0eXBlV2l0aG91dFR1cGxlUmVnZXg7CiAgdmFyIGluaXRfc3RydWN0cyA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vYWJpdHlwZUAxLjAuNi9ub2RlX21vZHVsZXMvYWJpdHlwZS9kaXN0L2VzbS9odW1hbi1yZWFkYWJsZS9ydW50aW1lL3N0cnVjdHMuanMiKCkgewogICAgICBpbml0X3JlZ2V4KCk7CiAgICAgIGluaXRfYWJpSXRlbSgpOwogICAgICBpbml0X2FiaVBhcmF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Jhc2VFcnJvciBleHRlbmRzIEVycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihzaG9ydE1lc3NhZ2UsIGFyZ3MgPSB7fSkgewogICAgICAgICAgY29uc3QgZGV0YWlscyA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kZXRhaWxzOwogICAgICAgICAgICBpZiAoYXJncy5jYXVzZT8ubWVzc2FnZSkKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5tZXNzYWdlOwogICAgICAgICAgICByZXR1cm4gYXJncy5kZXRhaWxzOwogICAgICAgICAgfSkoKTsKICAgICAgICAgIGNvbnN0IGRvY3NQYXRoOSA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChhcmdzLmNhdXNlIGluc3RhbmNlb2YgX0Jhc2VFcnJvcikKICAgICAgICAgICAgICByZXR1cm4gYXJncy5jYXVzZS5kb2NzUGF0aCB8fCBhcmdzLmRvY3NQYXRoOwogICAgICAgICAgICByZXR1cm4gYXJncy5kb2NzUGF0aDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBkb2NzVXJsID0gZXJyb3JDb25maWcuZ2V0RG9jc1VybD8uKHsgLi4uYXJncywgZG9jc1BhdGg6IGRvY3NQYXRoOSB9KTsKICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBbCiAgICAgICAgICAgIHNob3J0TWVzc2FnZSB8fCAiQW4gZXJyb3Igb2NjdXJyZWQuIiwKICAgICAgICAgICAgIiIsCiAgICAgICAgICAgIC4uLmFyZ3MubWV0YU1lc3NhZ2VzID8gWy4uLmFyZ3MubWV0YU1lc3NhZ2VzLCAiIl0gOiBbXSwKICAgICAgICAgICAgLi4uZG9jc1VybCA/IFtgRG9jczogJHtkb2NzVXJsfWBdIDogW10sCiAgICAgICAgICAgIC4uLmRldGFpbHMgPyBbYERldGFpbHM6ICR7ZGV0YWlsc31gXSA6IFtdLAogICAgICAgICAgICAuLi5lcnJvckNvbmZpZy52ZXJzaW9uID8gW2BWZXJzaW9uOiAke2Vycm9yQ29uZmlnLnZlcnNpb259YF0gOiBbXQogICAgICAgICAgXS5qb2luKCJcbiIpOwogICAgICAgICAgc3VwZXIobWVzc2FnZSwgYXJncy5jYXVzZSA/IHsgY2F1c2U6IGFyZ3MuY2F1c2UgfSA6IHZvaWQgMCk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRldGFpbHMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkb2NzUGF0aCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm1ldGFNZXNzYWdlcyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNob3J0TWVzc2FnZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInZlcnNpb24iLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJuYW1lIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogIkJhc2VFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgdGhpcy5kZXRhaWxzID0gZGV0YWlsczsKICAgICAgICAgIHRoaXMuZG9jc1BhdGggPSBkb2NzUGF0aDk7CiAgICAgICAgICB0aGlzLm1ldGFNZXNzYWdlcyA9IGFyZ3MubWV0YU1lc3NhZ2VzOwogICAgICAgICAgdGhpcy5uYW1lID0gYXJncy5uYW1lID8/IHRoaXMubmFtZTsKICAgICAgICAgIHRoaXMuc2hvcnRNZXNzYWdlID0gc2hvcnRNZXNzYWdlOwogICAgICAgICAgdGhpcy52ZXJzaW9uID0gdmVyc2lvbjI7CiAgICAgICAgfQogICAgICAgIHdhbGsoZm4pIHsKICAgICAgICAgIHJldHVybiB3YWxrKHRoaXMsIGZuKTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9lcnJvcnMvYWJpLmpzCiAgdmFyIEFiaU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9yIGdpdmVuIHBhcmFtZXRlcnMuYF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgUGFyYW1zOiAoJHtmb3JtYXRBYmlQYXJhbXMocGFyYW1zLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pfSlgLAogICAgICAgICAgICAgIGBEYXRhOiAgICR7ZGF0YX0gKCR7c2l6ZTN9IGJ5dGVzKWAKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkFiaURlY29kaW5nRGF0YVNpemVUb29TbWFsbEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImRhdGEiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJwYXJhbXMiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuZGF0YSA9IGRhdGE7CiAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcm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b250YWluIGFueSBwYXJhbWV0ZXJzIChcYGlucHV0c1xgKS5gLAogICAgICAgICAgICAiQ2Fubm90IGVuY29kZSBlcnJvciByZXN1bHQgd2l0aG91dCBrbm93aW5nIHdoYXQgdGhlIHBhcmFtZXRlciB0eXBlcyBhcmUuIiwKICAgICAgICAgICAgIk1ha2Ugc3VyZSB5b3UgYXJlIHVzaW5nIHRoZSBjb3JyZWN0IEFCSSBhbmQgdGhhdCB0aGUgaW5wdXRzIGV4aXN0IG9uIGl0LiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBuYW1lOiAiQWJpRXJyb3JJbnB1dHNOb3RGb3VuZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBBYmlFcnJvck5vdEZvdW5kRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKGVycm9yTmFtZSwgeyBkb2NzUGF0aDogZG9jc1BhdGg5IH0gPSB7fSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgRXJyb3IgJHtlcnJvck5hbWUgPyBgIiR7ZXJyb3JOYW1lfSIgYCA6ICIifW5vdCBmb3VuZCBvbiBBQkkuYCwKICAgICAgICAgICAgIk1ha2Ugc3VyZSB5b3UgYXJlIHVzaW5nIHRoZSBjb3JyZWN0IEFCSSBhbmQgdGhhdCB0aGUgZXJyb3IgZXhpc3RzIG9uIGl0LiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgewogICAgICAgICAgICBkb2NzUGF0aDogZG9jc1BhdGg5LAogICAgICAgICAgICBuYW1lOiAiQWJpRXJyb3JOb3RGb3VuZEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBBYmlFcnJvclNpZ25hdHVyZU5vdEZvdW5kRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2V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gICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJkYXRhIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAicGFyYW1zIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAic2l6ZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaUl0ZW0gPSBhYmlJdGVtOwogICAgICAgICAgdGhpcy5kYXRhID0gZGF0YTsKICAgICAgICAgIHRoaXMucGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgdGhpcy5zaXplID0gc2l6ZTM7CiAgICAgICAgfQogICAgICB9OwogICAgICBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhYmlJdGVtLCBwYXJhbSB9KSB7CiAgICAgICAgICBzdXBlcihbCiAgICAgICA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dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSwgeyBkb2NzUGF0aDogZG9jc1BhdGg5IH0pIHsKICAgICAgICAgIHN1cGVyKFsKICAgICAgICAgICAgYFR5cGUgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlY29kaW5nIHR5cGUuYCwKICAgICAgICAgICAgIlBsZWFzZSBwcm92aWRlIGEgdmFsaWQgQUJJIHR5cGUuIgogICAgICAgICAgXS5qb2luKCJcbiIpLCB7IGRvY3NQYXRoOiBkb2NzUGF0aDksIG5hbWU6ICJJbnZhbGlkQWJpRGVjb2RpbmdUeXBlIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEludmFsaWRBcnJheUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih2YWx1ZSkgewogICAgICAgICAgc3VwZXIoW2BWYWx1ZSAiJHt2YWx1ZX0iIGlzIG5vdCBhIHZhbGlkIGFycmF5LmBdLmpvaW4oIlxuIiksIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBcnJheUVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkRGVmaW5pdGlvblR5cGVFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IodHlwZSkgewogICAgICAgICAgc3VwZXIoWwogICAgICAgICAgICBgIiR7dHlwZX0iIGlzIG5vdCBhIHZhbGlkIGRlZmluaXRpb24gdHlwZS5gLAogICAgICAgICAgICAnVmFsaWQgdHlwZXM6ICJmdW5jdGlvbiIsICJldmVudCIsICJlcnJvciInCiAgICAgICAgICBdLmpvaW4oIlxuIiksIHsgbmFtZTogIkludmFsaWREZWZpbml0aW9uVHlwZUVycm9yIiB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFVuc3VwcG9ydGVkUGFja2V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RzID0gdHlwZW9mIHRvT3JPcHRzID09PSAic3RyaW5nIiA/IHsgdG86IHRvT3JPcHRzIH0gOiB0b09yT3B0czsKICAgIGNvbnN0IHRvID0gb3B0cy50bzsKICAgIGlmICh0byA9PT0gIm51bWJlciIpCiAgICAgIHJldHVybiBoZXhUb051bWJlcihoZXgsIG9wdHMpOwogICAgaWYgKHRvID09PSAiYmlnaW50IikKICAgICAgcmV0dXJuIGhleFRvQmlnSW50KGhleCwgb3B0cyk7CiAgICBpZiAodG8gPT09ICJzdHJpbmciKQogICAgICByZXR1cm4gaGV4VG9TdHJpbmcoaGV4LCBvcHRzKTsKICAgIGlmICh0byA9PT0gImJvb2xlYW4iKQogICAgICByZXR1cm4gaGV4VG9Cb29sKGhleCwgb3B0cyk7CiAgICByZXR1cm4gaGV4VG9CeXRlcyhoZXgsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBoZXhUb0JpZ0ludChoZXgsIG9wdHMgPSB7fSkgewogICAgY29uc3QgeyBzaWduZWQgfSA9IG9wdHM7CiAgICBpZiAob3B0cy5zaXplKQogICAgICBhc3NlcnRTaXplKGhleCwgeyBzaXplOiBvcHRzLnNpemUgfSk7CiAgICBjb25zdCB2YWx1ZSA9IEJpZ0ludChoZXgpOwogICAgaWYgKCFzaWduZWQpCiAgICAgIHJldHVybiB2YWx1ZTsKICAgIGNvbnN0IHNpemUzID0gKGhleC5sZW5ndGggLSAyKSAvIDI7CiAgICBjb25zdCBtYXggPSAoMW4gPDwgQmlnSW50KHNpemUzKSAqIDhuIC0gMW4pIC0gMW47CiAgICBpZiAodmFsdWUgPD0gbWF4KQogICAgICByZXR1cm4gdmFsdWU7CiAgICByZXR1cm4gdmFsdWUgLSBCaWdJbnQoYDB4JHsiZiIucGFkU3RhcnQoc2l6ZTMgKiAyLCAiZiIpfWApIC0gMW47CiAgfQogIGZ1bmN0aW9uIGhleFRvQm9vbChoZXhfLCBvcHRzID0ge30pIHsKICAgIGxldCBoZXggPSBoZXhfOwogICAg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xlcy9Abm9ibGUvaGFzaGVzL2VzbS9zaGEzLmpzIigpIHsKICAgICAgaW5pdF9hc3NlcnQoKTsKICAgICAgaW5pdF91NjQoKTsKICAgICAgaW5pdF91dGlsczIoKTsKICAgICAgU0hBM19QSSA9IFtdOwogICAgICBTSEEzX1JPVEwgPSBbXTsKICAgICAgX1NIQTNfSU9UQSA9IFtdOwogICAgICBfMG4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDApOwogICAgICBfMW4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDEpOwogICAgICBfMm4gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDIpOwogICAgICBfN24gPSAvKiBAX19QVVJFX18gKi8gQmlnSW50KDcpOwogICAgICBfMjU2biA9IC8qIEBfX1BVUkVfXyAqLyBCaWdJbnQoMjU2KTsKICAgICAgXzB4NzFuID0gLyogQF9fUFVSRV9fICovIEJpZ0ludCgxMTMpOwogICAgICBmb3IgKGxldCByb3VuZCA9IDAsIFIgPSBfMW4sIHggPSAxLCB5ID0gMDsgcm91bmQgPCAyNDsgcm91bmQrKykgewogICAgICAgIFt4LCB5XSA9IFt5LCAoMiAqIHggKyAzICogeSkgJSA1XTsKICAgICAgICBTSEEzX1BJLnB1c2goMiAqICg1ICogeSArIHgpKTsKICAgICAgICBTSEEzX1JPVEwucHVzaCgocm91bmQgKyAxKSAqIChyb3VuZCArIDIpIC8gMiAlIDY0KTsKICAgICAgICBsZXQgdCA9IF8wbjsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDc7IGorKykgewogICAgICAgICAgUiA9IChSIDw8IF8xbiBeIChSID4+IF83bikgKiBfMHg3MW4pICUgXzI1Nm47CiAgICAgICAgICBpZiAoUiAmIF8ybikKICAgICAgICAgICAgdCBePSBfMW4gPDwgKF8xbiA8PCAvKiBAX19QVVJFX18gKi8gQmlnSW50KGopKSAtIF8xbjsKICAgICAgICB9CiAgICAgICAgX1NIQTNfSU9UQS5wdXNoKHQpOwogICAg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cnJvcigiU2hhMyBzdXBwb3J0cyBvbmx5IGtlY2Nhay1mMTYwMCBmdW5jdGlvbiIpOwogICAgICAgICAgdGhpcy5zdGF0ZSA9IG5ldyBVaW50OEFycmF5KDIwMCk7CiAgICAgICAgICB0aGlzLnN0YXRlMzIgPSB1MzIodGhpcy5zdGF0ZSk7CiAgICAgICAgfQogICAgICAgIGtlY2NhaygpIHsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAga2VjY2FrUCh0aGlzLnN0YXRlMzIsIHRoaXMucm91bmRzKTsKICAgICAgICAgIGlmICghaXNMRSkKICAgICAgICAgICAgYnl0ZVN3YXAzMih0aGlzLnN0YXRlMzIpOwogICAgICAgICAgdGhpcy5wb3NPdXQgPSAwOwogICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiwgc3RhdGUgfSA9IHRoaXM7CiAgICAgICAgICBkYXRhID0gdG9CeXRlczIoZGF0YSk7CiAgICAgICAgICBjb25zdCBsZW4gPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDA7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGNvbnN0IHRha2UgPSBNYXRoLm1pbihibG9ja0xlbiAtIHRoaXMucG9zLCBsZW4gLSBwb3MpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRha2U7IGkrKykKICAgICAgICAgICAgICBzdGF0ZVt0aGlzLnBvcysrXSBePSBkYXRhW3BvcysrXTsKICAgICAgICAgICAgaWYgKHRoaXMucG9zID09PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGZpbmlzaCgpIHsKICAgICAgICAgIGlmICh0aGlzLmZpbmlzaGVkKQogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB0aGlzLmZpbmlzaGVkID0gdHJ1ZTsKICAgICAgICAgIGNvbnN0IHsgc3RhdGUsIHN1ZmZpeCwgcG9zLCBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIHN0YXRlW3Bvc10gXj0gc3VmZml4OwogICAgICAgICAgaWYgKChzdWZmaXggJiAxMjgpICE9PSAwICYmIHBvcyA9PT0gYmxvY2tMZW4gLSAxKQogICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgc3RhdGVbYmxvY2tMZW4gLSAxXSBePSAxMjg7CiAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgIH0KICAgICAgICB3cml0ZUludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcywgZmFsc2UpOwogICAgICAgICAgYnl0ZXMob3V0KTsKICAgICAgICAgIHRoaXMuZmluaXNoKCk7CiAgICAgICAgICBjb25zdCBidWZmZXJPdXQgPSB0aGlzLnN0YXRlOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiB9ID0gdGhpczsKICAgICAgICAgIGZvciAobGV0IHBvcyA9IDAsIGxlbiA9IG91dC5sZW5ndGg7IHBvcyA8IGxlbjsgKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnBvc091dCA+PSBibG9ja0xlbikKICAgICAgICAgICAgICB0aGlzLmtlY2NhaygpOwogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvc091dCwgbGVuIC0gcG9zKTsKICAgICAgICAgICAgb3V0LnNldChidWZmZXJPdXQuc3ViYXJyYXkodGhpcy5wb3NPdXQsIHRoaXMucG9zT3V0ICsgdGFrZSksIHBvcyk7CiAgICAgICAgICAgIHRoaXMucG9zT3V0ICs9IHRha2U7CiAgICAgICAgICAgIHBvcyArPSB0YWtlOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG91dDsKICAgICAgICB9CiAgICAgICAgeG9mSW50byhvdXQpIHsKICAgICAgICAgIGlmICghdGhpcy5lbmFibGVYT0YpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiWE9GIGlzIG5vdCBwb3NzaWJsZSBmb3IgdGhpcyBpbnN0YW5jZSIpOwogICAgICAgICAgcmV0dXJuIHRoaXMud3JpdGVJbnRvKG91dCk7CiAgICAgICAgfQogICAgICAgIHhvZihieXRlczIpIHsKICAgICAgICAgIG51bWJlcihieXRlczIpOwogICAgICAgICAgcmV0dXJuIHRoaXMueG9mSW50byhuZXcgVWludDhBcnJheShieXRlczIpKTsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIG91dHB1dChvdXQsIHRoaXMpOwogICAgICAgICAgaWYgKHRoaXMuZmluaXNoZWQpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZGlnZXN0KCkgd2FzIGFscmVhZHkgY2FsbGVkIik7CiAgICAgICAgICB0aGlzLndyaXRlSW50byhvdXQpOwogICAgICAgICAgdGhpcy5kZXN0cm95KCk7CiAgICAgICAgICByZXR1cm4gb3V0OwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5kaWdlc3RJbnRvKG5ldyBVaW50OEFycmF5KHRoaXMub3V0cHV0TGVuKSk7CiAgICAgICAgfQogICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICB0aGlzLnN0YXRlLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIGNvbnN0IHsgYmxvY2tMZW4sIHN1ZmZpeCwgb3V0cHV0TGVuLCByb3VuZHMsIGVuYWJsZVhPRiB9ID0gdGhpczsKICAgICAgICAgIHRvIHx8ICh0byA9IG5ld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pZ25hdHVyZS5sZW5ndGg7IGkrKykgewogICAgICBjb25zdCBjaGFyID0gc2lnbmF0dXJlW2ldOwogICAgICBpZiAoWyIoIiwgIikiLCAiLCJdLmluY2x1ZGVzKGNoYXIpKQogICAgICAgIGFjdGl2ZSA9IHRydWU7CiAgICAgIGlmIChjaGFyID09PSAiKCIpCiAgICAgICAgbGV2ZWwrKzsKICAgICAgaWYgKGNoYXIgPT09ICIpIikKICAgICAgICBsZXZlbC0tOwogICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICBjb250aW51ZTsKICAgICAgaWYgKGxldmVsID09PSAwKSB7CiAgICAgICAgaWYgKGNoYXIgPT09ICIgIiAmJiBbImV2ZW50IiwgImZ1bmN0aW9uIiwgIiJdLmluY2x1ZGVzKHJlc3VsdCkpCiAgICAgICAgICByZXN1bHQgPSAiIjsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICAgICAgaWYgKGNoYXIgPT09ICIpIikgewogICAgICAgICAgICB2YWxpZCA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gIiAiKSB7CiAgICAgICAgaWYgKHNpZ25hdHVyZVtpIC0gMV0gIT09ICIsIiAmJiBjdXJyZW50ICE9PSAiLCIgJiYgY3VycmVudCAhPT0gIiwoIikgewogICAgICAgICAgY3VycmVudCA9ICIiOwogICAgICAgICAgYWN0aXZlID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHJlc3VsdCArPSBjaGFyOwogICAgICBjdXJyZW50ICs9IGNoYXI7CiAgICB9CiAgICBpZiAoIXZhbGlkKQogICAgICB0aHJvdyBuZXcgQmFzZUVycm9yMigiVW5hYmxlIHRvIG5vcm1hbGl6ZSBzaWduYXR1cmUuIik7CiAgICByZXR1cm4gcmVzdWx0OwogIH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3NFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBhZGRyZXNzIH0pIHsKICAgICAgICAgIHN1cGVyKGBBZGRyZXNzICIke2FkZHJlc3N9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIi0gQWRkcmVzcyBtdXN0IGJlIGEgaGV4IHZhbHVlIG9mIDIwIGJ5dGVzICg0MCBoZXggY2hhcmFjdGVycykuIiwKICAgICAgICAgICAgICAiLSBBZGRyZXNzIG11c3QgbWF0Y2ggaXRzIGNoZWNrc3VtIGNvdW50ZXJwYXJ0LiIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRBZGRyZXNzRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9scnUuanMKICB2YXIgTHJ1TWFwOwogIHZhciBpbml0X2xydSA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvbHJ1LmpzIigpIHsKICAgICAgTHJ1TWFwID0gY2xhc3MgZXh0ZW5kcyBNYXAgewogICAgICAgIGNvbnN0cnVjdG9yKHNpemUzKSB7CiAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtYXhTaXplIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMubWF4U2l6ZSA9IHNpemUzOwogICAgICAgIH0KICAgICAgICBnZXQoa2V5KSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHN1cGVyLmdldChrZXkpOwogICAgICAgICAgaWYgKHN1cGVyLmhhcyhrZXkpICYmIHZhbHVlICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgdGhpcy5kZWxldGUoa2V5KTsKICAgICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0KICAgICAgICBzZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgc3VwZXIuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgaWYgKHRoaXMubWF4U2l6ZSAmJiB0aGlzLnNpemUgPiB0aGlzLm1heFNpemUpIHsKICAgICAgICAgICAgY29uc3QgZmlyc3RLZXkgPSB0aGlzLmtleXMoKS5uZXh0KCkudmFsdWU7CiAgICAgICAgICAgIGlmIChmaXJzdEtleSkKICAgICAgICAgICAgICB0aGlzLmRlbGV0ZShmaXJzdEtleSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9hZGRyZXNzL2dldEFkZHJlc3MuanMKICBmdW5jdGlvbiBjaGVja3N1bUFkZHJlc3MoYWRkcmVzc18sIGNoYWluSWQpIHsKICAgIGlmIChjaGVja3N1bUFkZHJlc3NDYWNoZS5oYXMoYCR7YWRkcmVzc199LiR7Y2hhaW5JZH1gKSkKICAgICAgcmV0dXJuIGNoZWNrc3VtQWRkcmVzc0NhY2hlLmdldChgJHthZGRyZXNzX30uJHtjaGFpbklkfWApOwogICAgY29uc3QgaGV4QWRkcmVzcyA9IGNo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vIGFjY2VzcyBhIHN0b3JhZ2UgYnl0ZSBhcnJheSB0aGF0IGlzIGluY29ycmVjdGx5IGVuY29kZWQuIiwKICAgICAgICA0OTogIlBlcmZvcm1lZCBgLnBvcCgpYCBvbiBhbiBlbXB0eSBhcnJheSIsCiAgICAgICAgNTA6ICJBcnJheSBpbmRleCBpcyBvdXQgb2YgYm91bmRzLiIsCiAgICAgICAgNjU6ICJBbGxvY2F0ZWQgdG9vIG11Y2ggbWVtb3J5IG9yIGNyZWF0ZWQgYW4gYXJyYXkgd2hpY2ggaXMgdG9vIGxhcmdlLiIsCiAgICAgICAgODE6ICJBdHRlbXB0ZWQgdG8gY2FsbCBhIHplcm8taW5pdGlhbGl6ZWQgdmFyaWFibGUgb2YgaW50ZXJuYWwgZnVuY3Rpb24gdHlwZS4iCiAgICAgIH07CiAgICAgIHNvbGlkaXR5RXJyb3IgPSB7CiAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICB7CiAgICAgICAgICAgIG5hbWU6ICJtZXNzYWdlIiwKICAgICAgICAgICAgdHlwZTogInN0cmluZyIKICAgICAgICAgIH0KICAgICAgICBdLAogICAgICAgIG5hbWU6ICJFcnJvciIsCiAgICAgICAgdHlwZTogImVycm9yIgogICAgICB9OwogICAgICBzb2xpZGl0eVBhbmljID0gewogICAgICAgIGlucHV0czogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAicmVhc29uIiwKICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICB9CiAgICAgICAgXSwKICAgICAgICBuYW1lOiAiUGFuaWMiLAogICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2Vycm9ycy9jdXJzb3IuanMKICB2YXIgTmVnYXRpdmVPZmZzZXRFcnJvciwgUG9zaXRpb25PdXRPZkJvdW5kc0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mZnNldDsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24pOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiA9IHBvc2l0aW9uOwogICAgICAgIH0sCiAgICAgICAgZ2V0UmVhZENvdW50KHBvc2l0aW9uKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5wb3NpdGlvblJlYWRDb3VudC5nZXQocG9zaXRpb24gfHwgdGhpcy5wb3NpdGlvbikgfHwgMDsKICAgICAgICB9LAogICAgICAgIGluY3JlbWVudFBvc2l0aW9uKG9mZnNldCkgewogICAgICAgICAgaWYgKG9mZnNldCA8IDApCiAgICAgICAgICAgIHRocm93IG5ldyBOZWdhdGl2ZU9mZnNldEVycm9yKHsgb2Zmc2V0IH0pOwogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uICsgb2Zmc2V0OwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0Qnl0ZShwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzW3Bvc2l0aW9uXTsKICAgICAgICB9LAogICAgICAgIGluc3BlY3RCeXRlcyhsZW5ndGgsIHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyBsZW5ndGggLSAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLnN1YmFycmF5KHBvc2l0aW9uLCBwb3NpdGlvbiArIGxlbmd0aCk7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDgocG9zaXRpb25fKSB7CiAgICAgICAgICBjb25zdCBwb3NpdGlvbiA9IHBvc2l0aW9uXyA/PyB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICByZXR1cm4gdGhpcy5ieXRlc1twb3NpdGlvbl07CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDE2KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAxKTsKICAgICAgICAgIHJldHVybiB0aGlzLmRhdGFWaWV3LmdldFVpbnQxNihwb3NpdGlvbik7CiAgICAgICAgfSwKICAgICAgICBpbnNwZWN0VWludDI0KHBvc2l0aW9uXykgewogICAgICAgICAgY29uc3QgcG9zaXRpb24gPSBwb3NpdGlvbl8gPz8gdGhpcy5wb3NpdGlvbjsKICAgICAgICAgIHRoaXMuYXNzZXJ0UG9zaXRpb24ocG9zaXRpb24gKyAyKTsKICAgICAgICAgIHJldHVybiAodGhpcy5kYXRhVmlldy5nZXRVaW50MTYocG9zaXRpb24pIDw8IDgpICsgdGhpcy5kYXRhVmlldy5nZXRVaW50OChwb3NpdGlvbiArIDIpOwogICAgICAgIH0sCiAgICAgICAgaW5zcGVjdFVpbnQzMihwb3NpdGlvbl8pIHsKICAgICAgICAgIGNvbnN0IHBvc2l0aW9uID0gcG9zaXRpb25fID8/IHRoaXMucG9zaXRpb247CiAgICAgICAgICB0aGlzLmFzc2VydFBvc2l0aW9uKHBvc2l0aW9uICsgMyk7CiAgICAgICAgICByZXR1cm4gdGhpcy5kYXRhVmlldy5nZXRVaW50MzIocG9zaXRpb24pOwogICAgICAgIH0sCiAgICAgICA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cuc2V0VWludDgodGhpcy5wb3NpdGlvbiArIDIsIHZhbHVlICYgfjQyOTQ5NjcwNDApOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAzOwogICAgICAgIH0sCiAgICAgICAgcHVzaFVpbnQzMih2YWx1ZSkgewogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbih0aGlzLnBvc2l0aW9uICsgMyk7CiAgICAgICAgICB0aGlzLmRhdGFWaWV3LnNldFVpbnQzMih0aGlzLnBvc2l0aW9uLCB2YWx1ZSk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDQ7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZSgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RCeXRlKCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uKys7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkQnl0ZXMobGVuZ3RoLCBzaXplMykgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdEJ5dGVzKGxlbmd0aCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IHNpemUzID8/IGxlbmd0aDsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50OCgpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50OCgpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSAxOwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgcmVhZFVpbnQxNigpIHsKICAgICAgICAgIHRoaXMuYXNzZXJ0UmVhZExpbWl0KCk7CiAgICAgICAgICB0aGlzLl90b3VjaCgpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLmluc3BlY3RVaW50MTYoKTsKICAgICAgICAgIHRoaXMucG9zaXRpb24gKz0gMjsKICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICB9LAogICAgICAgIHJlYWRVaW50MjQoKSB7CiAgICAgICAgICB0aGlzLmFzc2VydFJlYWRMaW1pdCgpOwogICAgICAgICAgdGhpcy5fdG91Y2goKTsKICAgICAgICAgIGNvbnN0IHZhbHVlID0gdGhpcy5pbnNwZWN0VWludDI0KCk7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uICs9IDM7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfSwKICAgICAgICByZWFkVWludDMyKCkgewogICAgICAgICAgdGhpcy5hc3NlcnRSZWFkTGltaXQoKTsKICAgICAgICAgIHRoaXMuX3RvdWNoKCk7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaW5zcGVjdFVpbnQzMigpOwogICAgICAgICAgdGhpcy5wb3NpdGlvbiArPSA0OwogICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgIH0sCiAgICAgICAgZ2V0IHJlbWFpbmluZygpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmxlbmd0aCAtIHRoaXMucG9zaXRpb247CiAgICAgICAgfSwKICAgICAgICBzZXRQb3NpdGlvbihwb3NpdGlvbikgewogICAgICAgICAgY29uc3Qgb2xkUG9zaXRpb24gPSB0aGlzLnBvc2l0aW9uOwogICAgICAgICAgdGhpcy5hc3NlcnRQb3NpdGlvbihwb3NpdGlvbik7CiAgICAgICAgICB0aGlzLnBvc2l0aW9uID0gcG9zaXRpb247CiAgICAgICAgICByZXR1cm4gKCkgPT4gdGhpcy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GRyZXNzIH0pIHsKICAgICAgICAgIHN1cGVyKGBTdGF0ZSBmb3IgYWNjb3VudCAiJHthZGRyZXNzfSIgaXMgc2V0IG11bHRpcGxlIHRpbWVzLmAsIHsKICAgICAgICAgICAgbmFtZTogIkFjY291bnRTdGF0ZUNvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgc3VwZXIoInN0YXRlIGFuZCBzdGF0ZURpZmYgYXJlIHNldCBvbiB0aGUgc2FtZSBhY2NvdW50LiIsIHsKICAgICAgICAgICAgbmFtZTogIlN0YXRlQXNzaWdubWVudENvbmZsaWN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9lcnJvcnMvdHJhbnNhY3Rpb24uanMKICBmdW5jdGlvbiBwcmV0dHlQcmludChhcmdzKSB7CiAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoYXJncykubWFwKChba2V5LCB2YWx1ZV0pID0+IHsKICAgICAgaWYgKHZhbHVlID09PSB2b2lkIDAgfHwgdmFsdWUgPT09IGZhbHNlKQogICAgICAgIHJldHVybiBudWxsOwogICAgICByZXR1cm4gW2tleSwgdmFsdWVdOwogICAgfSkuZmlsdGVyKEJvb2xlYW4pOwogICAgY29uc3QgbWF4TGVuZ3RoID0gZW50cmllcy5yZWR1Y2UoKGFjYywgW2tleV0pID0+IE1hdGgubWF4KGFjYywga2V5Lmxlbmd0aCksIDApOwogICAgcmV0dXJuIGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IGAgICR7YC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AtMTU1OSBjb21wYXRpYmxlIG5ldHdvcmtzLCBhbmQgYGdhc1ByaWNlYCBmb3Igb3RoZXJzLiIKICAgICAgICAgIF0uam9pbigiXG4iKSwgeyBuYW1lOiAiRmVlQ29uZmxpY3RFcnJvciIgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkTGVnYWN5VkVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHYgfSkgewogICAgICAgICAgc3VwZXIoYEludmFsaWQgXGB2XGAgdmFsdWUgIiR7dn0iLiBFeHBlY3RlZCAyNyBvciAyOC5gLCB7CiAgICAgICAgICAgIG5hbWU6ICJJbnZhbGlkTGVnYWN5VkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXphYmxlVHJhbnNhY3Rpb25FcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyB0cmFuc2FjdGlvbiB9KSB7CiAgICAgICAgICBzdXBlcigiQ2Fubm90IGluZmVyIGEgdHJhbnNhY3Rpb24gdHlwZSBmcm9tIHByb3ZpZGVkIHRyYW5zYWN0aW9uLiIsIHsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzOiBbCiAgICAgICAgICAgICAgIlByb3ZpZGVkIFRyYW5zYWN0aW9uOiIsCiAgICAgICAgICAgICAgInsiLAogICAgICAgICAgICAgIHByZXR0eVByaW50KHRyYW5zYWN0aW9uKSwKICAgICAgICAgICAgICAifSIsCiAgICAgICAgICAgICAgIiIsCiAgICAgICAgICAgICAgIlRvIGluZmVyIHRoZSB0eXBlLCBlaXRoZXIgcHJvdmlkZToiLAogICAgICAgICAgICAgICItIGEgYHR5cGVgIHRvIHRoZSBUcmFuc2FjdGlvbiwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC0xNTU5IFRyYW5zYWN0aW9uIHdpdGggYG1heEZlZVBlckdhc2AsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtMjkzMCBUcmFuc2FjdGlvbiB3aXRoIGBnYXNQcmljZWAgJiBgYWNjZXNzTGlzdGAsIG9yIiwKICAgICAgICAgICAgICAiLSBhbiBFSVAtNDg0NCBUcmFuc2FjdGlvbiB3aXRoIGBibG9ic2AsIGBibG9iVmVyc2lvbmVkSGFzaGVzYCwgYHNpZGVjYXJzYCwgb3IiLAogICAgICAgICAgICAgICItIGFuIEVJUC03NzAyIFRyYW5zYWN0aW9uIHdpdGggYGF1dGhvcml6YXRpb25MaXN0YCwgb3IiLAogICAgICAgICAgICAgICItIGEgTGVnYWN5IFRyYW5zYWN0aW9uIHdpdGggYGdhc1ByaWNlYCIKICAgICAgICAgICAgXSwKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemFibGVUcmFuc2FjdGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBJbnZhbGlkU2VyaWFsaXplZFRyYW5zYWN0aW9uVHlwZUVycm9yID0gY2xhc3MgZXh0ZW5kcyBCYXNlRXJyb3IyIHsKICAgICAgICBjb25zdHJ1Y3Rvcih7IHNlcmlhbGl6ZWRUeXBlIH0pIHsKICAgICAgICAgIHN1cGVyKGBTZXJpYWxpemVkIHRyYW5zYWN0aW9uIHR5cGUgIiR7c2VyaWFsaXplZFR5cGV9IiBpcyBpbnZhbGlkLmAsIHsKICAgICAgICAgICAgbmFtZTogIkludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25UeXBlIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlcmlhbGl6ZWRUeXBlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogIC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AgICAgICAgICAgLi4uY2F1c2UubWV0YU1lc3NhZ2VzID8gWy4uLmNhdXNlLm1ldGFNZXNzYWdlcywgIiAiXSA6IFtdLAogICAgICAgICAgICAgICJSZXF1ZXN0IEFyZ3VtZW50czoiLAogICAgICAgICAgICAgIHByZXR0eUFyZ3MKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJUcmFuc2FjdGlvbkV4ZWN1dGlvbkVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIHRoaXMuY2F1c2UgPSBjYXVzZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFRyYW5zYWN0aW9uTm90Rm91bmRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBibG9ja0hhc2gsIGJsb2NrTnVtYmVyLCBibG9ja1RhZywgaGFzaDogaGFzaDMsIGluZGV4OiBpbmRleDIgfSkgewogICAgICAgICAgbGV0IGlkZW50aWZpZXIgPSAiVHJhbnNhY3Rpb24iOwogICAgICAgICAgaWYgKGJsb2NrVGFnICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW9uIGF0IGJsb2NrIHRpbWUgIiR7YmxvY2tUYWd9IiBhdCBpbmRleCAiJHtpbmRleDJ9ImA7CiAgICAgICAgICBpZiAoYmxvY2tIYXNoICYmIGluZGV4MiAhPT0gdm9pZCAwKQogICAgICAgICAgICBpZGVudGlmaWVyID0gYFRyYW5zYWN0aW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TogIkNhbGxFeGVjdXRpb25FcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjYXVzZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhdXNlID0gY2F1c2U7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uRXhlY3V0aW9uRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlLCB7IGFiaTogYWJpMiwgYXJncywgY29udHJhY3RBZGRyZXNzLCBkb2NzUGF0aDogZG9jc1BhdGg5LCBmdW5jdGlvbk5hbWUsIHNlbmRlciB9KSB7CiAgICAgICAgICBjb25zdCBhYmlJdGVtID0gZ2V0QWJpSXRlbSh7IGFiaTogYWJpMiwgYXJncywgbmFtZTogZnVuY3Rpb25OYW1lIH0pOwogICAgICAgICAgY29uc3QgZm9ybWF0dGVkQXJncyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtV2l0aEFyZ3MoewogICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICBhcmdzLAogICAgICAgICAgICBpbmNsdWRlRnVuY3Rpb25OYW1lOiBmYWxzZSwKICAgICAgICAgICAgaW5jbHVkZU5hbWU6IGZhbHNlCiAgICAgICAgICB9KSA6IHZvaWQgMDsKICAgICAgICAgIGNvbnN0IGZ1bmN0aW9uV2l0aFBhcmFtcyA9IGFiaUl0ZW0gPyBmb3JtYXRBYmlJdGVtMihhYmlJdGVtLCB7IGluY2x1ZGVOYW1lOiB0cnVlIH0pIDogdm9pZCAwOwogICAgICAgICAgY29uc3QgcHJldHR5QX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lLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiYXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNhdXNlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29udHJhY3RBZGRyZXNzIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZm9ybWF0dGVkQXJncyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImZ1bmN0aW9uTmFtZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNlbmRlciIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmFiaSA9IGFiaTI7CiAgICAgICAgICB0aGlzLmFyZ3MgPSBhcmdzOwogICAgICAgICAgdGhpcy5jYXVzZSA9IGNhdXNlOwogICAgICAgICAgdGhpcy5jb250cmFjdEFkZHJlc3MgPSBjb250cmFjdEFkZHJlc3M7CiAgICAgICAgICB0aGlzLmZ1bmN0aW9uTmFtZSA9IGZ1bmN0aW9uTmFtZTsKICAgICAgICAgIHRoaXMuc2VuZGVyID0gc2VuZGVyOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYWJpOiBhYmkyLCBkYXRhLCBmdW5jdGlvbk5hbWUsIG1lc3NhZ2UgfSkgewogICAgICAgICAgbGV0IGNhdXNlOwogICAgICAgICAgbGV0IGRlY29kZWREYXRhID0gdm9pZCAwOwogICAgICAgICAgbGV0IG1ldGFNZXNzYWdlczsKICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICBpZiAoZGF0YSAmJiBkYXRhICE9PSAiMHgiKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZGVjb2RlZERhdGEgPSBkZWNvZGVFcnJvclJlc3VsdCh7IGFiaTogYWJpMiwgZGF0YSB9KTsKICAgICAgICAgICAgICBjb25zdCB7IGFiaUl0ZW0sIGVycm9yTmFtZSwgYXJnczogZXJyb3JBcmdzIH0gPSBkZWNvZGVkRGF0YTsKICAgICAgICAgICAgICBpZiAoZXJyb3JOYW1lID09PSAiRXJyb3IiKSB7CiAgICAgICAgICAgICAgICByZWFzb24gPSBlcnJvckFyZ3NbMF07CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChlcnJvck5hbWUgPT09ICJQYW5pYyIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IFtmaXJzdEFyZ10gPSBlcnJvckFyZ3M7CiAgICAgICAgICAgICAgICByZWFzb24gPSBwYW5pY1JlYXNvbnNbZmlyc3RBcmddOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBjb25zdCBlcnJvcldpdGhQYXJhbXMgPSBhYmlJdGVtID8gZm9ybWF0QWJpSXRlbTIoYWJpSXRlbSwgeyBpbmNsdWRlTmFtZTogdHJ1ZSB9KSA6IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZEFyZ3MgPSBhYmlJdGVtICYmIGVycm9yQXJncyA/IGZvcm1hdEFiaUl0ZW1XaXRoQXJncyh7CiAgICAgICAgICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICAgICAgICAgIGFyZ3M6IGVycm9yQXJncywKICAgICAgICAgICAgICAgICAgaW5jbHVkZUZ1bmN0aW9uTmFtZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVOYW1lOiBmYWxzZQogICAgICAgICAgICAgICAgfSkgOiB2b2lkIDA7CiAgICAgICAgICAgICAgICBtZXRhTWVzc2FnZXMgPSBbCiAgICAgICAgICAgICAgICAgIGVycm9yV2l0aFBhcmFtcyA/IGBFcnJvcjogJHtlcnJvcldpdGhQYXJhbXN9YCA6ICIiLAogICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRBcmdzICYmIGZvcm1hdHRlZEFyZ3MgIT09ICIoKSIgPyBgICAgICAgICR7Wy4uLkFycmF5KGVycm9yTmFtZT8ubGVuZ3RoID8/IDApLmtleXMoKV0ubWFwKCgpID0+ICIgIikuam9pbigiIil9JHtmb3JtYXR0ZWRBcmdzfWAgOiAiIgogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIGNhdXNlID0gZXJyOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKG1lc3NhZ2UpCiAgICAgICAgICAgIHJlYXNvbiA9IG1lc3NhZ2U7CiAgICAgICAgICBsZXQgc2lnbmF0dXJlOwogICAgICAgICAgaWYgKGNhdXNlIGluc3RhbmNlb2YgQWJpRXJyb3JTaWduYXR1cmVOb3RGb3VuZEVycm9yKSB7CiAgICAgICAgICAgIHNpZ25hdHVyZSA9IGNhdXNlLnNpZ25hdHVyZTsKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzID0gWwogICAgICAgICAgICAgIGBVbmFibGUgdG8gZGVjb2RlIHNpZ25hdHVyZSAiJHtzaWduYXR1cmV9IiBhcyBpdCB3YXMgbm90IGZvdW5kIG9uIHRoZSBwcm92aWRlZCBBQkkuYCwKICAgICAgICAgICAgICAiTWFrZSBzdXJlIHlvdSBhcmUgdXNpbmcgdGhlIGNvcnJlY3QgQUJJIGFuZCB0aGF0IHRoZSBlcnJvciBleGlzdHMgb24gaXQuIiwKICAgICAgICAgICAgICBgWW91IGNhbiBsb29rIHVwIHRoZSBkZWNvZGVkIHNpZ25hdHVyZSBoZXJlOiBodHRwczovL29wZW5jaGFpbi54eXovc2lnbmF0dXJlcz9xdWVyeT0ke3NpZ25hdHVyZX0uYAogICAgICAgICAgICBdOwogICAgICAgICAgfQogICAgICAgICAgc3VwZXIocmVhc29uICYmIHJlYXNvbiAhPT0gImV4ZWN1dGlvbiByZXZlcnRlZCIgfHwgc2lnbmF0dXJlID8gWwogICAgICAgICAgICBgVGhlIGNvbnRyYWN0IGZ1bmN0aW9uICIke2Z1bmN0aW9uTmFtZX0iIHJldmVydGVkIHdpdGggdGhlIGZvbGxvd2luZyAke3NpZ25hdHVyZSA/ICJzaWduYXR1cmUiIDogInJlYXNvbiJ9OmAsCiAgICAgICAgICAgIHJlYXNvbiB8fCBzaWduYXR1cmUKICAgICAgICAgIF0uam9pbigiXG4iKSA6IGBUaGUgY29udHJhY3QgZnVuY3Rpb24gIiR7ZnVuY3Rpb25OYW1lfSIgcmV2ZXJ0ZWQuYCwgewogICAgICAgICAgICBjYXVzZSwKICAgICAgICAgICAgbWV0YU1lc3NhZ2VzLAogICAgICAgICAgICBuYW1lOiAiQ29udHJhY3RGdW5jdGlvblJldmVydGVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiZGF0YSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInJlYXNvbiIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hdHVyZSIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmRhdGEgPSBkZWNvZGVkRGF0YTsKICAgICAgICAgIHRoaXMucmVhc29uID0gcmVhc29uOwogICAgICAgICAgdGhpcy5zaWduYXR1cmUgPSBzaWduYXR1cmU7CiAgICAgICAgfQogICAgICB9OwogICAgICBDb250cmFjdEZ1bmN0aW9uWmVyb0RhdGFFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBmdW5jdGlvbk5hbWUgfSkgewogICAgICAgICAgc3VwZXIoYFRoZSBjb250cmFjdCBmdW5jdGlvbiAiJHtmdW5jdGlvbk5hbWV9IiByZXR1cm5lZCBubyBkYXRhICgiMHgiKS5gLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgICJUaGlzIGNvdWxkIGJlIGR1ZSB0byBhbnkgb2YgdGhlIGZvbGxvd2luZzoiLAogICAgICAgICAgICAgIGAgIC0gVGhlIGNvbnRyYWN0IGRvZXMgbm90IGhhdmUgdGhlIGZ1bmN0aW9uICIke2Z1bmN0aW9uTmFtZX0iLGAsCiAgICAgICAgICAgICAgIiAgLSBUaGUgcGFyYW1ldGVycyBwYXNzZWQgdG8gdGhlIGNvbnRyYWN0IGZ1bmN0aW9uIG1heSBiZSBpbnZhbGlkLCBvciIsCiAgICAgICAgICAgICAgIiAgLSBUaGUgYWRkcmVzcyBpcyBub3QgYSBjb250cmFjdC4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb250cmFjdEZ1bmN0aW9uWmVyb0RhdGFFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQ291bnRlcmZhY3R1YWxEZXBsb3ltZW50RmFpbGVkRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgZmFjdG9yeSB9KSB7CiAgICAgICAgICBzdXBlcihgRGVwbG95bWVudCBmb3IgY291bnRlcmZhY3R1YWwgY29udHJhY3QgY2FsbCBmYWlsZWQke2ZhY3RvcnkgPyBgIGZvciBmYWN0b3J5ICIke2ZhY3Rvcnl9Ii5gIDogIiJ9YCwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAiUGxlYXNlIGVuc3VyZToiLAogICAgICAgICAgICAgICItIFRoZSBgZmFjdG9yeWAgaXMgYSB2YWxpZCBjb250cmFjdCBkZXBsb3ltZW50IGZhY3RvcnkgKGllLiBDcmVhdGUyIEZhY3RvcnksIEVSQy00MzM3IEZhY3RvcnksIGV0YykuIiwKICAgICAgICAgICAgICAiLSBUaGUgYGZhY3RvcnlEYXRhYCBpcyBhIHZhbGlkIGVuY29kZWQgZnVuY3Rpb24gY2FsbCBmb3IgY29udHJhY3QgZGVwbG95bWVudCBmdW5jdGlvbiBvbiB0aGUgZmFjdG9yeS4iCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJDb3VudGVyZmFjdHVhbERlcGxveW1lbnRGYWlsZWRFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgUmF3Q29udHJhY3RFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBkYXRhLCBtZXNzYWdlIH0pIHsKICAgICAgICAgIHN1cGVyKG1lc3NhZ2UgfHwgIiIsIHsgbmFtZTogIlJhd0NvbnRyYWN0RXJyb3IiIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjb2RlIiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlO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LAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBzdGF0dXMgJiYgYFN0YXR1czogJHtzdGF0dXN9YCwKICAgICAgICAgICAgICBgVVJMOiAke2dldFVybCh1cmwpfWAsCiAgICAgICAgICAgICAgYm9keSAmJiBgUmVxdWVzdCBib2R5OiAke3N0cmluZ2lmeShib2R5KX1gCiAgICAgICAgICAgIF0uZmlsdGVyKEJvb2xlYW4pLAogICAgICAgICAgICBuYW1lOiAiSHR0cFJlcXVlc3RFcnJvciIKICAgICAgICAgIH0pOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJib2R5IiwgewogICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiaGVhZGVycyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInN0YXR1cyIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInVybCIsIHsKICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmJvZHkgPSBib2R5OwogICAgICAgICAgdGhpcy5oZWFkZXJzID0gaGVhZGVyczsKICAgICAgICAgIHRoaXMuc3RhdHVzID0gc3RhdHVzOwogICAgICAgICAgdGhpcy51cmwgPSB1cmw7CiAgICAgICAgfQogICAgICB9OwogICAgICBXZWJTb2NrZXRSZXF1ZXN0RXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgYm9keSwgY2F1c2UsIGRldGFpbHMsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiV2ViU29ja2V0IHJlcXVlc3QgZmFpbGVkLiIsIHsKICAgICAgICAgICAgY2F1c2UsCiAgICAgICAgICAgIGRldGFpbHMsCiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBVUkw6ICR7Z2V0VXJsKHVybCl9YCwKICAgICAgICAgICAgICBib2R5ICYmIGBSZXF1ZXN0IGJvZHk6ICR7c3RyaW5naWZ5KGJvZHkpfWAKICAgICAgICAgICAgXS5maWx0ZXIoQm9vbGVhbiksCiAgICAgICAgICAgIG5hbWU6ICJXZWJTb2NrZXRSZXF1ZXN0RXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIFJwY1JlcXVlc3RFcnJvciA9IGNsYXNzIGV4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ICAgICAgICAgICAgbmFtZTogIk1ldGhvZE5vdEZvdW5kUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IGBUaGUgbWV0aG9kJHttZXRob2QgPyBgICIke21ldGhvZH0iYCA6ICIifSBkb2VzIG5vdCBleGlzdCAvIGlzIG5vdCBhdmFpbGFibGUuYAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTWV0aG9kTm90Rm91bmRScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMQogICAgICB9KTsKICAgICAgSW52YWxpZFBhcmFtc1JwY0Vycm9yID0gY2xhc3MgX0ludmFsaWRQYXJhbXNScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludmFsaWRQYXJhbXNScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiBbCiAgICAgICAgICAgICAgIkludmFsaWQgcGFyYW1ldGVycyB3ZXJlIHByb3ZpZGVkIHRvIHRoZSBSUEMgbWV0aG9kLiIsCiAgICAgICAgICAgICAgIkRvdWJsZSBjaGVjayB5b3UgaGF2ZSBwcm92aWRlZCB0aGUgY29ycmVjdCBwYXJhbWV0ZXJzLiIKICAgICAgICAgICAgXS5qb2luKCJcbiIpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShJbnZhbGlkUGFyYW1zUnBjRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiAtMzI2MDIKICAgICAgfSk7CiAgICAgIEludGVybmFsUnBjRXJyb3IgPSBjbGFzcyBfSW50ZXJuYWxScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0ludGVybmFsUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkludGVybmFsUnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBpbnRlcm5hbCBlcnJvciB3YXMgcmVjZWl2ZWQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoSW50ZXJuYWxScGNFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjYwMwogICAgICB9KTsKICAgICAgSW52YWxpZElucHV0UnBjRXJyb3IgPSBjbGFzcyBfSW52YWxpZElucHV0UnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9JbnZhbGlkSW5wdXRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiSW52YWxpZElucHV0UnBjRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6IFsKICAgICAgICAgICAgICAiTWlzc2luZyBvciBpbnZhbGlkIHBhcmFtZXRlcnMuIiwKICAgICAgICAgICAgICAiRG91YmxlIGNoZWNrIHlvdSBoYXZlIHByb3ZpZGVkIHRoZSBjb3JyZWN0IHBhcmFtZXRlcnMuIgogICAgICAgICAgICBdLmpvaW4oIlxuIikKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEludmFsaWRJbnB1dFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyZTMKICAgICAgfSk7CiAgICAgIFJlc291cmNlTm90Rm91bmRScGNFcnJvciA9IGNsYXNzIF9SZXNvdXJjZU5vdEZvdW5kUnBjRXJyb3IgZXh0ZW5kcyBScGNFcnJvciB7CiAgICAgICAgY29uc3RydWN0b3IoY2F1c2UpIHsKICAgICAgICAgIHN1cGVyKGNhdXNlLCB7CiAgICAgICAgICAgIGNvZGU6IF9SZXNvdXJjZU5vdEZvdW5kUnBjRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlJlc291cmNlTm90Rm91bmRScGNFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlJlcXVlc3RlZCByZXNvdXJjZSBub3QgZm91bmQuIgogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm5hbWUiLCB7CiAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIHZhbHVlOiAiUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVyd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FibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IC0zMjAwNAogICAgICB9KTsKICAgICAgTGltaXRFeGNlZWRlZFJwY0Vycm9yID0gY2xhc3MgX0xpbWl0RXhjZWVkZWRScGNFcnJvciBleHRlbmRzIFJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0xpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiTGltaXRFeGNlZWRlZFJwY0Vycm9yIiwKICAgICAgICAgICAgc2hvcnRNZXNzYWdlOiAiUmVxdWVzdCBleGNlZWRzIGRlZmluZWQgbGltaXQuIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTGltaXRFeGNlZWRlZFJwY0Vycm9yLCAiY29kZSIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICB2YWx1ZTogLTMyMDA1CiAgICAgIH0pOwogICAgICBKc29uUnBjVmVyc2lvblVuc3VwcG9ydGVkRXJyb3IgPSBjbGFzcyBfSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yIGV4dGVuZHMgUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlKSB7CiAgICAgICAgICBzdXBlcihjYXVzZSwgewogICAgICAgICAgICBjb2RlOiBfSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGUsCiAgICAgICAgICAgIG5hbWU6ICJKc29uUnBjVmVyc2lvblVuc3VwcG9ydGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJWZXJzaW9uIG9m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8gYCAiICR7bWV0aG9kfSJgIDogIiJ9LmAKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFVuc3VwcG9ydGVkUHJvdmlkZXJNZXRob2RFcnJvciwgImNvZGUiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgdmFsdWU6IDQyMDAKICAgICAgfSk7CiAgICAgIFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IgPSBjbGFzcyBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciBleHRlbmRzIFByb3ZpZGVyUnBjRXJyb3IgewogICAgICAgIGNvbnN0cnVjdG9yKGNhdXNlKSB7CiAgICAgICAgICBzdXBlcihjYXVzZSwgewogICAgICAgICAgICBjb2RlOiBfUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvci5jb2RlLAogICAgICAgICAgICBuYW1lOiAiUHJvdmlkZXJEaXNjb25uZWN0ZWRFcnJvciIsCiAgICAgICAgICAgIHNob3J0TWVzc2FnZTogIlRoZSBQcm92aWRlciBpcyBkaXNjb25uZWN0ZWQgZnJvbSBhbGwgY2hhaW5zLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAwCiAgICAgIH0pOwogICAgICBDaGFpbkRpc2Nvbm5lY3RlZEVycm9yID0gY2xhc3MgX0NoYWluRGlzY29ubmVjdGVkRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX0NoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIkNoYWluRGlzY29ubmVjdGVkRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJUaGUgUHJvdmlkZXIgaXMgbm90IGNvbm5lY3RlZCB0byB0aGUgcmVxdWVzdGVkIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KENoYWluRGlzY29ubmVjdGVkRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgIHZhbHVlOiA0OTAxCiAgICAgIH0pOwogICAgICBTd2l0Y2hDaGFpbkVycm9yID0gY2xhc3MgX1N3aXRjaENoYWluRXJyb3IgZXh0ZW5kcyBQcm92aWRlclJwY0Vycm9yIHsKICAgICAgICBjb25zdHJ1Y3RvcihjYXVzZSkgewogICAgICAgICAgc3VwZXIoY2F1c2UsIHsKICAgICAgICAgICAgY29kZTogX1N3aXRjaENoYWluRXJyb3IuY29kZSwKICAgICAgICAgICAgbmFtZTogIlN3aXRjaENoYWluRXJyb3IiLAogICAgICAgICAgICBzaG9ydE1lc3NhZ2U6ICJBbiBlcnJvciBvY2N1cnJlZCB3aGVuIGF0dGVtcHRpbmcgdG8gc3dpdGNoIGNoYWluLiIKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFN3aXRjaENoYWluRXJyb3IsICJjb2RlIiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgY29uZmlndXJhYmxlOiB0cn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MzIoYnl0ZU9mZnNldCArIGwsIHdsLCBpc0xFMik7CiAgfQogIHZhciBDaGksIE1haiwgSGFzaE1EOwogIHZhciBpbml0X21kID0gX19lc20oewogICAgIm5vZGVfbW9kdWxlcy8uZGVuby9Abm9ibGUraGFzaGVzQDEuNS4wL25vZGVfbW9kdWxlcy9Abm9ibGUvaGFzaGVzL2VzbS9fbWQuanMiKCkgewogICAgICBpbml0X2Fzc2VydCgpOwogICAgICBpbml0X3V0aWxzMigpOwogICAgICBDaGkgPSAoYSwgYiwgYykgPT4gYSAmIGIgXiB+YSAmIGM7CiAgICAgIE1haiA9IChhLCBiLCBjKSA9PiBhICYgYiBeIGEgJiBjIF4gYiAmIGM7CiAgICAgIEhhc2hNRCA9IGNsYXNzIGV4dGVuZHMgSGFzaCB7CiAgICAgICAgY29uc3RydWN0b3IoYmxvY2tMZW4sIG91dHB1dExlbiwgcGFkT2Zmc2V0LCBpc0xFMikgewogICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgIHRoaXMuYmxvY2tMZW4gPSBibG9ja0xlbjsKICAgICAgICAgIHRoaXMub3V0cHV0TGVuID0gb3V0cHV0TGVuOwogICAgICAgICAgdGhpcy5wYWRPZmZzZXQgPSBwYWRPZmZzZXQ7CiAgICAgICAgICB0aGlzLmlzTEUgPSBpc0xFMjsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSBmYWxzZTsKICAgICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICAgIHRoaXMucG9zID0gMDsKICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICB0aGlzLmJ1ZmZlciA9IG5ldyBVaW50OEFycmF5KGJsb2NrTGVuKTsKICAgICAgICAgIHRoaXMudmlldyA9IGNyZWF0ZVZpZXcodGhpcy5idWZmZXIpOwogICAgICAgIH0KICAgICAgICB1cGRhdGUoZGF0YSkgewogICAgICAgICAgZXhpc3RzKHRoaXMpOwogICAgICAgICAgY29uc3QgeyB2aWV3LCBidWZmZXI6IGJ1ZmZlcjIsIGJsb2NrTGVuIH0gPSB0aGlzOwogICAgICAgICAgZGF0YSA9IHRvQnl0ZXMyKGRhdGEpOwogICAgICAgICAgY29uc3QgbGVuID0gZGF0YS5sZW5ndGg7CiAgICAgICAgICBmb3IgKGxldCBwb3MgPSAwOyBwb3MgPCBsZW47ICkgewogICAgICAgICAgICBjb25zdCB0YWtlID0gTWF0aC5taW4oYmxvY2tMZW4gLSB0aGlzLnBvcywgbGVuIC0gcG9zKTsKICAgICAgICAgICAgaWYgKHRha2UgPT09IGJsb2NrTGVuKSB7CiAgICAgICAgICAgICAgY29uc3QgZGF0YVZpZXcgPSBjcmVhdGVWaWV3KGRhdGEpOwogICAgICAgICAgICAgIGZvciAoOyBibG9ja0xlbiA8PSBsZW4gLSBwb3M7IHBvcyArPSBibG9ja0xlbikKICAgICAgICAgICAgICAgIHRoaXMucHJvY2VzcyhkYXRhVmlldywgcG9zKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIyLnNldChkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgdGFrZSksIHRoaXMucG9zKTsKICAgICAgICAgICAgdGhpcy5wb3MgKz0gdGFrZTsKICAgICAgICAgICAgcG9zICs9IHRha2U7CiAgICAgICAgICAgIGlmICh0aGlzLnBvcyA9PT0gYmxvY2tMZW4pIHsKICAgICAgICAgICAgICB0aGlzLnByb2Nlc3ModmlldywgMCk7CiAgICAgICAgICAgICAgdGhpcy5wb3MgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmxlbmd0aCArPSBkYXRhLmxlbmd0aDsKICAgICAgICAgIHRoaXMucm91bmRDbGVhbigpOwogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdEludG8ob3V0KSB7CiAgICAgICAgICBleGlzdHModGhpcyk7CiAgICAgICAgICBvdXRwdXQob3V0LCB0aGlzKTsKICAgICAgICAgIHRoaXMuZmluaXNoZWQgPSB0cnVlOwogICAgICAgICAgY29uc3QgeyBidWZmZXI6IGJ1ZmZlcjIsIHZpZXcsIGJsb2NrTGVuLCBpc0xFOiBpc0xFMiB9ID0gdGhpczsKICAgICAgICAgIGxldCB7IHBvcyB9ID0gdGhpczsKICAgICAgICAgIGJ1ZmZlcjJbcG9zKytdID0gMTI4OwogICAgICAgICAgdGhpcy5idWZmZXIuc3ViYXJyYXkocG9zKS5maWxsKDApOwogICAgICAgICAgaWYgKHRoaXMucGFkT2Zmc2V0ID4gYmxvY2tMZW4gLSBwb3MpIHsKICAgICAgICAgICAgdGhpcy5wcm9jZXNzKHZpZXcsIDApOwogICAgICAgICAgICBwb3MgPSAwOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChsZXQgaSA9IHBvczsgaSA8IGJsb2NrTGVuOyBpKyspCiAgICAgICAgICAgIGJ1ZmZlcjJbaV0gPSAwOwogICAgICAgICAgc2V0QmlnVWludDY0KHZpZXcsIGJsb2NrTGVuIC0gOCwgQmlnSW50KHRoaXMubGVuZ3RoICogOCksIGlzTEUyKTsKICAgICAgICAgIHRoaXMucHJvY2Vzcyh2aWV3LCAwKTsKICAgICAgICAgIGNvbnN0IG92aWV3ID0gY3JlYXRlVmlldyhvdXQpOwogICAgICAgICAgY29uc3QgbGVuID0gdGhpcy5vdXRwdXRMZW47CiAgICAgICAgICBpZiAobGVuICUgNCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIHNob3VsZCBiZSBhbGlnbmVkIHRvIDMyYml0Iik7CiAgICAgICAgICBjb25zdCBvdXRMZW4gPSBsZW4gLyA0OwogICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLmdldCgpOwogICAgICAgICAgaWYgKG91dExlbiA+IHN0YXRlLmxlbmd0aCkKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJfc2hhMjogb3V0cHV0TGVuIGJpZ2dlciB0aGFuIHN0YXRlIik7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG91dExlbjsgaSsrKQogICAgICAgICAgICBvdmlldy5zZXRVaW50MzIoNCAqIGksIHN0YXRlW2ldLCBpc0xFMik7CiAgICAgICAgfQogICAgICAgIGRpZ2VzdCgpIHsKICAgICAgICAgIGNvbnN0IHsgYnVmZmVyOiBidWZmZXIyLCBvdXRwdXRMZW4gfSA9IHRoaXM7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8oYnVmZmVyMik7CiAgICAgICAgICBjb25zdCByZXMgPSBidWZmZXIyLnNsaWNlKDAsIG91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRlc3Ryb3koKTsKICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgfQogICAgICAgIF9jbG9uZUludG8odG8pIHsKICAgICAgICAgIHRvIHx8ICh0byA9IG5ldyB0aGlzLmNvbnN0cnVjdG9yKCkpOwogICAgICAgICAgdG8uc2V0KC4uLnRoaXMuZ2V0KCkpOwogICAgICAgICAgY29uc3QgeyBibG9ja0xlbiwgYnVmZmVyOiBidWZmZXIyLCBsZW5ndGgsIGZpbmlzaGVkLCBkZXN0cm95ZWQsIHBvcyB9ID0gdGhpczsKICAgICAgICAgIHRvLmxlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgIHRvLnBvcyA9IHBvczsKICAgICAgICAgIHRvLmZpbmlzaGVkID0gZmluaXNoZWQ7CiAgICAgICAgICB0by5kZXN0cm95ZWQgPSBkZXN0cm95ZWQ7CiAgICAgICAgICBpZiAobGVuZ3RoICUgYmxvY2tMZW4pCiAgICAgICAgICAgIHRvLmJ1ZmZlci5zZXQoYnVmZmVyMik7CiAgICAgICAgICByZXR1cm4gdG87CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2hhc2hlc0AxLjUuMC9ub2RlX21vZHVsZXMvQG5vYmxl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gICAgIDMzMzY1NzE4OTEsCiAgICAgICAgMzU4NDUyODcxMSwKICAgICAgICAxMTM5MjY5OTMsCiAgICAgICAgMzM4MjQxODk1LAogICAgICAgIDY2NjMwNzIwNSwKICAgICAgICA3NzM1Mjk5MTIsCiAgICAgICAgMTI5NDc1NzM3MiwKICAgICAgICAxMzk2MTgyMjkxLAogICAgICAgIDE2OTUxODM3MDAsCiAgICAgICAgMTk4NjY2MTA1MSwKICAgICAgICAyMTc3MDI2MzUwLAogICAgICAgIDI0NTY5NTYwMzcsCiAgICAgICAgMjczMDQ4NTkyMSwKICAgICAgICAyODIwMzAyNDExLAogICAgICAgIDMyNTk3MzA4MDAsCiAgICAgICAgMzM0NTc2NDc3MSwKICAgICAgICAzNTE2MDY1ODE3LAogICAgICAgIDM2MDAzNTI4MDQsCiAgICAgICAgNDA5NDU3MTkwOSwKICAgICAgICAyNzU0MjMzNDQsCiAgICAgICAgNDMwMjI3NzM0LAogICAgICAgIDUwNjk0ODYxNiwKICAgICAgICA2NTkwNjA1NTYsCiAgICAgICAgODgzOTk3ODc3LAogICAgICAgIDk1ODEzOTU3MSwKICAgICAgICAxMzIyODIyMjE4LAogICAgICAgIDE1MzcwMDIwNjMsCiAgICAgICAgMTc0Nzg3Mzc3OSwKICAgICAgICAxOTU1NTYyMjIyLAogICAgICAgIDIwMjQxMDQ4MTUsCiAgICAgICAgMjIyNzczMDQ1MiwKICAgICAgICAyMzYxODUyNDI0LAogICAgICAgIDI0Mjg0MzY0NzQsCiAgICAgICAgMjc1NjczNDE4NywKICAgICAgICAzMjA0MDMxNDc5LAogICAgICAgIDMzMjkzMjUyOTgKICAgICAgXSk7CiAgICAgIFNIQTI1Nl9JViA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoWwogICAgICAgIDE3NzkwMzM3MDMsCiAgICAgICAgMzE0NDEzNDI3NywKICAgICAgICAxMDEzOTA0MjQyLAogICAgICAgIDI3NzM0ODA3NjIsCiAgICAgICAgMTM1OTg5MzExOSwKICAgICAgICAyNjAwODIyOTI0LAogICAgICAgIDUyODczNDYzNSwKICAgICAgICAxNTQxNDU5MjI1CiAgICAgIF0pOwogICAgICBTSEEyNTZfVyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgVWludDMyQXJyYXkoNjQpOwogICAgICBTSEEyNTYgPSBjbGFzcyBleHRlbmRzIEhhc2hNRCB7CiAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICBzdXBlcig2NCwgMzIsIDgsIGZhbHNlKTsKICAgICAgICAgIHRoaXMuQSA9IFNIQTI1Nl9JVlswXSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBTSEEyNTZfSVZbMV0gfCAwOwogICAgICAgICAgdGhpcy5DID0gU0hBMjU2X0lWWzJdIHwgMDsKICAgICAgICAgIHRoaXMuRCA9IFNIQTI1Nl9JVlszXSB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBTSEEyNTZfSVZbNF0gfCAwOwogICAgICAgICAgdGhpcy5GID0gU0hBMjU2X0lWWzVdIHwgMDsKICAgICAgICAgIHRoaXMuRyA9IFNIQTI1Nl9JVls2XSB8IDA7CiAgICAgICAgICB0aGlzLkggPSBTSEEyNTZfSVZbN10gfCAwOwogICAgICAgIH0KICAgICAgICBnZXQoKSB7CiAgICAgICAgICBjb25zdCB7IEEsIEIsIEMsIEQsIEUsIEYsIEcsIEggfSA9IHRoaXM7CiAgICAgICAgICByZXR1cm4gW0EsIEIsIEMsIEQsIEUsIEYsIEcsIEhdOwogICAgICAgIH0KICAgICAgICAvLyBwcmV0dGllci1pZ25vcmUKICAgICAgICBzZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCkgewogICAgICAgICAgdGhpcy5BID0gQSB8IDA7CiAgICAgICAgICB0aGlzLkIgPSBCIHwgMDsKICAgICAgICAgIHRoaXMuQyA9IEMgfCAwOwogICAgICAgICAgdGhpcy5EID0gRCB8IDA7CiAgICAgICAgICB0aGlzLkUgPSBFIHwgMD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sIDIpIF4gcm90cihBLCAxMykgXiByb3RyKEEsIDIyKTsKICAgICAgICAgICAgY29uc3QgVDIgPSBzaWdtYTAgKyBNYWooQSwgQiwgQykgfCAwOwogICAgICAgICAgICBIID0gRzsKICAgICAgICAgICAgRyA9IEY7CiAgICAgICAgICAgIEYgPSBFOwogICAgICAgICAgICBFID0gRCArIFQxIHwgMDsKICAgICAgICAgICAgRCA9IEM7CiAgICAgICAgICAgIEMgPSBCOwogICAgICAgICAgICBCID0gQTsKICAgICAgICAgICAgQSA9IFQxICsgVDIgfCAwOwogICAgICAgICAgfQogICAgICAgICAgQSA9IEEgKyB0aGlzLkEgfCAwOwogICAgICAgICAgQiA9IEIgKyB0aGlzLkIgfCAwOwogICAgICAgICAgQyA9IEMgKyB0aGlzLkMgfCAwOwogICAgICAgICAgRCA9IEQgKyB0aGlzLkQgfCAwOwogICAgICAgICAgRSA9IEUgKyB0aGlzLkUgfCAwOwogICAgICAgICAgRiA9IEYgKyB0aGlzLkYgfCAwOwogICAgICAgICAgRyA9IEcgKyB0aGlzLkcgfCAwOwogICAgICAgICAgSCA9IEggKyB0aGlzLkggfCAwOwogICAgICAgICAgdGhpcy5zZXQoQSwgQiwgQywgRCwgRSwgRiwgRywgSCk7CiAgICAgICAgfQogICAgICAgIHJvdW5kQ2xlYW4oKSB7CiAgICAgICAgICBTSEEyNTZfVy5maWxsKDApOwogICAgICAgIH0KICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgdGhpcy5zZXQoMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCk7CiAgICAgICAgICB0aGlzLmJ1ZmZlci5maWxsKDApOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2hhMjU2ID0gLyogQF9fUFVSRV9fICovIHdyYXBDb25zdHJ1Y3RvcigoKSA9PiBuZXcgU0hBMjU2KCkpOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2hhc2hlc0AxLjUuMC9ub2RlX21vZH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oKS51cGRhdGUoa2V5KS5kaWdlc3QoKSA6IGtleSk7CiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHBhZDIubGVuZ3RoOyBpKyspCiAgICAgICAgICAgIHBhZDJbaV0gXj0gNTQ7CiAgICAgICAgICB0aGlzLmlIYXNoLnVwZGF0ZShwYWQyKTsKICAgICAgICAgIHRoaXMub0hhc2ggPSBoYXNoMy5jcmVhdGUoKTsKICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGFkMi5sZW5ndGg7IGkrKykKICAgICAgICAgICAgcGFkMltpXSBePSA1NCBeIDkyOwogICAgICAgICAgdGhpcy5vSGFzaC51cGRhdGUocGFkMik7CiAgICAgICAgICBwYWQyLmZpbGwoMCk7CiAgICAgICAgfQogICAgICAgIHVwZGF0ZShidWYpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIHRoaXMuaUhhc2gudXBkYXRlKGJ1Zik7CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgZGlnZXN0SW50byhvdXQpIHsKICAgICAgICAgIGV4aXN0cyh0aGlzKTsKICAgICAgICAgIGJ5dGVzKG91dCwgdGhpcy5vdXRwdXRMZW4pOwogICAgICAgICAgdGhpcy5maW5pc2hlZCA9IHRydWU7CiAgICAgICAgICB0aGlzLmlIYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMub0hhc2gudXBkYXRlKG91dCk7CiAgICAgICAgICB0aGlzLm9IYXNoLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHRoaXMuZGVzdHJveSgpOwogICAgICAgIH0KICAgICAgICBkaWdlc3QoKSB7CiAgICAgICAgICBjb25zdCBvdXQgPSBuZXcgVWludDhBcnJheSh0aGlzLm9IYXNoLm91dHB1dExlbik7CiAgICAgICAgICB0aGlzLmRpZ2VzdEludG8ob3V0KTsKICAgICAgICAgIHJldHVybiBvdXQ7CiAgICAgICAgfQogICAgICAgI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ICAgdi5maWxsKDEpOwogICAgICBrLmZpbGwoMCk7CiAgICAgIGkgPSAwOwogICAgfTsKICAgIGNvbnN0IGggPSAoLi4uYikgPT4gaG1hY0ZuKGssIHYsIC4uLmIpOwogICAgY29uc3QgcmVzZWVkID0gKHNlZWQgPSB1OG4oKSkgPT4gewogICAgICBrID0gaCh1OGZyKFswXSksIHNlZWQpOwogICAgICB2ID0gaCgpOwogICAgICBpZiAoc2VlZC5sZW5ndGggPT09IDApCiAgICAgICAgcmV0dXJuOwogICAgICBrID0gaCh1OGZyKFsxXSksIHNlZWQpOwogICAgICB2ID0gaCgpOwogICAgfTsKICAgIGNvbnN0IGdlbjIgPSAoKSA9PiB7CiAgICAgIGlmIChpKysgPj0gMWUzKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiZHJiZzogdHJpZWQgMTAwMCB2YWx1ZXMiKTsKICAgICAgbGV0IGxlbiA9IDA7CiAgICAgIGNvbnN0IG91dCA9IFtdOwogICAgICB3aGlsZSAobGVuIDwgcUJ5dGVMZW4pIHsKICAgICAgICB2ID0gaCgpOwogICAgICAgIGNvbnN0IHNsID0gdi5zbGljZSgpOwogICAgICAgIG91dC5wdXNoKHNsKTsKICAgICAgICBsZW4gKz0gdi5sZW5ndGg7CiAgICAgIH0KICAgICAgcmV0dXJuIGNvbmNhdEJ5dGVzMyguLi5vdXQpOwogICAgfTsKICAgIGNvbnN0IGdlblVudGlsID0gKHNlZWQsIHByZWQpID0+IHsKICAgICAgcmVzZXQyKCk7CiAgICAgIHJlc2VlZChzZWVkKTsKICAgICAgbGV0IHJlcyA9IHZvaWQgMDsKICAgICAgd2hpbGUgKCEocmVzID0gcHJlZChnZW4yKCkpKSkKICAgICAgICByZXNlZWQoKTsKICAgICAgcmVzZXQyKCk7CiAgICAgIHJldHVybiByZXM7CiAgICB9OwogICAgcmV0dXJuIGdlblVudGlsOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZU9iamVjdChvYmplY3QsIHZhbGlkYXRvcnMs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KTsKICAgICAgICByZXR1cm4gcm9vdDI7CiAgICAgIH07CiAgICB9CiAgICBjb25zdCBRMWRpdjIgPSAoUSArIF8xbjMpIC8gXzJuMzsKICAgIHJldHVybiBmdW5jdGlvbiB0b25lbGxpU2xvdyhGcDIsIG4pIHsKICAgICAgaWYgKEZwMi5wb3cobiwgbGVnZW5kcmVDKSA9PT0gRnAyLm5lZyhGcDIuT05FKSkKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgIGxldCByID0gUzsKICAgICAgbGV0IGcgPSBGcDIucG93KEZwMi5tdWwoRnAyLk9ORSwgWiksIFEpOwogICAgICBsZXQgeCA9IEZwMi5wb3cobiwgUTFkaXYyKTsKICAgICAgbGV0IGIgPSBGcDIucG93KG4sIFEpOwogICAgICB3aGlsZSAoIUZwMi5lcWwoYiwgRnAyLk9ORSkpIHsKICAgICAgICBpZiAoRnAyLmVxbChiLCBGcDIuWkVSTykpCiAgICAgICAgICByZXR1cm4gRnAyLlpFUk87CiAgICAgICAgbGV0IG0gPSAxOwogICAgICAgIGZvciAobGV0IHQyID0gRnAyLnNxcihiKTsgbSA8IHI7IG0rKykgewogICAgICAgICAgaWYgKEZwMi5lcWwodDIsIEZwMi5PTkUpKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIHQyID0gRnAyLnNxcih0Mik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGdlID0gRnAyLnBvdyhnLCBfMW4zIDw8IEJpZ0ludChyIC0gbSAtIDEpKTsKICAgICAgICBnID0gRnAyLnNxcihnZSk7CiAgICAgICAgeCA9IEZwMi5tdWwoeCwgZ2UpOwogICAgICAgIGIgPSBGcDIubXVsKGIsIGcpOwogICAgICAgIHIgPSBtOwogICAgICB9CiAgICAgIHJldHVybiB4OwogICAgfTsKICB9CiAgZnVuY3Rpb24gRnBTcXJ0KFApIHsKICAgIGlmIChQICUgXzRuID09PSBfM24pIHsKICAgICAgY29uc3QgcDFkaXY0ID0gKFAgKyBfMW4zKSAvIF80bjsKICAgICAgcmV0dXJuIGZ1bmN0aW9uIHNxcnQzbW9kNChGcDIsIG4pIHsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5wb3cobiwgcDFkaXY0KTsKICAgICAgICBpZiAoIUZwMi5lcWwoRnAyLnNxcihyb290MiksIG4pKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgZmluZCBzcXVhcmUgcm9vdCIpOwogICAgICAgIHJldHVybiByb290MjsKICAgICAgfTsKICAgIH0KICAgIGlmIChQICUgXzhuID09PSBfNW4pIHsKICAgICAgY29uc3QgYzEgPSAoUCAtIF81bikgLyBfOG47CiAgICAgIHJldHVybiBmdW5jdGlvbiBzcXJ0NW1vZDgoRnAyLCBuKSB7CiAgICAgICAgY29uc3QgbjIgPSBGcDIubXVsKG4sIF8ybjMpOwogICAgICAgIGNvbnN0IHYgPSBGcDIucG93KG4yLCBjMSk7CiAgICAgICAgY29uc3QgbnYgPSBGcDIubXVsKG4sIHYpOwogICAgICAgIGNvbnN0IGkgPSBGcDIubXVsKEZwMi5tdWwobnYsIF8ybjMpLCB2KTsKICAgICAgICBjb25zdCByb290MiA9IEZwMi5tdWwobnYsIEZwMi5zdWIoaSwgRnAyLk9ORSkpOwogICAgICAgIGlmICghRnAyLmVxbChGcDIuc3FyKHJvb3QyKSwgbikpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbm5vdCBmaW5kIHNxdWFyZSByb290Iik7CiAgICAgICAgcmV0dXJuIHJvb3QyOwogICAgICB9OwogICAgfQogICAgaWYgKFAgJSBfMTZuID09PSBfOW4pIHsKICAgIH0KICAgIHJldHVybiB0b25lbGxpU2hhbmtzKFApOwogIH0KICBmdW5jdGlvbiB2YWxpZGF0ZUZpZWxkKGZpZWxkKSB7CiAgICBjb25zdCBpbml0aWFsID0gewogICAgICBPUkRFUjogImJpZ2ludCIsCiAgICAgIE1BU0s6ICJiaWdpbnQiLAogICAgICBCWVRFUzogImlzU2FmZUludGVnZXIiLAogICAgICBCSVRTOiAiaXNTYWZlSW50ZWdlciIKICAgIH07CiAgICBjb25zdCBvcHRzID0gRklFTERfRklFTERTLnJlZHVjZSgobWFwLCB2YWwpID0+IHsKICAgICAgbWFwW3ZhbF0gPSAiZnVuY3Rpb24iOwogICAgICByZXR1cm4gbWFwOwogICAgfSwgaW5pdGlhbCk7CiAgICByZXR1cm4gdmFsaWRhdGVPYmplY3QoZmllbGQsIG9wdHMpOwogIH0KICBmdW5jdGlvbiBGcFBvdyhmMiwgbnVtMiwgcG93ZXIpIHsKICAgIGlmIChwb3dlciA8IF8wbjMpCiAgICAgIHRocm93IG5ldyBFcnJvcigiRXhwZWN0ZWQgcG93ZXIgPiAwIik7CiAgICBpZiAocG93ZXIgPT09IF8wbjMpCiAgICAgIHJldHVybiBmMi5PTkU7CiAgICBpZiAocG93ZXIgPT09IF8xbjMpCiAgICAgIHJldHVybiBudW0yOwogICAgbGV0IHAgPSBmMi5PTkU7CiAgICBsZXQgZCA9IG51bTI7CiAgICB3aGlsZSAocG93ZXIgPiBfMG4zKSB7CiAgICAgIGlmIChwb3dlciAmIF8xbjMpCiAgICAgICAgcCA9IGYyLm11bChwLCBkKTsKICAgICAgZCA9IGYyLnNxcihkKTsKICAgICAgcG93ZXIgPj49IF8xbjM7CiAgICB9CiAgICByZXR1cm4gcDsKICB9CiAgZnVuY3Rpb24gRnBJbnZlcnRCYXRjaChmMiwgbnVtcykgewogICAgY29uc3QgdG1wID0gbmV3IEFycmF5KG51bXMubGVuZ3RoKTsKICAgIGNvbnN0IGxhc3RNdWx0aXBsaWVkID0gbnVtcy5yZWR1Y2UoKGFjYywgbnVtMiwgaSkgPT4gewogICAgICBpZiAoZjIuaXMwKG51bTIpKQogICAgICAgIHJldHVybiBhY2M7CiAgICAgIHRtcFtpXSA9IGFjYzsKICAgICAgcmV0dXJuIGYyLm11bChhY2MsIG51bTIpOwogICAgfSwgZjIuT05F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IgPSBPYmplY3QuZnJlZXplKHsKICAgICAgT1JERVIsCiAgICAgIEJJVFMsCiAgICAgIEJZVEVTLAogICAgICBNQVNLOiBiaXRNYXNrKEJJVFMpLAogICAgICBaRVJPOiBfMG4zLAogICAgICBPTkU6IF8xbjMsCiAgICAgIGNyZWF0ZTogKG51bTIpID0+IG1vZChudW0yLCBPUkRFUiksCiAgICAgIGlzVmFsaWQ6IChudW0yKSA9PiB7CiAgICAgICAgaWYgKHR5cGVvZiBudW0yICE9PSAiYmlnaW50IikKICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgSW52YWxpZCBmaWVsZCBlbGVtZW50OiBleHBlY3RlZCBiaWdpbnQsIGdvdCAke3R5cGVvZiBudW0yfWApOwogICAgICAgIHJldHVybiBfMG4zIDw9IG51bTIgJiYgbnVtMiA8IE9SREVSOwogICAgICB9LAogICAgICBpczA6IChudW0yKSA9PiBudW0yID09PSBfMG4zLAogICAgICBpc09kZDogKG51bTIpID0+IChudW0yICYgXzFuMykgPT09IF8xbjMsCiAgICAgIG5lZzogKG51bTIpID0+IG1vZCgtbnVtMiwgT1JERVIpLAogICAgICBlcWw6IChsaHMsIHJocykgPT4gbGhzID09PSByaHMsCiAgICAgIHNxcjogKG51bTIpID0+IG1vZChudW0yICogbnVtMiwgT1JERVIpLAogICAgICBhZGQ6IChsaHMsIHJocykgPT4gbW9kKGxocyArIHJocywgT1JERVIpLAogICAgICBzdWI6IChsaHMsIHJocykgPT4gbW9kKGxocyAtIHJocywgT1JERVIpLAogICAgICBtdWw6IChsaHMsIHJocykgPT4gbW9kKGxocyAqIHJocywgT1JERVIpLAogICAgICBwb3c6IChudW0yLCBwb3dlcikgPT4gRnBQb3coZjIsIG51bTIsIHBvd2VyKSwKICAgICAgZGl2OiAobGhzLCByaHMpID0+IG1vZChsaHMgKiBpbnZlcnQocmhzLCBPUkRFUiksIE9SREVSKSwKICAgICAgLy8gU2FtZSBhcyBhYm92ZSwgYnV0IGRvZXNuJ3Qgbm9ybWFsaXplCiAgICAgIHNxck46IChudW0yKSA9PiBudW0yICogbnVtMiwKICAgICAgYWRkTjogKGxocywgcmhzKSA9PiBsaHMgKyByaHMsCiAgICAgIHN1Yk46IChsaHMsIHJocykgPT4gbGhzIC0gcmhzLAogICAgICBtdWxOOiAobGhzLCByaHMpID0+IGxocyAqIHJocywKICAgICAgaW52OiAobnVtMikgPT4gaW52ZXJ0KG51bTIsIE9SREVSKSwKICAgICAgc3FydDogcmVkZWYuc3FydCB8fCAoKG4pID0+IHNxcnRQKGYyLCBuKSksCiAgICAgIGludmVydEJhdGNoOiAobHN0KSA9PiBGcEludmVydEJhdGNoKGYyLCBsc3QpLAogICAgICAvLyBUT0RPOiBkbyB3ZSByZWFsbHkgbmVlZCBjb25zdGFudCBjbW92PwogICAgICAvLyBXZSBkb24ndCBoYXZlIGNvbnN0LXRpbWUgYmlnaW50cyBhbnl3YXksIHNvIHByb2JhYmx5IHdpbGwgYmUgbm90IHZlcnkgdXNlZnVsCiAgICAgIGNtb3Y6IChhLCBiLCBjKSA9PiBjID8gYiA6IGEsCiAgICAgIHRvQnl0ZXM6IChudW0yKSA9PiBpc0xFMiA/IG51bWJlclRvQnl0ZXNMRShudW0yLCBCWVRFUykgOiBudW1iZXJUb0J5dGVzQkUobnVtMiwgQllURVMpLAogICAgICBmcm9tQnl0ZXM6IChieXRlczIpID0+IHsKICAgICAgICBpZiAoYnl0ZXMyLmxlbmd0aCAhPT0gQllURVMpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEZwLmZyb21CeXRlczogZXhwZWN0ZWQgJHtCWVRFU30sIGdvdCAke2J5dGVzMi5sZW5ndGh9YCk7CiAgICAgICAgcmV0dXJuIGlzTEUyID8gYnl0ZXNUb051bWJlckxFKGJ5dGVzMikgOiBieXRlc1RvTnVtYmVyQkUoYnl0ZXMyKTsKICAgICAgfQogICAgfSk7CiAgICByZXR1cm4gT2JqZWN0LmZyZWV6ZShmMik7CiAgfQogIGZ1bmN0aW9uI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lzTEUyID8gbnVtYmVyVG9CeXRlc0xFKHJlZHVjZWQsIGZpZWxkTGVuKSA6IG51bWJlclRvQnl0ZXNCRShyZWR1Y2VkLCBmaWVsZExlbik7CiAgfQogIHZhciBfMG4zLCBfMW4zLCBfMm4zLCBfM24sIF80biwgXzVuLCBfOG4sIF85biwgXzE2biwgRklFTERfRklFTERTOwogIHZhciBpbml0X21vZHVsYXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL0Bub2JsZStjdXJ2ZXNAMS42LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9jdXJ2ZXMvZXNtL2Fic3RyYWN0L21vZHVsYXIuanMiKCkgewogICAgICBpbml0X3V0aWxzNCgpOwogICAgICBfMG4zID0gQmlnSW50KDApOwogICAgICBfMW4zID0gQmlnSW50KDEpOwogICAgICBfMm4zID0gQmlnSW50KDIpOwogICAgICBfM24gPSBCaWdJbnQoMyk7CiAgICAgIF80biA9IEJpZ0ludCg0KTsKICAgICAgXzVuID0gQmlnSW50KDUpOwogICAgICBfOG4gPSBCaWdJbnQoOCk7CiAgICAgIF85biA9IEJpZ0ludCg5KTsKICAgICAgXzE2biA9IEJpZ0ludCgxNik7CiAgICAgIEZJRUxEX0ZJRUxEUyA9IFsKICAgICAgICAiY3JlYXRlIiwKICAgICAgICAiaXNWYWxpZCIsCiAgICAgICAgImlzMCIsCiAgICAgICAgIm5lZyIsCiAgICAgICAgImludiIsCiAgICAgICAgInNxcnQiLAogICAgICAgICJzcXIiLAogICAgICAgICJlcWwiLAogICAgICAgICJhZGQiLAogICAgICAgICJzdWIiLAogICAgICAgICJtdWwiLAogICAgICAgICJwb3ciLAogICAgICAgICJkaXYiLAogICAgICAgICJhZGROIiwKICAgICAgICAic3ViTiIsCiAgICAgICAgIm11bE4iLAogICAgICAgICJzcXJOIgogICAgICBdOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vQG5vYmxlK2N1cnZlc0AxLjYuMC9ub2RlX21vZHVsZXMvQG5vYmxlL2N1cnZlcy9lc20vYWJzdHJhY3QvY3VydmUuanMKICBmdW5jdGlvbiB3TkFGKGMsIGJpdHMpIHsKICAgIGNvbnN0IGNvbnN0VGltZU5lZ2F0ZSA9IChjb25kaXRpb24sIGl0ZW0pID0+IHsKICAgICAgY29uc3QgbmVnID0gaXRlbS5uZWdhdGUoKTsKICAgICAgcmV0dXJuIGNvbmRpdGlvbiA/IG5lZyA6IGl0ZW07CiAgICB9OwogICAgY29uc3QgdmFsaWRhdGVXID0gKFcpID0+IHsKICAgICAgaWYgKCFOdW1iZXIuaXNTYWZlSW50ZWdlcihXKSB8fCBXIDw9IDAgfHwgVyA+IGJpdHMpCiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBXcm9uZyB3aW5kb3cgc2l6ZT0ke1d9LCBzaG91bGQgYmUgWzEuLiR7Yml0c31dYCk7CiAgICB9OwogICAgY29uc3Qgb3B0cyA9IChXKSA9PiB7CiAgICAgIHZhbGlkYXRlVyhXKTsKICAgICAgY29uc3Qgd2luZG93cyA9IE1hdGguY2VpbChiaXRzIC8gVykgKyAxOwogICAgICBjb25zdCB3aW5kb3dTaXplID0gMiAqKiAoVyAtIDEpOwogICAgICByZXR1cm4geyB3aW5kb3dzLCB3aW5kb3dTaXplIH07CiAgICB9OwogICAgcmV0dXJuIHsKICAgICAgY29uc3RUaW1lTmVnYXRlLAogICAgICAvLyBub24tY29uc3QgdGltZSBtdWx0aXBsaWNhdGlvbiBsYWRkZXIKICAgICAgdW5zYWZlTGFkZGVyKGVsbSwgbikgewogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBkID0gZWxtOwogICAgICAgIHdoaWxlIChuID4gXzBuNCkgewogICAgICAgICAgaWYgKG4gJiBfMW40KQogICAgICAgICAgICBwID0gcC5hZGQoZCk7CiAgICAgICAgICBkID0gZC5kb3VibGUoKTsKICAgICAgICAgIG4gPj49IF8xbjQ7CiAgICAgICAgfQogICAgICA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AgICAgZm9yIChsZXQgaSA9IDE7IGkgPCB3aW5kb3dTaXplOyBpKyspIHsKICAgICAgICAgICAgYmFzZTIgPSBiYXNlMi5hZGQocCk7CiAgICAgICAgICAgIHBvaW50cy5wdXNoKGJhc2UyKTsKICAgICAgICAgIH0KICAgICAgICAgIHAgPSBiYXNlMi5kb3VibGUoKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBvaW50czsKICAgICAgfSwKICAgICAgLyoqCiAgICAgICAqIEltcGxlbWVudHMgZWMgbXVsdGlwbGljYXRpb24gdXNpbmcgcHJlY29tcHV0ZWQgdGFibGVzIGFuZCB3LWFyeSBub24tYWRqYWNlbnQgZm9ybS4KICAgICAgICogQHBhcmFtIFcgd2luZG93IHNpemUKICAgICAgICogQHBhcmFtIHByZWNvbXB1dGVzIHByZWNvbXB1dGVkIHRhYmxlcwogICAgICAgKiBAcGFyYW0gbiBzY2FsYXIgKHdlIGRvbid0IGNoZWNrIGhlcmUsIGJ1dCBzaG91bGQgYmUgbGVzcyB0aGFuIGN1cnZlIG9yZGVyKQogICAgICAgKiBAcmV0dXJucyByZWFsIGFuZCBmYWtlIChmb3IgY29uc3QtdGltZSkgcG9pbnRzCiAgICAgICAqLwogICAgICB3TkFGKFcsIHByZWNvbXB1dGVzLCBuKSB7CiAgICAgICAgY29uc3QgeyB3aW5kb3dzLCB3aW5kb3dTaXplIH0gPSBvcHRzKFcpOwogICAgICAgIGxldCBwID0gYy5aRVJPOwogICAgICAgIGxldCBmMiA9IGMuQkFTRTsKICAgICAgICBjb25zdCBtYXNrID0gQmlnSW50KDIgKiogVyAtIDEpOwogICAgICAgIGNvbnN0IG1heE51bWJlciA9IDIgKiogVzsKICAgICAgICBjb25zdCBzaGlmdEJ5ID0gQmlnSW50KFcpOwogICAgICAgIGZvciAobGV0IHdpbmRvdzIgPSAwOyB3aW5kb3cyIDwgd2luZG93czsgd2luZG93MisrKSB7CiAgICAgICAgICBjb25zdCBvZmZzZXQgPSB3aW5kb3cyICogd2luZG93U2l6ZTsKICAgICAgICAgIGxldCB3Yml0cyA9IE51bWJlcihuICYgbWFzayk7CiAgICAgICAgICBuID4+PSBzaGlmdEJ5OwogICAgICAgICAgaWYgKHdiaXRzID4gd2luZG93U2l6ZSkgewogICAgICAgICAgICB3Yml0cyAtPSBtYXhOdW1iZXI7CiAgICAgICAgICAgIG4gKz0gXzFuNDsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG9mZnNldDEgPSBvZmZzZXQ7CiAgICAgICAgICBjb25zdCBvZmZzZXQyID0gb2Zmc2V0ICsgTWF0aC5hYnMod2JpdHMpIC0gMTsKICAgICAgICAgIGNvbnN0IGNvbmQxID0gd2luZG93MiAlIDIgIT09IDA7CiAgICAgICAgICBjb25zdCBjb25kMiA9IHdiaXRzIDwgMDsKICAgICAgICAgIGlmICh3Yml0cyA9PT0gMCkgewogICAgICAgICAgICBmMiA9IGYyLmFkZChjb25zdFRpbWVOZWdhdGUoY29uZDEsIHByZWNvbXB1dGVzW29mZnNldDFdKSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwID0gcC5hZGQoY29uc3RUaW1lTmVnYXRlKGNvbmQyLCBwcmVjb21wdXRlc1tvZmZzZXQyXSkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4geyBwLCBmOiBmMiB9OwogICAgICB9LAogICAgICB3TkFGQ2FjaGVkKFAsIG4sIHRyYW5zZm9ybSkgewogICAgICAgIGNvbnN0IFcgPSBwb2ludFdpbmRvd1NpemVzLmdldChQKSB8fCAxOwogICAgICAgIGxldCBjb21wID0gcG9pbnRQcmVjb21wdXRlcy5nZXQoUCk7CiAgICAgICAgaWYgKCFjb21wKSB7CiAgICAgICAgICBjb21wID0gdGhpcy5wcmVjb21wdXRlV2luZG93KFAsIFcpOwogICAgICAgICAgaWYgKFcgIT09IDEpCiAgICAgICAgICAgIHBvaW50UHJlY29tcHV0ZXMuc2V0KFAsIHRyYW5zZm9ybShjb21wK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AgICAgIGlmIChpc0J5dGVzMihrZXkpKQogICAgICAgICAga2V5ID0gYnl0ZXNUb0hleDIoa2V5KTsKICAgICAgICBpZiAodHlwZW9mIGtleSAhPT0gInN0cmluZyIgfHwgIWxlbmd0aHMuaW5jbHVkZXMoa2V5Lmxlbmd0aCkpCiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQga2V5Iik7CiAgICAgICAga2V5ID0ga2V5LnBhZFN0YXJ0KG5CeXRlTGVuZ3RoICogMiwgIjAiKTsKICAgICAgfQogICAgICBsZXQgbnVtMjsKICAgICAgdHJ5IHsKICAgICAgICBudW0yID0gdHlwZW9mIGtleSA9PT0gImJpZ2ludCIgPyBrZXkgOiBieXRlc1RvTnVtYmVyQkUoZW5zdXJlQnl0ZXMoInByaXZhdGUga2V5Iiwga2V5LCBuQnl0ZUxlbmd0aCkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIHRocm93IG5ldyBFcnJvcihgcHJpdmF0ZSBrZXkgbXVzdCBiZSAke25CeXRlTGVuZ3RofSBieXRlcywgaGV4IG9yIGJpZ2ludCwgbm90ICR7dHlwZW9mIGtleX1gKTsKICAgICAgfQogICAgICBpZiAod3JhcFByaXZhdGVLZXkpCiAgICAgICAgbnVtMiA9IG1vZChudW0yLCBOKTsKICAgICAgYUluUmFuZ2UoInByaXZhdGUga2V5IiwgbnVtMiwgXzFuNSwgTik7CiAgICAgIHJldHVybiBudW0yOwogICAgfQogICAgZnVuY3Rpb24gYXNzZXJ0UHJqUG9pbnQob3RoZXIpIHsKICAgICAgaWYgKCEob3RoZXIgaW5zdGFuY2VvZiBQb2ludDIpKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiUHJvamVjdGl2ZVBvaW50IGV4cGVjdGVkIik7CiAgICB9CiAgICBjb25zdCB0b0FmZmluZU1lbW8gPSBtZW1vaXplZCgocCwgaXopID0+IHsKICAgICAgY29uc3QgeyBweDogeCwgcHk6IHksIHB6OiB6IH0gPSBw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KHkpKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJpbnZhbGlkIGFmZmluZSBwb2ludCIpOwogICAgICAgIGlmIChwIGluc3RhbmNlb2YgUG9pbnQyKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJwcm9qZWN0aXZlIHBvaW50IG5vdCBhbGxvd2VkIik7CiAgICAgICAgY29uc3QgaXMwID0gKGkpID0+IEZwMi5lcWwoaSwgRnAyLlpFUk8pOwogICAgICAgIGlmIChpczAoeCkgJiYgaXMwKHkpKQogICAgICAgICAgcmV0dXJuIFBvaW50Mi5aRVJPOwogICAgICAgIHJldHVybiBuZXcgUG9pbnQyKHgsIHksIEZwMi5PTkUpOwogICAgICB9CiAgICAgIGdldCB4KCkgewogICAgICAgIHJldHVybiB0aGlzLnRvQWZmaW5lKCkueDsKICAgICAgfQogICAgICBnZXQgeSgpIHsKICAgICAgICByZXR1cm4gdGhpcy50b0FmZmluZSgpLnk7CiAgICAgIH0KICAgICAgLyoqCiAgICAgICAqIFRha2VzIGEgYnVuY2ggb2YgUHJvamVjdGl2ZSBQb2ludHMgYnV0IGV4ZWN1dGVzIG9ubHkgb25lCiAgICAgICAqIGludmVyc2lvbiBvbiBhbGwgb2YgdGhlbS4gSW52ZXJzaW9uIGlzIHZlcnkgc2xvdyBvcGVyYXRpb24sCiAgICAgICAqIHNvIHRoaXMgaW1wcm92ZXMgcGVyZm9ybWFuY2UgbWFzc2l2ZWx5LgogICAgICAgKiBPcHRpbWl6YXRpb246IGNvbnZlcnRzIGEgbGlzdCBvZiBwcm9qZWN0aXZlIHBvaW50cyB0byBhIGxpc3Qgb2YgaWRlbnRpY2FsIHBvaW50cyB3aXRoIFo9MS4KICAgICAgICovCiAgICAgIHN0YXRpYyBub3JtYWxpemVaKHBvaW50cykgewogICAgICAgIGNvbnN0IHRvSW52ID0gRnAyLmludmVydEJhdGNoKHBvaW50cy5tYXAoKHApID0+IHAucHopKTsKICAgICAgICByZXR1cm4gcG9pbnRzLm1h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GNlcHRpb24tZnJlZSBkb3VibGluZyBmb3JtdWxhLgogICAgICAvLyBUaGVyZSBpcyAzMCUgZmFzdGVyIEphY29iaWFuIGZvcm11bGEsIGJ1dCBpdCBpcyBub3QgY29tcGxldGUuCiAgICAgIC8vIGh0dHBzOi8vZXByaW50LmlhY3Iub3JnLzIwMTUvMTA2MCwgYWxnb3JpdGhtIDMKICAgICAgLy8gQ29zdDogOE0gKyAzUyArIDMqYSArIDIqYjMgKyAxNWFkZC4KICAgICAgZG91YmxlKCkgewogICAgICAgIGNvbnN0IHsgYSwgYiB9ID0gQ1VSVkU7CiAgICAgICAgY29uc3QgYjMyID0gRnAyLm11bChiLCBfM24yKTsKICAgICAgICBjb25zdCB7IHB4OiBYMSwgcHk6IFkxLCBwejogWjEgfSA9IHRoaXM7CiAgICAgICAgbGV0IFgzID0gRnAyLlpFUk8sIFkzID0gRnAyLlpFUk8sIFozID0gRnAyLlpFUk87CiAgICAgICAgbGV0IHQwID0gRnAyLm11bChYMSwgWDEpOwogICAgICAgIGxldCB0MSA9IEZwMi5tdWwoWTEsIFkxKTsKICAgICAgICBsZXQgdDIgPSBGcDIubXVsKFoxLCBaMSk7CiAgICAgICAgbGV0IHQzID0gRnAyLm11bChYMSwgWTEpOwogICAgICAgIHQzID0gRnAyLmFkZCh0MywgdDMpOwogICAgICAgIFozID0gRnAyLm11bChYMSwgWjEpOwogICAgICAgIFozID0gRnAyLmFkZChaMywgWjMpOwogICAgICAgIFgzID0gRnAyLm11bChhLCBaMyk7CiAgICAgICAgWTMgPSBGcDIubXVsKGIzMiwgdDIpOwogICAgICAgIFkzID0gRnAyLmFkZChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLnN1Yih0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLmFkZCh0MSwgWTMpOwogICAgICAgIFkzID0gRnAyLm11bChYMywgWTMpOwogICAgICAgIFgzID0gRnAyLm11bCh0MywgWDMpOwogICAgICAgIFozID0gRnAyLm11bChiMzIsIFozKTs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lZCh0aGlzLCBuLCBQb2ludDIubm9ybWFsaXplWik7CiAgICAgIH0KICAgICAgLyoqCiAgICAgICAqIE5vbi1jb25zdGFudC10aW1lIG11bHRpcGxpY2F0aW9uLiBVc2VzIGRvdWJsZS1hbmQtYWRkIGFsZ29yaXRobS4KICAgICAgICogSXQncyBmYXN0ZXIsIGJ1dCBzaG91bGQgb25seSBiZSB1c2VkIHdoZW4geW91IGRvbid0IGNhcmUgYWJvdXQKICAgICAgICogYW4gZXhwb3NlZCBwcml2YXRlIGtleSBlLmcuIHNpZyB2ZXJpZmljYXRpb24sIHdoaWNoIHdvcmtzIG92ZXIgKnB1YmxpYyoga2V5cy4KICAgICAgICovCiAgICAgIG11bHRpcGx5VW5zYWZlKHNjKSB7CiAgICAgICAgYUluUmFuZ2UoInNjYWxhciIsIHNjLCBfMG41LCBDVVJWRS5uKTsKICAgICAgICBjb25zdCBJID0gUG9pbnQyLlpFUk87CiAgICAgICAgaWYgKHNjID09PSBfMG41KQogICAgICAgICAgcmV0dXJuIEk7CiAgICAgICAgaWYgKHNjID09PSBfMW41KQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgY29uc3QgeyBlbmRvIH0gPSBDVVJWRTsKICAgICAgICBpZiAoIWVuZG8pCiAgICAgICAgICByZXR1cm4gd25hZi51bnNhZmVMYWRkZXIodGhpcywgc2MpOwogICAgICAgIGxldCB7IGsxbmVnLCBrMSwgazJuZWcsIGsyIH0gPSBlbmRvLnNwbGl0U2NhbGFyKHNjKTsKICAgICAgICBsZXQgazFwID0gSTsKICAgICAgICBsZXQgazJwID0gSTsKICAgICAgICBsZXQgZCA9IHRoaXM7CiAgICAgICAgd2hpbGUgKGsxID4gXzBuNSB8fCBrMiA+IF8wbjUpIHsKICAgICAgICAgIGlmIChrMSAmIF8xbjUpCiAgICAgICAgICAgIGsxcCA9IGsxcC5hZGQoZCk7CiAgICAgICAgICBpZiAoazIgJiBfMW41KQogICAgICAgICAgICBrMnAgPSBrMnAuYWRkKGQpOwogICAgICAgICAgZCA9IGQuZG91YmxlKCk7CiAgICAgICAgICBrMSA+Pj0gXzFuNTsKICAgICAgICAgIGsyID4+PSBfMW41OwogICAgICAgIH0KICAgICAgICBpZiAoazFuZWcpCiAgICAgICAgICBrMXAgPSBrMXAubmVnYXRlKCk7CiAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgazJwID0gazJwLm5lZ2F0ZSgpOwogICAgICAgIGsycCA9IG5ldyBQb2ludDIoRnAyLm11bChrMnAucHgsIGVuZG8uYmV0YSksIGsycC5weSwgazJwLnB6KTsKICAgICAgICByZXR1cm4gazFwLmFkZChrMnApOwogICAgICB9CiAgICAgIC8qKgogICAgICAgKiBDb25zdGFudCB0aW1lIG11bHRpcGxpY2F0aW9uLgogICAgICAgKiBVc2VzIHdOQUYgbWV0aG9kLiBXaW5kb3dlZCBtZXRob2QgbWF5IGJlIDEwJSBmYXN0ZXIsCiAgICAgICAqIGJ1dCB0YWtlcyAyeCBsb25nZXIgdG8gZ2VuZXJhdGUgYW5kIGNvbnN1bWVzIDJ4IG1lbW9yeS4KICAgICAgICogVXNlcyBwcmVjb21wdXRlcyB3aGVuIGF2YWlsYWJsZS4KICAgICAgICogVXNlcyBlbmRvbW9ycGhpc20gZm9yIEtvYmxpdHogY3VydmVzLgogICAgICAgKiBAcGFyYW0gc2NhbGFyIGJ5IHdoaWNoIHRoZSBwb2ludCB3b3VsZCBiZSBtdWx0aXBsaWVkCiAgICAgICAqIEByZXR1cm5zIE5ldyBwb2ludAogICAgICAgKi8KICAgICAgbXVsdGlwbHkoc2NhbGFyKSB7CiAgICAgICAgY29uc3QgeyBlbmRvLCBuOiBOIH0gPSBDVVJWRTsKICAgICAgICBhSW5SYW5nZSgic2NhbGFyIiwgc2NhbGFyLCBfMW41LCBOKTsKICAgICAgICBsZXQgcG9pbnQsIGZha2U7CiAgICAgICAgaWYgKGVuZG8pIHsKICAgICAgICAgIGNvbnN0IHsgazFuZWcsIGsxLCBrMm5lZywgazIgfSA9IGVuZG8uc3BsaXRTY2FsYXIoc2NhbGFyKTsKICAgICAgICAgIGxldCB7IHA6IGsxcCwgZjogZjFwIH0gPSB0aGlzLndOQUYoazEpOwogICAgICAgICAgbGV0IHsgcDogazJwLCBmOiBmMnAgfSA9IHRoaXMud05BRihrMik7CiAgICAgICAgICBrMXAgPSB3bmFmLmNvbnN0VGltZU5lZ2F0ZShrMW5lZywgazFwKTsKICAgICAgICAgIGsycCA9IHduYWYuY29uc3RUaW1lTmVnYXRlKGsybmVnLCBrMnApOwogICAgICAgICAgazJwID0gbmV3IFBvaW50MihGcDIubXVsKGsycC5weCwgZW5kby5iZXRhKSwgazJwLnB5LCBrMnAucHopOwogICAgICAgICAgcG9pbnQgPSBrMXAuYWRkKGsycCk7CiAgICAgICAgICBmYWtlID0gZjFwLmFkZChmMnApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCB7IHAsIGY6IGYyIH0gPSB0aGlzLndOQUYoc2NhbGFyKTsKICAgICAgICAgIHBvaW50ID0gcDsKICAgICAgICAgIGZha2UgPSBmMjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIFBvaW50Mi5ub3JtYWxpemVaKFtwb2ludCwgZmFrZV0pWzBdOwogICAgICB9CiAgICAgIC8qKgogICAgICAgKiBFZmZpY2llbnRseSBjYWxjdWxhdGUgYGFQICsgYlFgLiBVbnNhZmUsIGNhbiBleHBvc2UgcHJpdmF0ZSBrZXksIGlmIHVzZWQgaW5jb3JyZWN0bHkuCiAgICAgICAqIE5vdCB1c2luZyBTdHJhdXNzLVNoYW1pciB0cmljazogcHJlY29tcHV0YXRpb24gdGFibGVzIGFyZSBmYXN0ZXIuCiAgICAgICAqIFRoZSB0cmljayBjb3VsZCBiZSB1c2VmdWwgaWYgYm90aCBQIGFuZCBRIGFyZSBub3QgRyAobm90IGluIG91ciBjYXNlKS4KICAgICAgICogQHJldHVybnMgbm9uLXplcm8gYWZmaW5lIHBvaW50CiAgICAgICAqLwog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ml2YXRlS2V5VG9TY2FsYXIsIHdlaWVyc3RyYXNzRXF1YXRpb24sIGlzV2l0aGluQ3VydmVPcmRlciB9ID0gd2VpZXJzdHJhc3NQb2ludHMoewogICAgICAuLi5DVVJWRSwKICAgICAgdG9CeXRlcyhfYywgcG9pbnQsIGlzQ29tcHJlc3NlZCkgewogICAgICAgIGNvbnN0IGEgPSBwb2ludC50b0FmZmluZSgpOwogICAgICAgIGNvbnN0IHggPSBGcDIudG9CeXRlcyhhLngpOwogICAgICAgIGNvbnN0IGNhdCA9IGNvbmNhdEJ5dGVzMzsKICAgICAgICBhYm9vbCgiaXNDb21wcmVzc2VkIiwgaXNDb21wcmVzc2VkKTsKICAgICAgICBpZiAoaXNDb21wcmVzc2VkKSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbcG9pbnQuaGFzRXZlblkoKSA/IDIgOiAzXSksIHgpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXR1cm4gY2F0KFVpbnQ4QXJyYXkuZnJvbShbNF0pLCB4LCBGcDIudG9CeXRlcyhhLnkpKTsKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGZyb21CeXRlcyhieXRlczIpIHsKICAgICAgICBjb25zdCBsZW4gPSBieXRlczIubGVuZ3RoOwogICAgICAgIGNvbnN0IGhlYWQgPSBieXRlczJbMF07CiAgICAgICAgY29uc3QgdGFpbCA9IGJ5dGVzMi5zdWJhcnJheSgxKTsKICAgICAgICBpZiAobGVuID09PSBjb21wcmVzc2VkTGVuICYmIChoZWFkID09PSAyIHx8IGhlYWQgPT09IDMpKSB7CiAgICAgICAgICBjb25zdCB4ID0gYnl0ZXNUb051bWJlckJFKHRhaWwpOwogICAgICAgICAgaWYgKCFpblJhbmdlKHgsIF8xbjUsIEZwMi5PUkRFUikpCiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiUG9pbnQgaXMgbm90IG9uIGN1cnZlIik7CiAgICAgICAgICBjb25zdCB5Mi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AgICBpZiAocHJlaGFzaCkKICAgICAgICBtc2dIYXNoID0gZW5zdXJlQnl0ZXMoInByZWhhc2hlZCBtc2dIYXNoIiwgaGFzaDMobXNnSGFzaCkpOwogICAgICBjb25zdCBoMWludCA9IGJpdHMyaW50X21vZE4obXNnSGFzaCk7CiAgICAgIGNvbnN0IGQgPSBub3JtUHJpdmF0ZUtleVRvU2NhbGFyKHByaXZhdGVLZXkpOwogICAgICBjb25zdCBzZWVkQXJncyA9IFtpbnQyb2N0ZXRzKGQpLCBpbnQyb2N0ZXRzKGgxaW50KV07CiAgICAgIGlmIChlbnQgIT0gbnVsbCAmJiBlbnQgIT09IGZhbHNlKSB7CiAgICAgICAgY29uc3QgZSA9IGVudCA9PT0gdHJ1ZSA/IHJhbmRvbUJ5dGVzMihGcDIuQllURVMpIDogZW50OwogICAgICAgIHNlZWRBcmdzLnB1c2goZW5zdXJlQnl0ZXMoImV4dHJhRW50cm9weSIsIGUpKTsKICAgICAgfQogICAgICBjb25zdCBzZWVkID0gY29uY2F0Qnl0ZXMzKC4uLnNlZWRBcmdzKTsKICAgICAgY29uc3QgbSA9IGgxaW50OwogICAgICBmdW5jdGlvbiBrMnNpZyhrQnl0ZXMpIHsKICAgICAgICBjb25zdCBrID0gYml0czJpbnQoa0J5dGVzKTsKICAgICAgICBpZiAoIWlzV2l0aGluQ3VydmVPcmRlcihrKSkKICAgICAgICAgIHJldHVybjsKICAgICAgICBjb25zdCBpayA9IGludk4oayk7CiAgICAgICAgY29uc3QgcSA9IFBvaW50Mi5CQVNFLm11bHRpcGx5KGspLnRvQWZmaW5lKCk7CiAgICAgICAgY29uc3QgciA9IG1vZE4yKHEueCk7CiAgICAgICAgaWYgKHIgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgY29uc3QgcyA9IG1vZE4yKGlrICogbW9kTjIobSArIHIgKiBkKSk7CiAgICAgICAgaWYgKHMgPT09IF8wbjUpCiAgICAgICAgICByZXR1cm47CiAgICAgICAgbG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ludDIuZnJvbUhleChwdWJsaWNLZXkpOwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChlcnJvci5tZXNzYWdlID09PSAiUEFSU0UiKQogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzaWduYXR1cmUgbXVzdCBiZSBTaWduYXR1cmUgaW5zdGFuY2UsIFVpbnQ4QXJyYXkgb3IgaGV4IHN0cmluZ2ApOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobG93UyAmJiBfc2lnLmhhc0hpZ2hTKCkpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICBpZiAocHJlaGFzaCkKICAgICAgICBtc2dIYXNoID0gQ1VSVkUuaGFzaChtc2dIYXNoKTsKICAgICAgY29uc3QgeyByLCBzIH0gPSBfc2lnOwogICAgICBjb25zdCBoID0gYml0czJpbnRfbW9kTihtc2dIYXNoKTsKICAgICAgY29uc3QgaXMgPSBpbnZOKHMpOwogICAgICBjb25zdCB1MSA9IG1vZE4yKGggKiBpcyk7CiAgICAgIGNvbnN0IHUyID0gbW9kTjIociAqIGlzKTsKICAgICAgY29uc3QgUiA9IFBvaW50Mi5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFAsIHUxLCB1Mik/LnRvQWZmaW5lKCk7CiAgICAgIGlmICghUikKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgIGNvbnN0IHYgPSBtb2ROMihSLngpOwogICAgICByZXR1cm4gdiA9PT0gcjsKICAgIH0KICAgIHJldHVybiB7CiAgICAgIENVUlZFLAogICAgICBnZXRQdWJsaWNLZXksCiAgICAgIGdldFNoYXJlZFNlY3JldCwKICAgICAgc2lnbjogc2lnbjIsCiAgICAgIHZlcmlmeSwKICAgICAgUHJvamVjdGl2ZVBvaW50OiBQb2ludDIsCiAgICAgIFNpZ25hdHVyZSwKICAgICAgdXRpbHMKICAgIH07CiAgfQogIGZ1bmN0aW9uIFNXVUZwU3FydFJhdGlvKEZwMiwg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sIEZwMi5PTkUpOwogICAgICB0djIgPSBGcDIubXVsKHR2MywgYzcpOwogICAgICB0djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgdHYzID0gRnAyLmNtb3YodHYyLCB0djMsIGlzUVIpOwogICAgICB0djQgPSBGcDIuY21vdih0djUsIHR2NCwgaXNRUik7CiAgICAgIGZvciAobGV0IGkgPSBjMTsgaSA+IF8xbjU7IGktLSkgewogICAgICAgIGxldCB0djUyID0gaSAtIF8ybjQ7CiAgICAgICAgdHY1MiA9IF8ybjQgPDwgdHY1MiAtIF8xbjU7CiAgICAgICAgbGV0IHR2djUgPSBGcDIucG93KHR2NCwgdHY1Mik7CiAgICAgICAgY29uc3QgZTEgPSBGcDIuZXFsKHR2djUsIEZwMi5PTkUpOwogICAgICAgIHR2MiA9IEZwMi5tdWwodHYzLCB0djEpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djEpOwogICAgICAgIHR2djUgPSBGcDIubXVsKHR2NCwgdHYxKTsKICAgICAgICB0djMgPSBGcDIuY21vdih0djIsIHR2MywgZTEpOwogICAgICAgIHR2NCA9IEZwMi5jbW92KHR2djUsIHR2NCwgZTEpOwogICAgICB9CiAgICAgIHJldHVybiB7IGlzVmFsaWQ6IGlzUVIsIHZhbHVlOiB0djMgfTsKICAgIH07CiAgICBpZiAoRnAyLk9SREVSICUgXzRuMiA9PT0gXzNuMikgewogICAgICBjb25zdCBjMTIgPSAoRnAyLk9SREVSIC0gXzNuMikgLyBfNG4yOwogICAgICBjb25zdCBjMjIgPSBGcDIuc3FydChGcDIubmVnKFopKTsKICAgICAgc3FydFJhdGlvID0gKHUsIHYpID0+IHsKICAgICAgICBsZXQgdHYxID0gRnAyLnNxcih2KTsKICAgICAgICBjb25zdCB0djIgPSBGcDIubXVsKHUsIHYpOwogICAgICAgIHR2MSA9IEZwMi5tdWwodHYxLCB0djIpOwogICAgICAgIGxldCB5MSA9IEZwMi5wb3codHYxLCBjMTIpOwogICAgICAgI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2R1bGVzLy5kZW5vL0Bub2JsZStjdXJ2ZXNAMS42LjAvbm9kZV9tb2R1bGVzL0Bub2JsZS9jdXJ2ZXMvZXNtL2Fic3RyYWN0L3dlaWVyc3RyYXNzLmpzIigpIHsKICAgICAgaW5pdF9jdXJ2ZSgpOwogICAgICBpbml0X21vZHVsYXIoKTsKICAgICAgaW5pdF91dGlsczQoKTsKICAgICAgaW5pdF91dGlsczQoKTsKICAgICAgKHsgYnl0ZXNUb051bWJlckJFOiBiMm4sIGhleFRvQnl0ZXM6IGgyYiB9ID0gdXRpbHNfZXhwb3J0cyk7CiAgICAgIERFUiA9IHsKICAgICAgICAvLyBhc24uMSBERVIgZW5jb2RpbmcgdXRpbHMKICAgICAgICBFcnI6IGNsYXNzIERFUkVyciBleHRlbmRzIEVycm9yIHsKICAgICAgICAgIGNvbnN0cnVjdG9yKG0gPSAiIikgewogICAgICAgICAgICBzdXBlcihtKTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIEJhc2ljIGJ1aWxkaW5nIGJsb2NrIGlzIFRMViAoVGFnLUxlbmd0aC1WYWx1ZSkKICAgICAgICBfdGx2OiB7CiAgICAgICAgICBlbmNvZGU6ICh0YWcsIGRhdGEpID0+IHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgaWYgKHRhZyA8IDAgfHwgdGFnID4gMjU2KQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZW5jb2RlOiB3cm9uZyB0YWciKTsKICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoICYgMSkKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogdW5wYWRkZWQgZGF0YSIpOwogICAgICAgICAgICBjb25zdCBkYXRhTGVuID0gZGF0YS5sZW5ndGggLyAyOwogICAgICAgICAgICBjb25zdCBsZW4gPSBudW1iZXJUb0hleFVucGFkZGVkKGRhdGFMZW4pOwogICAgICAgICAgICBpZiAobGVuLmxlbmd0aCAvIDIgJiAxMjgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5lbmNvZGU6IGxvbmcgZm9ybSBsZW5ndGggdG9vIGJpZyIpOwogICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBkYXRhTGVuID4gMTI3ID8gbnVtYmVyVG9IZXhVbnBhZGRlZChsZW4ubGVuZ3RoIC8gMiB8IDEyOCkgOiAiIjsKICAgICAgICAgICAgcmV0dXJuIGAke251bWJlclRvSGV4VW5wYWRkZWQodGFnKX0ke2xlbkxlbn0ke2xlbn0ke2RhdGF9YDsKICAgICAgICAgIH0sCiAgICAgICAgICAvLyB2IC0gdmFsdWUsIGwgLSBsZWZ0IGJ5dGVzICh1bnBhcnNlZCkKICAgICAgICAgIGRlY29kZSh0YWcsIGRhdGEpIHsKICAgICAgICAgICAgY29uc3QgeyBFcnI6IEUgfSA9IERFUjsKICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgIGlmICh0YWcgPCAwIHx8IHRhZyA+IDI1NikKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmVuY29kZTogd3JvbmcgdGFnIik7CiAgICAgICAgICAgIGlmIChkYXRhLmxlbmd0aCA8IDIgfHwgZGF0YVtwb3MrK10gIT09IHRhZykKICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZTogd3JvbmcgdGx2Iik7CiAgICAgICAgICAgIGNvbnN0IGZpcnN0ID0gZGF0YVtwb3MrK107CiAgICAgICAgICAgIGNvbnN0IGlzTG9uZyA9ICEhKGZpcnN0ICYgMTI4KTsKICAgICAgICAgICAgbGV0IGxlbmd0aCA9IDA7CiAgICAgICAgICAgIGlmICghaXNMb25nKQogICAgICAgICAgICAgIGxlbmd0aCA9IGZpcnN0OwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBsZW5MZW4gPSBmaXJzdCAmIDEyNzsKICAgICAgICAgICAgICBpZiAoIWxlbkxlbikKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBpbmRlZmluaXRlIGxlbmd0aCBub3Qgc3VwcG9ydGVkIik7CiAgICAgICAgICAgICAgaWYgKGxlbkxlbiA+IDQpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogYnl0ZSBsZW5ndGggaXMgdG9vIGJpZyIpOwogICAgICAgICAgICAgIGNvbnN0IGxlbmd0aEJ5dGVzID0gZGF0YS5zdWJhcnJheShwb3MsIHBvcyArIGxlbkxlbik7CiAgICAgICAgICAgICAgaWYgKGxlbmd0aEJ5dGVzLmxlbmd0aCAhPT0gbGVuTGVuKQogICAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5kZWNvZGU6IGxlbmd0aCBieXRlcyBub3QgY29tcGxldGUiKTsKICAgICAgICAgICAgICBpZiAobGVuZ3RoQnl0ZXNbMF0gPT09IDApCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRSgidGx2LmRlY29kZShsb25nKTogemVybyBsZWZ0bW9zdCBieXRlIik7CiAgICAgICAgICAgICAgZm9yIChjb25zdCBiIG9mIGxlbmd0aEJ5dGVzKQogICAgICAgICAgICAgICAgbGVuZ3RoID0gbGVuZ3RoIDw8IDggfCBiOwogICAgICAgICAgICAgIHBvcyArPSBsZW5MZW47CiAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IDEyOCkKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ0bHYuZGVjb2RlKGxvbmcpOiBub3QgbWluaW1hbCBlbmNvZGluZyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhLnN1YmFycmF5KHBvcywgcG9zICsgbGVuZ3RoKTsKICAgICAgICAgICAgaWYgKHYubGVuZ3RoICE9PSBsZW5ndGgpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoInRsdi5kZWNvZGU6IHdyb25nIHZhbHVlIGxlbmd0aCIpOwogICAgICAgICAgICByZXR1cm4geyB2LCBsOiBkYXRhLnN1YmFycmF5KHBvcyArIGxlbmd0aCkgfTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIC8vIGh0dHBzOi8vY3J5cHRvLnN0YWNrZXhjaGFuZ2UuY29tL2EvNTc3MzQgTGVmdG1vc3QgYml0IG9mIGZpcnN0IGJ5dGUgaXMgJ25lZ2F0aXZlJyBmbGFnLAogICAgICAgIC8vIHNpbmNlIHdlIGFsd2F5cyB1c2UgcG9zaXRpdmUgaW50ZWdlcnMgaGVyZS4gSXQgbXVzdCBhbHdheXMgYmUgZW1wdHk6CiAgICAgICAgLy8gLSBhZGQgemVybyBieXRlIGlmIGV4aXN0cwogICAgICAgIC8vIC0gaWYgbmV4dCBieXRlIGRvZXNuJ3QgaGF2ZSBhIGZsYWcsIGxlYWRpbmcgemVybyBpcyBub3QgYWxsb3dlZCAobWluaW1hbCBlbmNvZGluZykKICAgICAgICBfaW50OiB7CiAgICAgICAgICBlbmNvZGUobnVtMikgewogICAgICAgICAgICBjb25zdCB7IEVycjogRSB9ID0gREVSOwogICAgICAgICAgICBpZiAobnVtMiA8IF8wbjUpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IEUoImludGVnZXI6IG5lZ2F0aXZlIGludGVnZXJzIGFyZSBub3QgYWxsb3dlZCIpOwogICAgICAgICAgICBsZXQgaGV4ID0gbnVtYmVyVG9IZXhVbnBhZGRlZChudW0yKTsKICAgICAgICAgICAgaWYgKE51bWJlci5wYXJzZUludChoZXhbMF0sIDE2KSAmIDgpCiAgICAgICAgICAgICAgaGV4ID0gIjAwIiArIGhleDsKICAgICAgICAgICAgaWYgKGhleC5sZW5ndGggJiAxKQogICAgICAgICAgICAgIHRocm93IG5ldyBFKCJ1bmV4cGVjdGVkIGFzc2VydGlvbiIpOwogICAgICAgICAgICByZXR1cm4gaGV4OwogICAgICAgICAgfSwKICAgICAgICAgIGRlY29kZShk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fMl8xMjg7CiAgICAgICAgICAgIGNvbnN0IGsybmVnID0gazIgPiBQT1dfMl8xMjg7CiAgICAgICAgICAgIGlmIChrMW5lZykKICAgICAgICAgICAgICBrMSA9IG4gLSBrMTsKICAgICAgICAgICAgaWYgKGsybmVnKQogICAgICAgICAgICAgIGsyID0gbiAtIGsyOwogICAgICAgICAgICBpZiAoazEgPiBQT1dfMl8xMjggfHwgazIgPiBQT1dfMl8xMjgpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInNwbGl0U2NhbGFyOiBFbmRvbW9ycGhpc20gZmFpbGVkLCBrPSIgKyBrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4geyBrMW5lZywgazEsIGsybmVnLCBrMiB9OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSwgc2hhMjU2KTsKICAgICAgXzBuNiA9IEJpZ0ludCgwKTsKICAgICAgVEFHR0VEX0hBU0hfUFJFRklYRVMgPSB7fTsKICAgICAgcG9pbnRUb0J5dGVzID0gKHBvaW50KSA9PiBwb2ludC50b1Jhd0J5dGVzKHRydWUpLnNsaWNlKDEpOwogICAgICBudW1UbzMyYiA9IChuKSA9PiBudW1iZXJUb0J5dGVzQkUobiwgMzIpOwogICAgICBtb2RQID0gKHgpID0+IG1vZCh4LCBzZWNwMjU2azFQKTsKICAgICAgbW9kTiA9ICh4KSA9PiBtb2QoeCwgc2VjcDI1NmsxTik7CiAgICAgIFBvaW50ID0gc2VjcDI1NmsxLlByb2plY3RpdmVQb2ludDsKICAgICAgR211bEFkZCA9IChRLCBhLCBiKSA9PiBQb2ludC5CQVNFLm11bHRpcGx5QW5kQWRkVW5zYWZlKFEsIGEsIGIpOwogICAgICBudW0gPSBieXRlc1RvTnVtYmVyQkU7CiAgICAgIHNjaG5vcnIgPSAvKiBAX19QVVJFX18gKi8gKCgpID0+ICh7CiAgICAgICAgZ2V0UHVibGljS2V5OiBzY2hub3JyR2V0UHVibGljS2V5LAogICAgICAgI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AgICAgIGlmIChzbG90Lmxlbmd0aCAhPT0gNjYpCiAgICAgICAgdGhyb3cgbmV3IEludmFsaWRCeXRlc0xlbmd0aEVycm9yKHsKICAgICAgICAgIHNpemU6IHNsb3QubGVuZ3RoLAogICAgICAgICAgdGFyZ2V0U2l6ZTogNjYsCiAgICAgICAgICB0eXBlOiAiaGV4IgogICAgICAgIH0pOwogICAgICBpZiAodmFsdWUubGVuZ3RoICE9PSA2NikKICAgICAgICB0aHJvdyBuZXcgSW52YWxpZEJ5dGVzTGVuZ3RoRXJyb3IoewogICAgICAgICAgc2l6ZTogdmFsdWUubGVuZ3RoLAogICAgICAgICAgdGFyZ2V0U2l6ZTogNjYsCiAgICAgICAgICB0eXBlOiAiaGV4IgogICAgICAgIH0pOwogICAgICBhY2Nbc2xvdF0gPSB2YWx1ZTsKICAgICAgcmV0dXJuIGFjYzsKICAgIH0sIHt9KTsKICB9CiAgZnVuY3Rpb24gc2VyaWFsaXplQWNjb3VudFN0YXRlT3ZlcnJpZGUocGFyYW1ldGVycykgewogICAgY29uc3QgeyBiYWxhbmNlLCBub25jZSwgc3RhdGUsIHN0YXRlRGlmZiwgY29kZSB9ID0gcGFyYW1ldGVyczsKICAgIGNvbnN0IHJwY0FjY291bnRTdGF0ZU92ZXJyaWRlID0ge307CiAgICBpZiAoY29kZSAhPT0gdm9pZCAwKQogICAgICBycGNBY2NvdW50U3RhdGVPdmVycmlkZS5jb2RlID0gY29kZTsKICAgIGlmIChiYWxhbmNlICE9PSB2b2lkIDApCiAgICAgIHJwY0FjY291bnRTdGF0ZU92ZXJyaWRlLmJhbGFuY2UgPSBudW1iZXJUb0hleChiYWxhbmNlKTsKICAgIGlmIChub25jZSAhPT0gdm9pZCAwKQogICAgICBycGNBY2NvdW50U3RhdGVPdmVycmlkZS5ub25jZSA9IG51bWJlclRvSGV4KG5vbmNlKTsKICAgIGlmIChzdGF0ZSAhPT0gdm9pZCAwKQogICAgICBycGNBY2NvdW50U3RhdGVPdmVycmlkZ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MTUyLCBtaW5JbnQxNjAsIG1pbkludDE2OCwgbWluSW50MTc2LCBtaW5JbnQxODQsIG1pbkludDE5MiwgbWluSW50MjAwLCBtaW5JbnQyMDgsIG1pbkludDIxNiwgbWluSW50MjI0LCBtaW5JbnQyMzIsIG1pbkludDI0MCwgbWluSW50MjQ4LCBtaW5JbnQyNTYsIG1heFVpbnQ4LCBtYXhVaW50MTYsIG1heFVpbnQyNCwgbWF4VWludDMyLCBtYXhVaW50NDAsIG1heFVpbnQ0OCwgbWF4VWludDU2LCBtYXhVaW50NjQsIG1heFVpbnQ3MiwgbWF4VWludDgwLCBtYXhVaW50ODgsIG1heFVpbnQ5NiwgbWF4VWludDEwNCwgbWF4VWludDExMiwgbWF4VWludDEyMCwgbWF4VWludDEyOCwgbWF4VWludDEzNiwgbWF4VWludDE0NCwgbWF4VWludDE1MiwgbWF4VWludDE2MCwgbWF4VWludDE2OCwgbWF4VWludDE3NiwgbWF4VWludDE4NCwgbWF4VWludDE5MiwgbWF4VWludDIwMCwgbWF4VWludDIwOCwgbWF4VWludDIxNiwgbWF4VWludDIyNCwgbWF4VWludDIzMiwgbWF4VWludDI0MCwgbWF4VWludDI0OCwgbWF4VWludDI1NjsKICB2YXIgaW5pdF9udW1iZXIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NvbnN0YW50cy9udW1iZXIuanMiKCkgewogICAgICBtYXhJbnQ4ID0gMm4gKiogKDhuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDE2ID0gMm4gKiogKDE2biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQyNCA9IDJuICoqICgyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MzIgPSAybiAqKiAoMzJuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDQwID0gMm4gKiogKDQwbiAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ0OCA9IDJuICoqICg0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50NTYgPSAybiAqKiAoNTZuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDY0ID0gMm4gKiogKDY0biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ3MiA9IDJuICoqICg3Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50ODAgPSAybiAqKiAoODBuIC0gMW4pIC0gMW47CiAgICAgIG1heEludDg4ID0gMm4gKiogKDg4biAtIDFuKSAtIDFuOwogICAgICBtYXhJbnQ5NiA9IDJuICoqICg5Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTA0ID0gMm4gKiogKDEwNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTEyID0gMm4gKiogKDExMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTIwID0gMm4gKiogKDEyMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTI4ID0gMm4gKiogKDEyOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTM2ID0gMm4gKiogKDEzNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTQ0ID0gMm4gKiogKDE0NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTUyID0gMm4gKiogKDE1Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTYwID0gMm4gKiogKDE2MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTY4ID0gMm4gKiogKDE2OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTc2ID0gMm4gKiogKDE3Nm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTg0ID0gMm4gKiogKDE4NG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MTkyID0gMm4gKiogKDE5Mm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjAwID0gMm4gKiogKDIwMG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjA4ID0gMm4gKiogKDIwOG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjE2ID0gMm4gKiogKDIxNm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjI0ID0gMm4gKiogKDIyNG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjMyID0gMm4gKiogKDIzMm4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQwID0gMm4gKiogKDI0MG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjQ4ID0gMm4gKiogKDI0OG4gLSAxbikgLSAxbjsKICAgICAgbWF4SW50MjU2ID0gMm4gKiogKDI1Nm4gLSAxbikgLSAxbjsKICAgICAgbWluSW50OCA9IC0oMm4gKiogKDhuIC0gMW4pKTsKICAgICAgbWluSW50MTYgPSAtKDJuICoqICgxNm4gLSAxbikpOwogICAgICBtaW5JbnQyNCA9IC0oMm4gKiogKDI0biAtIDFuKSk7CiAgICAgIG1pbkludDMyID0gLSgybiAqKiAoMzJuIC0gMW4pKTsKICAgICAgbWluSW50NDAgPSAtKDJuICoqICg0MG4gLSAxbikpOwogICAgICBtaW5JbnQ0OCA9IC0oMm4gKiogKDQ4biAtIDFuKSk7CiAgICAgIG1pbkludDU2ID0gLSgybiAqKiAoNTZuIC0gMW4pKTsKICAgICAgbWluSW50NjQgPSAtKDJuICoqICg2NG4gLSAxbikpOwogICAgICBtaW5JbnQ3MiA9IC0oMm4gKiogKDcybiAtIDFuKSk7CiAgICAgIG1pbkludDgwID0gLSgybiAqKiAoODBuIC0gMW4pKTsKICAgICAgbWluSW50ODggPSAtKDJuICoqICg4OG4gLSAxbikpOwogICAgICBtaW5JbnQ5NiA9IC0oMm4gKiogKDk2biAtIDFuKSk7CiAgICAgIG1pbkludDEwNCA9IC0oMm4gKiogKDEwNG4gLSAxbikpOwogICAgICBtaW5JbnQxMTIgPSAtKDJuICoqICgxMTJuIC0gMW4pKTsKICAgICAgbWluSW50MTIwID0gLSgybiAqKiAoMTIwbiAtIDFuKSk7CiAgICAgIG1pbkludDEyOCA9IC0oMm4gKiogKDEyOG4gLSAxbikpOwogICAgICBtaW5JbnQxMzYgPSAtKDJuICoqICgxMzZuIC0gMW4pKTsKICAgICAgbWluSW50MTQ0ID0gLSgybiAqKiAoMTQ0biAtIDFuKSk7CiAgICAgIG1pbkludDE1MiA9IC0oMm4gKiogKDE1Mm4gLSAxbikpOwogICAgICBtaW5JbnQxNjAgPSAtKDJuICoqICgxNjBuIC0gMW4pKTsKICAgICAgbWluSW50MTY4ID0gLSgybiAqKiAoMTY4biAtIDFuKSk7CiAgICAgIG1pbkludDE3NiA9IC0oMm4gKiogKDE3Nm4gLSAxbikpOwogICAgICBtaW5JbnQxODQgPSAtKDJuICoqICgxODRuIC0gMW4pKTsKICAgICAgbWluSW50MTkyID0gLSgybiAqKiAoMTkybiAtIDFuKSk7CiAgICAgIG1pbkludDIwMCA9IC0oMm4gKiogKDIwMG4gLSAxbikpOwogICAgICBtaW5JbnQyMDggPSAtKDJuICoqICgyMDhuIC0gMW4pKTsKICAgICAgbWluSW50MjE2ID0gLSgybiAqKiAoMjE2biAtIDFuKSk7CiAgICAgIG1pbkludDIyNCA9IC0oMm4gKiogKDIyNG4gLSAxbikpOwogICAgICBtaW5JbnQyMzIgPSAtKDJuICoqICgyMzJuIC0gMW4pKTsKICAgICAgbWluSW50MjQwID0gLSgybiAqKiAoMjQwbiAtIDFuKSk7CiAgICAgIG1pbkludDI0OCA9IC0oMm4gKiogKDI0OG4gLSAxbikpOwogICAgICBtaW5JbnQyNTYgPSAtKDJuICoqICgyNTZuIC0gMW4pKTsKICAgICAgbWF4VWludDggPSAybiAqKiA4biAtIDFuOwogICAgICBtYXhVaW50MTYgPSAybiAqKiAxNm4gLSAxbjsKICAgICAgbWF4VWludDI0ID0gMm4gKiogMjRuIC0gMW47CiAgICAgIG1heFVpbnQzMiA9IDJuICoqIDMybiAtIDFuOwogICAgICBtYXhVaW50NDAgPSAybiAqKiA0MG4gLSAxbjsKICAgICAgbWF4VWludDQ4ID0gMm4gKiogNDhuIC0gMW47CiAgICAgIG1heFVpbnQ1NiA9IDJuICoqIDU2biAtIDFuOwogICAgICBtYXhVaW50NjQgPSAybiAqKiA2NG4gLSAxbjsKICAgICAgbWF4VWludDcyID0gMm4gKiogNzJuIC0gMW47CiAgICAgIG1heFVpbnQ4MCA9IDJuICoqIDgwbiAtIDFuOwogICAgICBtYXhVaW50ODggPSAybiAqKiA4OG4gLSAxbjsKICAgICAgbWF4VWludDk2ID0gMm4gKiogOTZuIC0gMW47CiAgICAgIG1heFVpbnQxMDQgPSAybiAqKiAxMDRuIC0gMW47CiAgICAgIG1heFVpbnQxMTIgPSAybiAqKiAxMTJuIC0gMW47CiAgICAgIG1heFVpbnQxMjAgPSAybiAqKiAxMjBuIC0gMW47CiAgICAgIG1heFVpbnQxMjggPSAybiAqKiAxMjhuIC0gMW47CiAgICAgIG1heFVpbnQxMzYgPSAybiAqKiAxMzZuIC0gMW47CiAgICAgIG1heFVpbnQxNDQgPSAybiAqKiAxNDRuIC0gMW47CiAgICAgIG1heFVpbnQxNTIgPSAybiAqKiAxNTJuIC0gMW47CiAgICAgIG1heFVpbnQxNjAgPSAybiAqKiAxNjBuIC0gMW47CiAgICAgIG1heFVpbnQxNjggPSAybiAqKiAxNjhuIC0gMW47CiAgICAgIG1heFVpbnQxNzYgPSAybiAqKiAxNzZuIC0gMW47CiAgICAgIG1heFVpbnQxODQgPSAybiAqKiAxODRuIC0gMW47CiAgICAgIG1heFVpbnQxOTIgPSAybiAqKiAxOTJuIC0gMW47CiAgICAgIG1heFVpbnQyMDAgPSAybiAqKiAyMDBuIC0gMW47CiAgICAgIG1heFVpbnQyMDggPSAybiAqKiAyMDhuIC0gMW47CiAgICAgIG1heFVpbnQyMTYgPSAybiAqKiAyMTZuIC0gMW47CiAgICAgIG1heFVpbnQyMjQgPSAybiAqKiAyMjRuIC0gMW47CiAgICAgIG1heFVpbnQyMzIgPSAybiAqKiAyMzJuIC0gMW47CiAgICAgIG1heFVpbnQyNDAgPSAybiAqKiAyNDBuIC0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ZXJBYmksIHVuaXZlcnNhbFNpZ25hdHVyZVZhbGlkYXRvckFiaSwgZXJjMjBBYmksIGVyYzIwQWJpX2J5dGVzMzIsIGVyYzcyMUFiaSwgZXJjNDYyNkFiaTsKICB2YXIgaW5pdF9hYmlzID0gX19lc20oewogICAgIm5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvYWJpcy5qcyIoKSB7CiAgICAgIG11bHRpY2FsbDNBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJ0YXJnZXQiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJhbGxvd0ZhaWx1cmUiLAogICAgICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJjYWxsRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJjYWxscyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiYWdncmVnYXRlMyIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdWNjZXNzIiwKICAgICAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIG5hbWU6ICJyZXR1cm5EYXRhIiwKICAgICAgICAgICAgICB0eXBlOiAidHVwbGVbXSIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0KICAgICAgXTsKICAgICAgdW5pdmVyc2FsUmVzb2x2ZXJFcnJvcnMgPSBbCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG5hbWU6ICJSZXNvbHZlck5vdEZvdW5kIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBuYW1lOiAiUmVzb2x2ZXJXaWxkY2FyZE5vdFN1cHBvcnRlZCIsCiAgICAgICAgICB0eXBlOiAiZXJyb3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyTm90Q29udHJhY3QiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmV0dXJuRGF0YSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIlJlc29sdmVyRXJyb3IiLAogICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb21wb25lbnRzOiBbCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgIG5hbWU6ICJzdGF0dXMiLAogICAgICAgICAgICAgICAgICB0eXBlOiAidWludDE2IgogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgbmFtZTogIm1lc3NhZ2UiLAogICAgICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgbmFtZTogImVycm9ycyIsCiAgICAgICAgICAgICAgdHlwZTogInR1cGxlW10iCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiSHR0cEVycm9yIiwKICAgICAgICAgIHR5cGU6ICJlcnJvciIKICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmVzb2x2ZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmVzb2x2ZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlcyIgfSwKICAgICAgICAgICAgeyBuYW1lOiAiZGF0YSIsIHR5cGU6ICJieXRlcyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJyZXNvbHZlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7IG5hbWU6ICJuYW1lIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJkYXRhIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJnYXRld2F5cyIsIHR5cGU6ICJzdHJpbmdbXSIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAiIiwgdHlwZTogImJ5dGVzIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJhZGRyZXNzIiwgdHlwZTogImFkZHJlc3MiIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFJlc29sdmVyUmV2ZXJzZUFiaSA9IFsKICAgICAgICAuLi51bml2ZXJzYWxSZXNvbHZlckVycm9ycywKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAicmV2ZXJzZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFt7IHR5cGU6ICJieXRlcyIsIG5hbWU6ICJyZXZlcnNlTmFtZSIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogInN0cmluZyIsIG5hbWU6ICJyZXNvbHZlZE5hbWUiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmVzb2x2ZWRBZGRyZXNzIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJldmVyc2VSZXNvbHZlciIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlciIgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgbmFtZTogInJldmVyc2UiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgdHlwZTogImJ5dGVzIiwgbmFtZTogInJldmVyc2VOYW1lIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJzdHJpbmdbXSIsIG5hbWU6ICJnYXRld2F5cyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgeyB0eXBlOiAic3RyaW5nIiwgbmFtZTogInJlc29sdmVkTmFtZSIgfSwKICAgICAgICAgICAgeyB0eXBlOiAiYWRkcmVzcyIsIG5hbWU6ICJyZXNvbHZlZEFkZHJlc3MiIH0sCiAgICAgICAgICAgIHsgdHlwZTogImFkZHJlc3MiLCBuYW1lOiAicmV2ZXJzZVJlc29sdmVyIiB9LAogICAgICAgICAgICB7IHR5cGU6ICJhZGRyZXNzIiwgbmFtZTogInJlc29sdmVyIiB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICB0ZXh0UmVzb2x2ZXJBYmkgPSBbCiAgICAgICAgewogICAgICAgICAgbmFtZTogInRleHQiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfSwKICAgICAgICAgICAgeyBuYW1lOiAia2V5IiwgdHlwZTogInN0cmluZyIgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgIH0KICAgICAgXTsKICAgICAgYWRkcmVzc1Jlc29sdmVyQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIG5hbWU6ICJhZGRyIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIm5hbWUiLCB0eXBlOiAiYnl0ZXMzMiIgfV0sCiAgICAgICAgICBvdXRwdXRzOiBbeyBuYW1lOiAiIiwgdHlwZTogImFkZHJlc3MiIH1dCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBuYW1lOiAiYWRkciIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgeyBuYW1lOiAibmFtZSIsIHR5cGU6ICJieXRlczMyIiB9LAogICAgICAgICAgICB7IG5hbWU6ICJjb2luVHlwZSIsIHR5cGU6ICJ1aW50MjU2IiB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogW3sgbmFtZTogIiIsIHR5cGU6ICJieXRlcyIgfV0KICAgICAgICB9CiAgICAgIF07CiAgICAgIHVuaXZlcnNhbFNpZ25hdHVyZVZhbGlkYXRvckFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiY29uc3RydWN0b3IiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfc2lnbmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJfaGFzaCIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzMzIiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiX3NpZ25hdHVyZSIsCiAgICAgICAgICAgICAgdHlwZTogImJ5dGVzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiaXNWYWxpZFNpZyIKICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzIwQWJpID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic3ltYm9sIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXIiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdOwogICAgICBlcmMyMEFiaV9ieXRlczMyID0gWwogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYWxsb3dhbmNlIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiYXBwcm92ZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJiYWxhbmNlT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhY2NvdW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImRlY2ltYWxzIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50OCIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJuYW1lIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgaW5wdXRzOiBbXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJieXRlczMyIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYnl0ZXMzMiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0b3RhbFN1cHBseSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2lwaWVudCIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAicmVjaXBpZW50IiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhbW91bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9CiAgICAgIF07CiAgICAgIGVyYzcyMUFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZXZlbnQiLAogICAgICAgICAgbmFtZTogIkFwcHJvdmFsIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgdHlwZTogImV2ZW50IiwKICAgICAgICAgIG5hbWU6ICJBcHByb3ZhbEZvckFsbCIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm9wZXJhdG9yIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhcHByb3ZlZCIsCiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJldmVudCIsCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRva2VuSWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImFwcHJvdmUiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAicGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAiZ2V0QXBwcm92ZWQiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogImlzQXBwcm92ZWRGb3JBbGwiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogImJvb2wiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAibmFtZSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogIm93bmVyT2YiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAic2FmZVRyYW5zZmVyRnJvbSIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJwYXlhYmxlIiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImZyb20iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNhZmVUcmFuc2ZlckZyb20iLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiaWQiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImRhdGEiLAogICAgICAgICAgICAgIHR5cGU6ICJieXRlcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInNldEFwcHJvdmFsRm9yQWxsIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3BlcmF0b3IiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFwcHJvdmVkIiwKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFtdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInN5bWJvbCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogW10sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAic3RyaW5nIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImluZGV4IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iLAogICAgICAgICAgbmFtZTogInRva2VuQnlJbmRleCIsCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJpbmRleCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG9rZW5JZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG9rZW5VUkkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b2tlbklkIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJzdHJpbmciCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidG90YWxTdXBwbHkiLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIsCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInBheWFibGUiLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJyZWNpcGllbnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInRva2VJZCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBvdXRwdXRzOiBbXQogICAgICAgIH0KICAgICAgXTsKICAgICAgZXJjNDYyNkFiaSA9IFsKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJzcGVuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiQXBwcm92YWwiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiRGVwb3NpdCIsCiAgICAgICAgICB0eXBlOiAiZXZlbnQiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBhbm9ueW1vdXM6IGZhbHNlLAogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBpbmRleGVkOiB0cnVlLAogICAgICAgICAgICAgIG5hbWU6ICJmcm9tIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInRvIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJ2YWx1ZSIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiVHJhbnNmZXIiLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgYW5vbnltb3VzOiBmYWxzZSwKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogdHJ1ZSwKICAgICAgICAgICAgICBuYW1lOiAic2VuZGVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IHRydWUsCiAgICAgICAgICAgICAgbmFtZTogIm93bmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIGluZGV4ZWQ6IGZhbHNlLAogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgaW5kZXhlZDogZmFsc2UsCiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiV2l0aGRyYXciLAogICAgICAgICAgdHlwZTogImV2ZW50IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNwZW5kZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImFsbG93YW5jZSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic3BlbmRlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJhcHByb3ZlIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogImFzc2V0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldFRva2VuQWRkcmVzcyIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFjY291bnQiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogImJhbGFuY2VPZiIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAic2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJjb252ZXJ0VG9Bc3NldHMiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAiY29udmVydFRvU2hhcmVzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJkZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJjYWxsZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heERlcG9zaXQiLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogIm1heEFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImNhbGxlciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAibWF4TWludCIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFJlZGVlbSIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAibWF4U2hhcmVzIiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogInZpZXciLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAib3duZXIiLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogIm1heFdpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJtYXhBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJtaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdEZXBvc2l0IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdNaW50IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgbmFtZTogInByZXZpZXdSZWRlZW0iLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJ2aWV3IiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgIGlucHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFzc2V0cyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicHJldmlld1dpdGhkcmF3IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJzaGFyZXMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAicmVkZWVtIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsQXNzZXRzIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0b3RhbE1hbmFnZWRBc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFtdLAogICAgICAgICAgbmFtZTogInRvdGFsU3VwcGx5IiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJ0byIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiYW1vdW50IiwKICAgICAgICAgICAgICB0eXBlOiAidWludDI1NiIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIG5hbWU6ICJ0cmFuc2ZlciIsCiAgICAgICAgICBvdXRwdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICB0eXBlOiAiYm9vbCIKICAgICAgICAgICAgfQogICAgICAgICAgXSwKICAgICAgICAgIHN0YXRlTXV0YWJpbGl0eTogIm5vbnBheWFibGUiLAogICAgICAgICAgdHlwZTogImZ1bmN0aW9uIgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgaW5wdXRzOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAiZnJvbSIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBuYW1lOiAidG8iLAogICAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogImFtb3VudCIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAidHJhbnNmZXJGcm9tIiwKICAgICAgICAgIG91dHB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIHR5cGU6ICJib29sIgogICAgICAgICAgICB9CiAgICAgICAgICBdLAogICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAibm9ucGF5YWJsZSIsCiAgICAgICAgICB0eXBlOiAiZnVuY3Rpb24iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJhc3NldHMiLAogICAgICAgICAgICAgIHR5cGU6ICJ1aW50MjU2IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInJlY2VpdmVyIiwKICAgICAgICAgICAgICB0eXBlOiAiYWRkcmVzcyIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgIG5hbWU6ICJvd25lciIsCiAgICAgICAgICAgICAgdHlwZTogImFkZHJlc3MiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBuYW1lOiAid2l0aGRyYXciLAogICAgICAgICAgb3V0cHV0czogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgbmFtZTogInNoYXJlcyIsCiAgICAgICAgICAgICAgdHlwZTogInVpbnQyNTYiCiAgICAgICAgICAgIH0KICAgICAgICAgIF0sCiAgICAgICAgICBzdGF0ZU11dGFiaWxpdHk6ICJub25wYXlhYmxlIiwKICAgICAgICAgIHR5cGU6ICJmdW5jdGlvbiIKICAgICAgICB9CiAgICAgIF07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvY29udHJhY3QuanMKICB2YXIgYWdncmVnYXRlM1NpZ25hdHVyZTsKICB2YXIgaW5pdF9jb250cmFjdDIgPSBfX2VzbSh7CiAgICAibm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NvbnN0YW50cy9jb250cmFjdC5qcyIoKSB7CiAgICAgIGFnZ3JlZ2F0ZTNTaWduYXR1cmUgPSAiMHg4MmFkNTZjYiI7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jb25zdGFudHMvY29udHJhY3RzLmpzCiAgdmFyIGRlcGxveWxlc3NDYWxsVmlhQnl0ZWNvZGVCeXRlY29kZSwgZGVwbG95bGVzc0Nh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luRG9lc05vdFN1cHBvcnRDb250cmFjdCA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBibG9ja051bWJlciwgY2hhaW4sIGNvbnRyYWN0IH0pIHsKICAgICAgICAgIHN1cGVyKGBDaGFpbiAiJHtjaGFpbi5uYW1lfSIgZG9lcyBub3Qgc3VwcG9ydCBjb250cmFjdCAiJHtjb250cmFjdC5uYW1lfSIuYCwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAiVGhpcyBjb3VsZCBiZSBkdWUgdG8gYW55IG9mIHRoZSBmb2xsb3dpbmc6IiwKICAgICAgICAgICAgICAuLi5ibG9ja051bWJlciAmJiBjb250cmFjdC5ibG9ja0NyZWF0ZWQgJiYgY29udHJhY3QuYmxvY2tDcmVhdGVkID4gYmxvY2tOdW1iZXIgPyBbCiAgICAgICAgICAgICAgICBgLSBUaGUgY29udHJhY3QgIiR7Y29udHJhY3QubmFtZX0iIHdhcyBub3QgZGVwbG95ZWQgdW50aWwgYmxvY2sgJHtjb250cmFjdC5ibG9ja0NyZWF0ZWR9IChjdXJyZW50IGJsb2NrICR7YmxvY2tOdW1iZXJ9KS5gCiAgICAgICAgICAgICAgXSA6IFsKICAgICAgICAgICAgICAgIGAtIFRoZSBjaGFpbiBkb2VzIG5vdCBoYXZlIHRoZSBjb250cmFjdCAiJHtjb250cmFjdC5uYW1lfSIgY29uZmlndXJlZC5gCiAgICAgICAgICAgICAgXQogICAgICAgICAgICBdLAogICAgICAgICAgICBuYW1lOiAiQ2hhaW5Eb2VzTm90U3VwcG9ydENvbnRyYWN0IgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgICBDaGFpbk1pc21hdGNoRXJyb3IgPSBjbGFzcyBleHRlbmRzIEJhc2VFcnJvcjIgewogICAgICAgIGNvbnN0cnVjdG9yKHsgY2hhaW4sIGN1cnJlbnRDaGFpbklkIH0pIHsKICAgIC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ZXJyb3Igb2NjdXJyZWQgd2hpbGUgZmV0Y2hpbmcgZm9yIGFuIG9mZmNoYWluIHJlc3VsdC4iLCB7CiAgICAgICAgICAgIGNhdXNlLAogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICAuLi5jYXVzZS5tZXRhTWVzc2FnZXMgfHwgW10sCiAgICAgICAgICAgICAgY2F1c2UubWV0YU1lc3NhZ2VzPy5sZW5ndGggPyAiIiA6IFtdLAogICAgICAgICAgICAgICJPZmZjaGFpbiBHYXRld2F5IENhbGw6IiwKICAgICAgICAgICAgICB1cmxzICYmIFsKICAgICAgICAgICAgICAgICIgIEdhdGV3YXkgVVJMKHMpOiIsCiAgICAgICAgICAgICAgICAuLi51cmxzLm1hcCgodXJsKSA9PiBgICAgICR7Z2V0VXJsKHVybCl9YCkKICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgIGAgIFNlbmRlcjogJHtzZW5kZXJ9YCwKICAgICAgICAgICAgICBgICBEYXRhOiAke2RhdGF9YCwKICAgICAgICAgICAgICBgICBDYWxsYmFjayBzZWxlY3RvcjogJHtjYWxsYmFja1NlbGVjdG9yfWAsCiAgICAgICAgICAgICAgYCAgRXh0cmEgZGF0YTogJHtleHRyYURhdGF9YAogICAgICAgICAgICBdLmZsYXQoKSwKICAgICAgICAgICAgbmFtZTogIk9mZmNoYWluTG9va3VwRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwUmVzcG9uc2VNYWxmb3JtZWRFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyByZXN1bHQsIHVybCB9KSB7CiAgICAgICAgICBzdXBlcigiT2ZmY2hhaW4gZ2F0ZXdheSByZXNwb25zZSBpcyBtYWxmb3JtZWQuIFJlc3BvbnNlIGRhdGEgbXVzdCBiZSBhIGhleCB2YWx1ZS4iLCB7CiAgICAgICAgICAgIG1ldGFNZXNzYWdlczogWwogICAgICAgICAgICAgIGBHYXRld2F5IFVSTDogJHtnZXRVcmwodXJsKX1gLAogICAgICAgICAgICAgIGBSZXNwb25zZTogJHtzdHJpbmdpZnkocmVzdWx0KX1gCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cFJlc3BvbnNlTWFsZm9ybWVkRXJyb3IiCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9mZmNoYWluTG9va3VwU2VuZGVyTWlzbWF0Y2hFcnJvciA9IGNsYXNzIGV4dGVuZHMgQmFzZUVycm9yMiB7CiAgICAgICAgY29uc3RydWN0b3IoeyBzZW5kZXIsIHRvIH0pIHsKICAgICAgICAgIHN1cGVyKCJSZXZlcnRlZCBzZW5kZXIgYWRkcmVzcyBkb2VzIG5vdCBtYXRjaCB0YXJnZXQgY29udHJhY3QgYWRkcmVzcyAoYHRvYCkuIiwgewogICAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgICBgQ29udHJhY3QgYWRkcmVzczogJHt0b31gLAogICAgICAgICAgICAgIGBPZmZjaGFpbkxvb2t1cCBzZW5kZXIgYWRkcmVzczogJHtzZW5kZXJ9YAogICAgICAgICAgICBdLAogICAgICAgICAgICBuYW1lOiAiT2ZmY2hhaW5Mb29rdXBTZW5kZXJNaXNtYXRjaEVycm9yIgogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2NpcC5qcwogIHZhciBjY2lwX2V4cG9ydHMgPSB7fTsKICBfX2V4cG9ydChjY2lwX2V4cG9ydHMsIHsKICAgIGNjaXBSZXF1ZXN0OiAoKSA9PiBjY2lwUmVxdWVzdCwKICAgIG9mZmNoYWluTG9va3VwOiAoKSA9Pi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ZGVyKS5yZXBsYWNlKCJ7ZGF0YX0iLCBkYXRhKSwgewogICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksCiAgICAgICAgICBoZWFkZXJzLAogICAgICAgICAgbWV0aG9kCiAgICAgICAgfSk7CiAgICAgICAgbGV0IHJlc3VsdDsKICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpIHsKICAgICAgICAgIHJlc3VsdCA9IChhd2FpdCByZXNwb25zZS5qc29uKCkpLmRhdGE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHJlc3VsdCA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICB9CiAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgZXJyb3IgPSBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgIGRldGFpbHM6IHJlc3VsdD8uZXJyb3IgPyBzdHJpbmdpZnkocmVzdWx0LmVycm9yKSA6IHJlc3BvbnNlLnN0YXR1c1RleHQsCiAgICAgICAgICAgIGhlYWRlcnM6IHJlc3BvbnNlLmhlYWRlcnMsCiAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICghaXNIZXgocmVzdWx0KSkgewogICAgICAgICAgZXJyb3IgPSBuZXcgT2ZmY2hhaW5Mb29rdXBSZXNwb25zZU1hbGZvcm1lZEVycm9yKHsKICAgICAgICAgICAgcmVzdWx0LAogICAgICAgICAgICB1cmwKICAgICAgICAgIH0pOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgIGVycm9yID0gbmV3IEh0dHBSZXF1ZXN0RXJyb3IoewogICAgICAgICAgYm9keSwKICAgICAgICAgIGRldGFpbHM6IGVyci5tZXNzYWdlLAogICAgICAgICAgdXJsCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIHRocm93IGVycm9yOwogIH0KICB2YXIgb2ZmY2hhaW5Mb29rdXBTaWduYXR1cmUsIG9mZmNoYWluTG9va3VwQWJpSXRlbTsKICB2YXIgaW5pdF9jY2lwMiA9IF9fZXNtKHsKICAgICJub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvY2NpcC5qcyIoKSB7CiAgICAgIGluaXRfY2FsbCgpOwogICAgICBpbml0X2NjaXAoKTsKICAgICAgaW5pdF9yZXF1ZXN0KCk7CiAgICAgIGluaXRfZGVjb2RlRXJyb3JSZXN1bHQoKTsKICAgICAgaW5pdF9lbmNvZGVBYmlQYXJhbWV0ZXJzKCk7CiAgICAgIGluaXRfaXNBZGRyZXNzRXF1YWwoKTsKICAgICAgaW5pdF9jb25jYXQoKTsKICAgICAgaW5pdF9pc0hleCgpOwogICAgICBpbml0X3N0cmluZ2lmeSgpOwogICAgICBvZmZjaGFpbkxvb2t1cFNpZ25hdHVyZSA9ICIweDU1NmYxODMwIjsKICAgICAgb2ZmY2hhaW5Mb29rdXBBYmlJdGVtID0gewogICAgICAgIG5hbWU6ICJPZmZjaGFpbkxvb2t1cCIsCiAgICAgICAgdHlwZTogImVycm9yIiwKICAgICAgICBpbnB1dHM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInNlbmRlciIsCiAgICAgICAgICAgIHR5cGU6ICJhZGRyZXNzIgogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInVybHMiLAogICAgICAgICAgICB0eXBlOiAic3RyaW5nW10iCiAgICAgICAgICB9LAogICAgICAgICAgewogICAgICAgICAgICBuYW1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aXplNCArIChkYXRhMi5sZW5ndGggLSAyKSwgMCk7CiAgICAgICAgcmV0dXJuIHNpemUzID4gYmF0Y2hTaXplICogMjsKICAgICAgfSwKICAgICAgZm46IGFzeW5jIChyZXF1ZXN0cykgPT4gewogICAgICAgIGNvbnN0IGNhbGxzID0gcmVxdWVzdHMubWFwKChyZXF1ZXN0KSA9PiAoewogICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgY2FsbERhdGE6IHJlcXVlc3QuZGF0YSwKICAgICAgICAgIHRhcmdldDogcmVxdWVzdC50bwogICAgICAgIH0pKTsKICAgICAgICBjb25zdCBjYWxsZGF0YSA9IGVuY29kZUZ1bmN0aW9uRGF0YSh7CiAgICAgICAgICBhYmk6IG11bHRpY2FsbDNBYmksCiAgICAgICAgICBhcmdzOiBbY2FsbHNdLAogICAgICAgICAgZnVuY3Rpb25OYW1lOiAiYWdncmVnYXRlMyIKICAgICAgICB9KTsKICAgICAgICBjb25zdCBkYXRhMiA9IGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgIG1ldGhvZDogImV0aF9jYWxsIiwKICAgICAgICAgIHBhcmFtczogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgZGF0YTogY2FsbGRhdGEsCiAgICAgICAgICAgICAgdG86IG11bHRpY2FsbEFkZHJlc3MKICAgICAgICAgICAgfSwKICAgICAgICAgICAgYmxvY2sKICAgICAgICAgIF0KICAgICAgICB9KTsKICAgICAgICByZXR1cm4gZGVjb2RlRnVuY3Rpb25SZXN1bHQoewogICAgICAgICAgYWJpOiBtdWx0aWNhbGwzQWJpLAogICAgICAgICAgYXJnczogW2NhbGxzXSwKICAgICAgICAgIGZ1bmN0aW9uTmFtZTogImFnZ3JlZ2F0ZTMiLAogICAgICAgICAgZGF0YTogZGF0YTIgfHwgIjB4IgogICAgICAgIH0pOwogICAgICB9CiAgICB9KTsKICAgIGNvbnN0IFt7IHJldHVybkRhdGEsIHN1Y2Nlc3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jMyLAogICAgbWF4SW50MjQ6ICgpID0+IG1heEludDI0LAogICAgbWF4SW50MjQwOiAoKSA9PiBtYXhJbnQyNDAsCiAgICBtYXhJbnQyNDg6ICgpID0+IG1heEludDI0OCwKICAgIG1heEludDI1NjogKCkgPT4gbWF4SW50MjU2LAogICAgbWF4SW50MzI6ICgpID0+IG1heEludDMyLAogICAgbWF4SW50NDA6ICgpID0+IG1heEludDQwLAogICAgbWF4SW50NDg6ICgpID0+IG1heEludDQ4LAogICAgbWF4SW50NTY6ICgpID0+IG1heEludDU2LAogICAgbWF4SW50NjQ6ICgpID0+IG1heEludDY0LAogICAgbWF4SW50NzI6ICgpID0+IG1heEludDcyLAogICAgbWF4SW50ODogKCkgPT4gbWF4SW50OCwKICAgIG1heEludDgwOiAoKSA9PiBtYXhJbnQ4MCwKICAgIG1heEludDg4OiAoKSA9PiBtYXhJbnQ4OCwKICAgIG1heEludDk2OiAoKSA9PiBtYXhJbnQ5NiwKICAgIG1heFVpbnQxMDQ6ICgpID0+IG1heFVpbnQxMDQsCiAgICBtYXhVaW50MTEyOiAoKSA9PiBtYXhVaW50MTEyLAogICAgbWF4VWludDEyMDogKCkgPT4gbWF4VWludDEyMCwKICAgIG1heFVpbnQxMjg6ICgpID0+IG1heFVpbnQxMjgsCiAgICBtYXhVaW50MTM2OiAoKSA9PiBtYXhVaW50MTM2LAogICAgbWF4VWludDE0NDogKCkgPT4gbWF4VWludDE0NCwKICAgIG1heFVpbnQxNTI6ICgpID0+IG1heFVpbnQxNTIsCiAgICBtYXhVaW50MTY6ICgpID0+IG1heFVpbnQxNiwKICAgIG1heFVpbnQxNjA6ICgpID0+IG1heFVpbnQxNjAsCiAgICBtYXhVaW50MTY4OiAoKSA9PiBtYXhVaW50MTY4LAogICAgbWF4VWludDE3NjogKCkgPT4gbWF4VWludDE3NiwKICAgIG1heFVpbnQxODQ6ICgpID0+IG1heFVpbnQxODQsCiAgICBtYXhVaW50MTkyOiAoKSA9PiBtYXhVaW50MTkyLAogICAgbWF4VWludDIwMDogKCkgPT4gbWF4VWludDIwMCwKICAgIG1heFVpbnQyMDg6ICgpID0+IG1heFVpbnQyMDgsCiAgICBtYXhVaW50MjE2OiAoKSA9PiBtYXhVaW50MjE2LAogICAgbWF4VWludDIyNDogKCkgPT4gbWF4VWludDIyNCwKICAgIG1heFVpbnQyMzI6ICgpID0+IG1heFVpbnQyMzIsCiAgICBtYXhVaW50MjQ6ICgpID0+IG1heFVpbnQyNCwKICAgIG1heFVpbnQyNDA6ICgpID0+IG1heFVpbnQyNDAsCiAgICBtYXhVaW50MjQ4OiAoKSA9PiBtYXhVaW50MjQ4LAogICAgbWF4VWludDI1NjogKCkgPT4gbWF4VWludDI1NiwKICAgIG1heFVpbnQzMjogKCkgPT4gbWF4VWludDMyLAogICAgbWF4VWludDQwOiAoKSA9PiBtYXhVaW50NDAsCiAgICBtYXhVaW50NDg6ICgpID0+IG1heFVpbnQ0OCwKICAgIG1heFVpbnQ1NjogKCkgPT4gbWF4VWludDU2LAogICAgbWF4VWludDY0OiAoKSA9PiBtYXhVaW50NjQsCiAgICBtYXhVaW50NzI6ICgpID0+IG1heFVpbnQ3MiwKICAgIG1heFVpbnQ4OiAoKSA9PiBtYXhVaW50OCwKICAgIG1heFVpbnQ4MDogKCkgPT4gbWF4VWludDgwLAogICAgbWF4VWludDg4OiAoKSA9PiBtYXhVaW50ODgsCiAgICBtYXhVaW50OTY6ICgpID0+IG1heFVpbnQ5NiwKICAgIG1pbkludDEwNDogKCkgPT4gbWluSW50MTA0LAogICAgbWluSW50MTEyOiAoKSA9PiBtaW5JbnQxMTIsCiAgICBtaW5JbnQxMjA6ICgpID0+IG1pbkludDEyMCwKICAgIG1pbkludDEyODogKCkgPT4gbWluSW50MTI4LAogICAgbWluSW50MTM2OiAoKSA9PiBtaW5JbnQxMzYsCiAgICBtaW5JbnQxNDQ6ICgpID0+IG1pbkludDE0NCwKICAgIG1pbkludDE1MjogKCkgPT4gbWluSW50MTUyLAogICAgbWluSW50MTY6ICgpID0+IG1pbkludDE2LAogICAgbWluSW50MTYwOiAoKSA9PiBtaW5JbnQxNjAsCiAgICBtaW5JbnQxNjg6ICgpID0+IG1pbkludDE2OCwKICAgIG1pbkludDE3NjogKCkgPT4gbWluSW50MTc2LAogICAgbWluSW50MTg0OiAoKSA9PiBtaW5JbnQxODQsCiAgICBtaW5JbnQxOTI6ICgpID0+IG1pbkludDE5MiwKICAgIG1pbkludDIwMDogKCkgPT4gbWluSW50MjAwLAogICAgbWluSW50MjA4OiAoKSA9PiBtaW5JbnQyMDgsCiAgICBtaW5JbnQyMTY6ICgpID0+IG1pbkludDIxNiwKICAgIG1pbkludDIyNDogKCkgPT4gbWluSW50MjI0LAogICAgbWluSW50MjMyOiAoKSA9PiBtaW5JbnQyMzIsCiAgICBtaW5JbnQyNDogKCkgPT4gbWluSW50MjQsCiAgICBtaW5JbnQyNDA6ICgpID0+IG1pbkludDI0MCwKICAgIG1pbkludDI0ODogKCkgPT4gbWluSW50MjQ4LAogICAgbWluSW50MjU2OiAoKSA9PiBtaW5JbnQyNTYsCiAgICBtaW5JbnQzMjogKCkgPT4gbWluSW50MzIsCiAgICBtaW5JbnQ0MDogKCkgPT4gbWluSW50NDAsCiAgICBtaW5JbnQ0ODogKCkgPT4gbWluSW50NDgsCiAgICBtaW5JbnQ1NjogKCkgPT4gbWluSW50NTYsCiAgICBtaW5JbnQ2NDogKCkgPT4gbWluSW50NjQsCiAgICBtaW5JbnQ3MjogKCkgPT4gbWluSW50NzIsCiAgICBtaW5JbnQ4OiAoKSA9PiBtaW5JbnQ4LAogICAgbWluSW50ODA6ICgpID0+IG1pbkludDgwLAogICAgbWluSW50ODg6ICgpID0+IG1pbkludDg4LAogICAgbWluSW50OTY6ICgpID0+IG1pbkludDk2LAogICAgbXVsdGljYWxsM0FiaTogKCkgPT4gbXVsdGljYWxsM0FiaSwKICAgIG5hbWVoYXNoOiAoKSA9PiBuYW1laGFzaCwKICAgIG5vbmNlTWFuYWdlcjog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cm4gY2hhaW5JZDsKICAgIH0KICAgIGlmICgocGFyYW1ldGVycy5pbmNsdWRlcygiYmxvYlZlcnNpb25lZEhhc2hlcyIpIHx8IHBhcmFtZXRlcnMuaW5jbHVkZXMoInNpZGVjYXJzIikpICYmIGJsb2JzICYmIGt6ZykgewogICAgICBjb25zdCBjb21taXRtZW50cyA9IGJsb2JzVG9Db21taXRtZW50cyh7IGJsb2JzLCBremcgfSk7CiAgICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJibG9iVmVyc2lvbmVkSGFzaGVzIikpIHsKICAgICAgICBjb25zdCB2ZXJzaW9uZWRIYXNoZXMgPSBjb21taXRtZW50c1RvVmVyc2lvbmVkSGFzaGVzKHsKICAgICAgICAgIGNvbW1pdG1lbnRzLAogICAgICAgICAgdG86ICJoZXgiCiAgICAgICAgfSk7CiAgICAgICAgcmVxdWVzdC5ibG9iVmVyc2lvbmVkSGFzaGVzID0gdmVyc2lvbmVkSGFzaGVzOwogICAgICB9CiAgICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJzaWRlY2FycyIpKSB7CiAgICAgICAgY29uc3QgcHJvb2ZzID0gYmxvYnNUb1Byb29mcyh7IGJsb2JzLCBjb21taXRtZW50cywga3pnIH0pOwogICAgICAgIGNvbnN0IHNpZGVjYXJzID0gdG9CbG9iU2lkZWNhcnMoewogICAgICAgICAgYmxvYnMsCiAgICAgICAgICBjb21taXRtZW50cywKICAgICAgICAgIHByb29mcywKICAgICAgICAgIHRvOiAiaGV4IgogICAgICAgIH0pOwogICAgICAgIHJlcXVlc3Quc2lkZWNhcnMgPSBzaWRlY2FyczsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImNoYWluSWQiKSkKICAgICAgcmVxdWVzdC5jaGFpbklkID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgIGlmIChwYXJhbWV0ZXJzLmluY2x1ZGVzKCJub25jZSIpICYmIHR5cGVvZiBub25jZSA9PT0gInVuZGVmaW5lZCIgJiYgYWNjb3VudCkgewogICAgICBpZiAobm9uY2VNYW5hZ2VyMikgewogICAgICAgIGNvbnN0IGNoYWluSWQyID0gYXdhaXQgZ2V0Q2hhaW5JZDIoKTsKICAgICAgICByZXF1ZXN0Lm5vbmNlID0gYXdhaXQgbm9uY2VNYW5hZ2VyMi5jb25zdW1lKHsKICAgICAgICAgIGFkZHJlc3M6IGFjY291bnQuYWRkcmVzcywKICAgICAgICAgIGNoYWluSWQ6IGNoYWluSWQyLAogICAgICAgICAgY2xpZW50CiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmVxdWVzdC5ub25jZSA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uQ291bnQsICJnZXRUcmFuc2FjdGlvbkNvdW50IikoewogICAgICAgICAgYWRkcmVzczogYWNjb3VudC5hZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBpZiAoKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSB8fCBwYXJhbWV0ZXJzLmluY2x1ZGVzKCJ0eXBlIikpICYmIHR5cGVvZiB0eXBlID09PSAidW5kZWZpbmVkIikgewogICAgICB0cnkgewogICAgICAgIHJlcXVlc3QudHlwZSA9IGdldFRyYW5zYWN0aW9uVHlwZShyZXF1ZXN0KTsKICAgICAgfSBjYXRjaCB7CiAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgcmVxdWVzdC50eXBlID0gdHlwZW9mIGJsb2NrMj8uYmFzZUZlZVBlckdhcyA9PT0gImJpZ2ludCIgPyAiZWlwMTU1OSIgOiAibGVnYWN5IjsKICAgICAgfQogICAgfQogICAgaWYgKHBhcmFtZXRlcnMuaW5jbHVkZXMoImZlZXMiKSkgewogICAgICBpZiAocmVxdWVzdC50eXBlICE9PSAibGVnYWN5IiAmJiByZXF1ZXN0LnR5cGUgIT09ICJlaXAyOTMwIikgewogICAgICAgIGlmICh0eXBlb2YgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiByZXF1ZXN0Lm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgY29uc3QgYmxvY2syID0gYXdhaXQgZ2V0QmxvY2syKCk7CiAgICAgICAgICBjb25zdCB7IG1heEZlZVBlckdhcywgbWF4UHJpb3JpdHlGZWVQZXJHYXMgfSA9IGF3YWl0IGludGVybmFsX2VzdGltYXRlRmVlc1BlckdhcyhjbGllbnQsIHsKICAgICAgICAgICAgYmxvY2s6IGJsb2NrMiwKICAgICAgICAgICAgY2hhaW4sCiAgICAgICAgICAgIHJlcXVlc3QKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzID09PSAidW5kZWZpbmVkIiAmJiBhcmdzLm1heEZlZVBlckdhcyAmJiBhcmdzLm1heEZlZVBlckdhcyA8IG1heFByaW9yaXR5RmVlUGVyR2FzKQogICAgICAgICAgICB0aHJvdyBuZXcgTWF4RmVlUGVyR2FzVG9vTG93RXJyb3IoewogICAgICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzCiAgICAgICAgICAgIH0pOwogICAgICAgICAgcmVxdWVzdC5tYXhQcmlvcml0eUZlZVBlckdhcyA9IG1heFByaW9yaXR5RmVlUGVyR2FzOwogICAgICAgICAgcmVxdWVzdC5tYXhGZWVQZXJHYXMgPSBtYXhGZWVQZXJHYXM7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICh0eXBlb2YgYXJncy5tYXhGZWVQZXJHYXMgIT09ICJ1bmRlZmluZWQiIHx8IHR5cGVvZiBhcmdzLm1heFByaW9yaXR5RmVlUGVyR2FzICE9PSAidW5kZWZ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zLAogICAgICAgIGRhdGEsCiAgICAgICAgZ2FzLAogICAgICAgIGdhc1ByaWNlLAogICAgICAgIG1heEZlZVBlckJsb2JHYXMsCiAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgIG5vbmNlLAogICAgICAgIHRvLAogICAgICAgIHZhbHVlCiAgICAgIH0pOwogICAgICBsZXQgZXN0aW1hdGUgPSBCaWdJbnQoYXdhaXQgZXN0aW1hdGVHYXNfcnBjKHsgYmxvY2ssIHJlcXVlc3QsIHJwY1N0YXRlT3ZlcnJpZGUgfSkpOwogICAgICBpZiAoYXV0aG9yaXphdGlvbkxpc3QpIHsKICAgICAgICBjb25zdCB2YWx1ZTIgPSBhd2FpdCBnZXRCYWxhbmNlKGNsaWVudCwgeyBhZGRyZXNzOiByZXF1ZXN0LmZyb20gfSk7CiAgICAgICAgY29uc3QgZXN0aW1hdGVzID0gYXdhaXQgUHJvbWlzZS5hbGwoYXV0aG9yaXphdGlvbkxpc3QubWFwKGFzeW5jIChhdXRob3JpemF0aW9uKSA9PiB7CiAgICAgICAgICBjb25zdCB7IGNvbnRyYWN0QWRkcmVzcyB9ID0gYXV0aG9yaXphdGlvbjsKICAgICAgICAgIGNvbnN0IGVzdGltYXRlMiA9IGF3YWl0IGVzdGltYXRlR2FzX3JwYyh7CiAgICAgICAgICAgIGJsb2NrLAogICAgICAgICAgICByZXF1ZXN0OiB7CiAgICAgICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3Q6IHZvaWQgMCwKICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgIGZyb206IGFjY291bnQ/LmFkZHJlc3MsCiAgICAgICAgICAgICAgdG86IGNvbnRyYWN0QWRkcmVzcywKICAgICAgICAgICAgICB2YWx1ZTogbnVtYmVyVG9IZXgodmFsdWUyKQogICAgICAgICAgICB9LAogICAgICAgICAgICBycGNTdGF0ZU92ZXJyaWRlCiAgICAgICAgICB9KS5jYXRj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hbWVkID8gW10gOiB7fTsKICAgIGNvbnN0IGluZGV4ZWRJbnB1dHMgPSBpbnB1dHMuZmlsdGVyKCh4KSA9PiAiaW5kZXhlZCIgaW4geCAmJiB4LmluZGV4ZWQpOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbmRleGVkSW5wdXRzLmxlbmd0aDsgaSsrKSB7CiAgICAgIGNvbnN0IHBhcmFtID0gaW5kZXhlZElucHV0c1tpXTsKICAgICAgY29uc3QgdG9waWMgPSBhcmdUb3BpY3NbaV07CiAgICAgIGlmICghdG9waWMpCiAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ1RvcGljc01pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBwYXJhbQogICAgICAgIH0pOwogICAgICBhcmdzW2lzVW5uYW1lZCA/IGkgOiBwYXJhbS5uYW1lIHx8IGldID0gZGVjb2RlVG9waWMoeyBwYXJhbSwgdmFsdWU6IHRvcGljIH0pOwogICAgfQogICAgY29uc3Qgbm9uSW5kZXhlZElucHV0cyA9IGlucHV0cy5maWx0ZXIoKHgpID0+ICEoImluZGV4ZWQiIGluIHggJiYgeC5pbmRleGVkKSk7CiAgICBpZiAobm9uSW5kZXhlZElucHV0cy5sZW5ndGggPiAwKSB7CiAgICAgIGlmIChkYXRhICYmIGRhdGEgIT09ICIweCIpIHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgZGVjb2RlZERhdGEgPSBkZWNvZGVBYmlQYXJhbWV0ZXJzKG5vbkluZGV4ZWRJbnB1dHMsIGRhdGEpOwogICAgICAgICAgaWYgKGRlY29kZWREYXRhKSB7CiAgICAgICAgICAgIGlmIChpc1VubmFtZWQpCiAgICAgICAgICAgICAgYXJncyA9IFsuLi5hcmdzLCAuLi5kZWNvZGVkRGF0YV07CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbm9uSW5kZXhlZElucHV0cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgYXJnc1tub25JbmRleGVkSW5wdXRzW2ldLm5hbWVdID0gZGVjb2RlZERhdGFbaV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICBpZiAoc3RyaWN0KSB7CiAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBBYmlEZWNvZGluZ0RhdGFTaXplVG9vU21hbGxFcnJvciB8fCBlcnIgaW5zdGFuY2VvZiBQb3NpdGlvbk91dE9mQm91bmRzRXJyb3IpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IERlY29kZUxvZ0RhdGFNaXNtYXRjaCh7CiAgICAgICAgICAgICAgICBhYmlJdGVtLAogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgIHBhcmFtczogbm9uSW5kZXhlZElucHV0cywKICAgICAgICAgICAgICAgIHNpemU6IHNpemUoZGF0YSkKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChzdHJpY3QpIHsKICAgICAgICB0aHJvdyBuZXcgRGVjb2RlTG9nRGF0YU1pc21hdGNoKHsKICAgICAgICAgIGFiaUl0ZW0sCiAgICAgICAgICBkYXRhOiAiMHgiLAogICAgICAgICAgcGFyYW1zOiBub25JbmRleGVkSW5wdXRzLAogICAgICAgICAgc2l6ZTogMAogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBldmVudE5hbWU6IG5hbWUsCiAgICAgIGFyZ3M6IE9iamVjdC52YWx1ZXMoYXJncykubGVuZ3RoID4gMCA/IGFyZ3MgOiB2b2lkIDAKICAgIH07CiAgfQogIGZ1bmN0aW9uIGRlY29kZVRvcGljKHsgcGFyYW0sIHZhbHVlIH0pIHsKICAgIGlmIChwYXJhbS50eXBlID09PSAic3RyaW5nIi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m4gbnVsbDsKICAgICAgICBjb25zdCBldmVudCA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgIC4uLmxvZywKICAgICAgICAgIGFiaTogW2FiaUl0ZW1dLAogICAgICAgICAgc3RyaWN0CiAgICAgICAgfSk7CiAgICAgICAgaWYgKGV2ZW50TmFtZSAmJiAhZXZlbnROYW1lLmluY2x1ZGVzKGV2ZW50LmV2ZW50TmFtZSkpCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICBpZiAoIWluY2x1ZGVzQXJncyh7CiAgICAgICAgICBhcmdzOiBldmVudC5hcmdzLAogICAgICAgICAgaW5wdXRzOiBhYmlJdGVtLmlucHV0cywKICAgICAgICAgIG1hdGNoQXJnczogYXJncwogICAgICAgIH0pKQogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgcmV0dXJuIHsgLi4uZXZlbnQsIC4uLmxvZyB9OwogICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICBsZXQgZXZlbnROYW1lMjsKICAgICAgICBsZXQgaXNVbm5hbWVkOwogICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBBYmlFdmVudFNpZ25hdHVyZU5vdEZvdW5kRXJyb3IpCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgRGVjb2RlTG9nRGF0YU1pc21hdGNoIHx8IGVyciBpbnN0YW5jZW9mIERlY29kZUxvZ1RvcGljc01pc21hdGNoKSB7CiAgICAgICAgICBpZiAoc3RyaWN0KQogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIGV2ZW50TmFtZTIgPSBlcnIuYWJpSXRlbS5uYW1lOwogICAgICAgICAgaXNVbm5hbWVkID0gZXJyLmFiaUl0ZW0uaW5wdXRzPy5zb21lKCh4KSA9PiAhKCJuYW1lIiBpbiB4ICYmIHgubmFtZSkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4geyAuLi5sb2csIGFyZ3M6IGlzVW5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2ZW50XSA6IHZvaWQgMCk7CiAgICBsZXQgdG9waWNzID0gW107CiAgICBpZiAoZXZlbnRzKSB7CiAgICAgIGNvbnN0IGVuY29kZWQgPSBldmVudHMuZmxhdE1hcCgoZXZlbnQyKSA9PiBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgICAgYWJpOiBbZXZlbnQyXSwKICAgICAgICBldmVudE5hbWU6IGV2ZW50Mi5uYW1lLAogICAgICAgIGFyZ3M6IGV2ZW50c18gPyB2b2lkIDAgOiBhcmdzCiAgICAgIH0pKTsKICAgICAgdG9waWNzID0gW2VuY29kZWRdOwogICAgICBpZiAoZXZlbnQpCiAgICAgICAgdG9waWNzID0gdG9waWNzWzBdOwogICAgfQogICAgbGV0IGxvZ3M7CiAgICBpZiAoYmxvY2tIYXNoKSB7CiAgICAgIGxvZ3MgPSBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgbWV0aG9kOiAiZXRoX2dldExvZ3MiLAogICAgICAgIHBhcmFtczogW3sgYWRkcmVzcywgdG9waWNzLCBibG9ja0hhc2ggfV0KICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBsb2dzID0gYXdhaXQgY2xpZW50LnJlcXVlc3QoewogICAgICAgIG1ldGhvZDogImV0aF9nZXRMb2dzIiwKICAgICAgICBwYXJhbXM6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgdG9waWNzLAogICAgICAgICAgICBmcm9tQmxvY2s6IHR5cGVvZiBmcm9tQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgoZnJvbUJsb2NrKSA6IGZyb21CbG9jaywKICAgICAgICAgICAgdG9CbG9jazogdHlwZW9mIHRvQmxvY2sgPT09ICJiaWdpbnQiID8gbnVtYmVyVG9IZXgodG9CbG9jaykgOiB0b0Jsb2NrCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9KTsKICAgIH0KICAgIGNvbnN0IGZvcm1hdHRlZExvZ3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wKICAgICAgICBzdHJpY3QsCiAgICAgICAgZnJvbUJsb2NrCiAgICAgIF0pOwogICAgICByZXR1cm4gb2JzZXJ2ZShvYnNlcnZlcklkLCB7IG9uTG9ncywgb25FcnJvciB9LCAoZW1pdCkgPT4gewogICAgICAgIGxldCBwcmV2aW91c0Jsb2NrTnVtYmVyOwogICAgICAgIGlmIChmcm9tQmxvY2sgIT09IHZvaWQgMCkKICAgICAgICAgIHByZXZpb3VzQmxvY2tOdW1iZXIgPSBmcm9tQmxvY2sgLSAxbjsKICAgICAgICBsZXQgZmlsdGVyOwogICAgICAgIGxldCBpbml0aWFsaXplZCA9IGZhbHNlOwogICAgICAgIGNvbnN0IHVud2F0Y2ggPSBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmICghaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBmaWx0ZXIgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyLCAiY3JlYXRlQ29udHJhY3RFdmVudEZpbHRlciIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciA8IGJsb2NrTnVtYmVyKSB7CiAgICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICAgIGZyb21CbG9jazogcHJldmlvdXNCbG9ja051bWJlciArIDFuLAogICAgICAgICAgICAgICAgICB0b0Jsb2NrOiBibG9ja051bWJlciwKICAgICAgICAgICAgICAgICAgc3RyaWN0CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUNvbnRyYWN0RXZlbnQgPSAoKSA9PiB7CiAgICAgIGNvbnN0IHN0cmljdCA9IHN0cmljdF8gPz8gZmFsc2U7CiAgICAgIGNvbnN0IG9ic2VydmVySWQgPSBzdHJpbmdpZnkoWwogICAgICAgICJ3YXRjaENvbnRyYWN0RXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50TmFtZSwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgc3RyaWN0CiAgICAgIF0pOwogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgOwogICAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQgPSAoKCkgPT4gewogICAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSBjbGllbnQudHJhbnNwb3J0LnRyYW5zcG9ydHMuZmluZCgodHJhbnNwb3J0MykgPT4gdHJhbnNwb3J0My5jb25maWcudHlwZSA9PT0gIndlYlNvY2tldCIpOwogICAgICAgICAgICAgICAgaWYgKCF0cmFuc3BvcnQyKQogICAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIHJldHVybiB0cmFuc3BvcnQyLnZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgY29uc3QgdG9waWNzID0gZXZlbnROYW1lID8gZW5jb2RlRXZlbnRUb3BpY3MoewogICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgYXJncwogICAgICAgICAgICB9KSA6IFtdOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJsb2dzIiwgeyBhZGRyZXNzLCB0b3BpY3MgfV0sCiAgICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBjb25zdCBsb2cgPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgIGNvbnN0IHsgZXZlbnROYW1lOiBldmVudE5hbWUyLCBhcmdzOiBhcmdzMiB9ID0gZGVjb2RlRXZlbnRMb2coewogICAgICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgICB0b3BpY3M6IGxvZy50b3BpY3MsCiAgICAgICAgICAgICAgICAgICAgc3RyaWN0OiBzdHJpY3RfCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBjb25zdCBmb3JtYXR0ZWQgPSBmb3JtYXRMb2cobG9nLCB7CiAgICAgICAgICAgICAgICAgICAgYXJnczogYXJnczIsCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgICAgbGV0IGV2ZW50TmFtZTI7CiAgICAgICAgICAgICAgICAgIGxldCBpc1VubmFtZWQ7CiAgICAgICAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dEYXRhTWlzbWF0Y2ggfHwgZXJyIGluc3RhbmNlb2YgRGVjb2RlTG9nVG9waWNzTWlzbWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBldmVudE5hbWUyID0gZXJyLmFiaUl0ZW0ubmFtZTsKICAgICAgICAgICAgICAgICAgICBpc1VubmFtZWQgPSBlcnIuYWJpSXRlbS5pbnB1dHM/LnNvbWUoKHgpID0+ICEoIm5hbWUiIGluIHggJiYgeC5uYW1lKSk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgewogICAgICAgICAgICAgICAgICAgIGFyZ3M6IGlzVW5uYW1lZCA/IFtdIDoge30sCiAgICAgICAgICAgICAgICAgICAgZXZlbnROYW1lOiBldmVudE5hbWUyCiAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICBlbWl0Lm9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgIHVuc3Vic2NyaWJlKCk7CiAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgb25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSkoKTsKICAgICAgICByZXR1cm4gKCkgPT4gdW5zdWJzY3JpYmUoKTsKICAgICAgfSk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsQ29udHJhY3RFdmVudCgpIDogc3Vic2NyaWJlQ29udHJhY3RFdmVudCgpOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvd2FsbGV0L3dyaXRlQ29udHJhY3QuanMKICBpbml0X3BhcnNlQWNjb3VudCgpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vZXJyb3JzL2FjY291bnQuanMKICBpbml0X2Jhc2UoKTsKICB2YX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ICAgICAgICBmcm9tOiBhY2NvdW50Py5hZGRyZXNzLAogICAgICAgICAgZ2FzLAogICAgICAgICAgZ2FzUHJpY2UsCiAgICAgICAgICBtYXhGZWVQZXJCbG9iR2FzLAogICAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBub25jZSwKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUKICAgICAgICB9KTsKICAgICAgICBjb25zdCBtZXRob2QgPSBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5nZXQoY2xpZW50LnVpZCkgPyAid2FsbGV0X3NlbmRUcmFuc2FjdGlvbiIgOiAiZXRoX3NlbmRUcmFuc2FjdGlvbiI7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHJldHVybiBhd2FpdCBjbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgcGFyYW1zOiBbcmVxdWVzdF0KICAgICAgICAgIH0sIHsgcmV0cnlDb3VudDogMCB9KTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgICAgICBpZiAoZXJyb3IubmFtZSA9PT0gIkludmFsaWRJbnB1dFJwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiSW52YWxpZFBhcmFtc1JwY0Vycm9yIiB8fCBlcnJvci5uYW1lID09PSAiTWV0aG9kTm90Rm91bmRScGNFcnJvciIgfHwgZXJyb3IubmFtZSA9PT0gIk1ldGhvZE5vdFN1cHBvcnRlZFJwY0Vycm9yIikKICAgICAgICAgICAgcmV0dXJuIGF3YWl0IGNsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBtZXRob2Q6ICJ3YWxsZXRfc2VuZFRyYW5zYWN0aW9uIiwKICAgICAgICAgICAgICBwYXJhbXM6IFtyZXF1ZXN0XQogICAgICAgICAgICB9LCB7IHJldHJ5Q291bnQ6IDAgfSkudGhlbigoaGFzaDMpID0+IHsKICAgICAgICAgICAgICBzdXBwb3J0c1dhbGxldE5hbWVzcGFjZS5zZXQoY2xpZW50LnVpZCwgdHJ1ZSk7CiAgICAgICAgICAgICAgcmV0dXJuIGhhc2gzOwogICAgICAgICAgICB9KTsKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gImxvY2FsIikgewogICAgICAgIGNvbnN0IHJlcXVlc3QgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBwcmVwYXJlVHJhbnNhY3Rpb25SZXF1ZXN0LCAicHJlcGFyZVRyYW5zYWN0aW9uUmVxdWVzdCIpKHsKICAgICAgICAgIGFjY291bnQsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgYXV0aG9yaXphdGlvbkxpc3QsCiAgICAgICAgICBibG9icywKICAgICAgICAgIGNoYWluLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGdhcywKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgbWF4RmVlUGVyQmxvYkdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBub25jZU1hbmFnZXI6IGFjY291bnQubm9uY2VNYW5hZ2VyLAogICAgICAgICAgcGFyYW1ldGVyczogWy4uLmRlZmF1bHRQYXJhbWV0ZXJzLCAic2lkZWNhcnMiXSwKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgLi4ucmVzdCwKICAgICAgICAgIHRvCiAgICAgICAgfSk7CiAgICAgICAgY29uc3Qgc2VyaWFsaXplciA9IGNoYWluPy5zZXJpYWxpemVycz8udHJhbnNhY3Rpb247CiAgICAgICAgY29uc3Qgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gYXdhaXQgYWNjb3VudC5zaWduVHJhbnNhY3Rpb24ocmVxdWVzdCwgewogICAgICAgICAgc2VyaWFsaXplcgogICAgICAgIH0pOwogICAgICAgIHJldHVybiBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBzZW5kUmF3VHJhbnNhY3Rpb24sICJzZW5kUmF3VHJhbnNhY3Rpb24iKSh7CiAgICAgICAgICBzZXJpYWxpemVkVHJhbnNhY3Rpb24KICAgICAgICB9KTsKICAgICAgfQogICAgICBpZiAoYWNjb3VudD8udHlwZSA9PT0gInNtYXJ0IikKICAgICAgICB0aHJvdyBuZXcgQWNjb3VudFR5cGVOb3RTdXBwb3J0ZWRFcnJvcih7CiAgICAgICAgICBtZXRhTWVzc2FnZXM6IFsKICAgICAgICAgICAgIkNvbnNpZGVyIHVzaW5nIHRoZSBgc2VuZFVzZXJPcGVyYXRpb25gIEFjdGlvbiBpbnN0ZWFkLiIKICAgICAgICAgIF0sCiAgICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2FjdGlvbnMvYnVuZGxlci9zZW5kVXNlck9wZXJhdGlvbiIsCiAgICAgICAgICB0eXBlOiAic21hcnQiCiAgICAgICAgfSk7CiAgICAgIHRocm93IG5ldyBBY2NvdW50VHlwZU5vdFN1cHBvcnRlZEVycm9yKHsKICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2FjdGlvbnMvd2FsbGV0L3NlbmRUcmFuc2FjdGlvbiIsCiAgICAgICAgdHlwZTogYWNjb3VudD8udHlwZQogICAgICB9KTsKICAgIH0gY2F0Y2ggKGVycikgewogICAgICBpZiAoZXJyIGluc3RhbmNlb2YgQWNjb3VudFR5cGVOb3RTdXBwb3J0ZWRFcnJvcikKICAgICAgICB0aHJvdyBlcnI7CiAgICAgIHRocm93IGdldFRyYW5zYWN0aW9uRXJyb3IoZXJyLCB7CiAgICAgICAgLi4ucGFyYW1ldGVycywKICAgICAgICBhY2NvdW50LAogICAgICAgIGNoYWluOiBwYXJhbWV0ZXJzLmNoYWluIHx8IHZvaWQgMAogICAgICB9KTsKICAgIH0KICB9CgogIC8vI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NsaWVudCwgcmVhZENvbnRyYWN0LCAicmVhZENvbnRyYWN0IikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGZ1bmN0aW9uTmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LnNpbXVsYXRlID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCBzaW11bGF0ZUNvbnRyYWN0LCAic2ltdWxhdGVDb250cmFjdCIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBmdW5jdGlvbk5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICBpZiAoaGFzRXZlbnQpIHsKICAgICAgICBjb250cmFjdC5jcmVhdGVFdmVudEZpbHRlciA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGV2ZW50TmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCBhYmlFdmVudCA9IGFiaTIuZmluZCgoeCkgPT4geC50eXBlID09PSAiZXZlbnQiICYmIHgubmFtZSA9PT0gZXZlbnROYW1lKTsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEV2ZW50UGFyYW1ldGVycyhwYXJhbWV0ZXJzLCBhYmlFdmVudCk7CiAgICAgICAgICAgICAgcmV0dXJuIGdldEFjdGlvbihwdWJsaWNDbGllbnQsIGNyZWF0ZUNvbnRyYWN0RXZlbnRGaWx0ZXIsICJjcmVhdGVDb250cmFjdEV2ZW50RmlsdGVyIikoewogICAgICAgICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgIGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgICAgICAuLi5vcHRpb25zCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgY29udHJhY3QuZ2V0RXZlbnRzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZXZlbnROYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IGFiaUV2ZW50ID0gYWJpMi5maW5kKCh4KSA9PiB4LnR5cGUgPT09ICJldmVudCIgJiYgeC5uYW1lID09PSBldmVudE5hbWUpOwogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RXZlbnRQYXJhbWV0ZXJzKHBhcmFtZXRlcnMsIGFiaUV2ZW50KTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHB1YmxpY0NsaWVudCwgZ2V0Q29udHJhY3RFdmVudHMsICJnZXRDb250cmFjdEV2ZW50cyIpKHsKICAgICAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgICAgICBldmVudE5hbWUsCiAgICAgICAgICAgICAgICBhcmdzLAogICAgICAgICAgICAgICAgLi4ub3B0aW9ucwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9OwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICAgIGNvbnRyYWN0LndhdGNoRXZlbnQgPSBuZXcgUHJveHkoe30sIHsKICAgICAgICAgIGdldChfLCBldmVudE5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuICguLi5wYXJhbWV0ZXJzKSA9PiB7CiAgICAgICAgICAgICAgY29uc3QgYWJpRXZlbnQgPSBhYmkyLmZpbmQoKHgpID0+IHgudHlwZSA9PT0gImV2ZW50IiAmJiB4Lm5hbWUgPT09IGV2ZW50TmFtZSk7CiAgICAgICAgICAgICAgY29uc3QgeyBhcmdzLCBvcHRpb25zIH0gPSBnZXRFdmVudFBhcmFtZXRlcnMocGFyYW1ldGVycywgYWJpRXZlbnQpOwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24ocHVibGljQ2xpZW50LCB3YXRjaENvbnRyYWN0RXZlbnQsICJ3YXRjaENvbnRyYWN0RXZlbnQiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZXZlbnROYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfQogICAgfQogICAgaWYgKGhhc1dhbGxldENsaWVudCkgewogICAgICBpZiAoaGFzV3JpdGVGdW5jdGlvbikKICAgICAgICBjb250cmFjdC53cml0ZSA9IG5ldyBQcm94eSh7fSwgewogICAgICAgICAgZ2V0KF8sIGZ1bmN0aW9uTmFtZSkgewogICAgICAgICAgICByZXR1cm4gKC4uLnBhcmFtZXRlcnMpID0+IHsKICAgICAgICAgICAgICBjb25zdCB7IGFyZ3MsIG9wdGlvbnMgfSA9IGdldEZ1bmN0aW9uUGFyYW1ldGVycyhwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICByZXR1cm4gZ2V0QWN0aW9uKHdhbGxldENsaWVudCwgd3JpdGVDb250cmFjdCwgIndyaXRlQ29udHJhY3QiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIC4uLm9wdGlvbnMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgIH0KICAgIGlmIChoYXNQdWJsaWNDbGllbnQgfHwgaGFzV2FsbGV0Q2xpZW50KSB7CiAgICAgIGlmIChoYXNXcml0ZUZ1bmN0aW9uKQogICAgICAgIGNvbnRyYWN0LmVzdGltYXRlR2FzID0gbmV3IFByb3h5KHt9LCB7CiAgICAgICAgICBnZXQoXywgZnVuY3Rpb25OYW1lKSB7CiAgICAgICAgICAgIHJldHVybiAoLi4ucGFyYW1ldGVycykgPT4gewogICAgICAgICAgICAgIGNvbnN0IHsgYXJncywgb3B0aW9ucyB9ID0gZ2V0RnVuY3Rpb25QYXJhbWV0ZXJzKHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgIGNvbnN0IGNsaWVudDIgPSBwdWJsaWNDbGllbnQgPz8gd2FsbGV0Q2xpZW50OwogICAgICAgICAgICAgIHJldHVybiBnZXRBY3Rpb24oY2xpZW50MiwgZXN0aW1hdGVDb250cmFjdEdhcywgImVzdGltYXRlQ29udHJhY3RHYXMiKSh7CiAgICAgICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgZnVuY3Rpb25OYW1lLAogICAgICAgICAgICAgICA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YW1ldGVycykgewogICAgY29uc3QgeyBhZGRyZXNzLCBmYWN0b3J5LCBmYWN0b3J5RGF0YSB9ID0gcGFyYW1ldGVyczsKICAgIHRyeSB7CiAgICAgIGNvbnN0IFtmaWVsZHMsIG5hbWUsIHZlcnNpb24zLCBjaGFpbklkLCB2ZXJpZnlpbmdDb250cmFjdCwgc2FsdCwgZXh0ZW5zaW9uc10gPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKSh7CiAgICAgICAgYWJpLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgZnVuY3Rpb25OYW1lOiAiZWlwNzEyRG9tYWluIiwKICAgICAgICBmYWN0b3J5LAogICAgICAgIGZhY3RvcnlEYXRhCiAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGRvbWFpbjogewogICAgICAgICAgbmFtZSwKICAgICAgICAgIHZlcnNpb246IHZlcnNpb24zLAogICAgICAgICAgY2hhaW5JZDogTnVtYmVyKGNoYWluSWQpLAogICAgICAgICAgdmVyaWZ5aW5nQ29udHJhY3QsCiAgICAgICAgICBzYWx0CiAgICAgICAgfSwKICAgICAgICBleHRlbnNpb25zLAogICAgICAgIGZpZWxkcwogICAgICB9OwogICAgfSBjYXRjaCAoZSkgewogICAgICBjb25zdCBlcnJvciA9IGU7CiAgICAgIGlmIChlcnJvci5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvbkV4ZWN1dGlvbkVycm9yIiAmJiBlcnJvci5jYXVzZS5uYW1lID09PSAiQ29udHJhY3RGdW5jdGlvblplcm9EYXRhRXJyb3IiKSB7CiAgICAgICAgdGhyb3cgbmV3IEVpcDcxMkRvbWFpbk5vdEZvdW5kRXJyb3IoeyBhZGRyZXNzIH0pOwogICAgICB9CiAgICAgIHRocm93IGVycm9yOwogICAgfQogIH0KICB2YXIgYWJpID0gWwogICAgewogICAgICBpbnB1dHM6IFtdLAogICAgICBuYW1lOiAiZWlwNzEyR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2UgSW52YWxpZFJlcXVlc3RScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBJbnZhbGlkUmVxdWVzdFJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjYwMQogICAgICAgICAgICBjYXNlIE1ldGhvZE5vdEZvdW5kUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90Rm91bmRScGNFcnJvcihlcnIsIHsgbWV0aG9kOiBhcmdzLm1ldGhvZCB9KTsKICAgICAgICAgICAgLy8gLTMyNjAyCiAgICAgICAgICAgIGNhc2UgSW52YWxpZFBhcmFtc1JwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRQYXJhbXNScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzI2MDMKICAgICAgICAgICAgY2FzZSBJbnRlcm5hbFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEludGVybmFsUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAwCiAgICAgICAgICAgIGNhc2UgSW52YWxpZElucHV0UnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZElucHV0UnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDAxCiAgICAgICAgICAgIGNhc2UgUmVzb3VyY2VOb3RGb3VuZFJwY0Vycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFJlc291cmNlTm90Rm91bmRScGNFcnJvcihlcnIpOwogICAgICAgICAgICAvLyAtMzIwMDIKICAgICAgICAgICAgY2FzZSBSZXNvdXJjZVVuYXZhaWxhYmxlUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgUmVzb3VyY2VVbmF2YWlsYWJsZVJwY0Vycm9yKGVycik7CiAgICAgICAgICAgIC8vIC0zMjAwMwogICAgICAgICAgICBjYXNlIFRyYW5zYWN0aW9uUmVqZWN0ZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBUcmFuc2FjdGlvblJlamVjdGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA0CiAgICAgICAgICAgIGNhc2UgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgTWV0aG9kTm90U3VwcG9ydGVkUnBjRXJyb3IoZXJyLCB7CiAgICAgICAgICAgICAgICBtZXRob2Q6IGFyZ3MubWV0aG9kCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIC8vIC0zMjAwNQogICAgICAgICAgICBjYXNlIExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBMaW1pdEV4Y2VlZGVkUnBjRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gLTMyMDA2CiAgICAgICAgICAgIGNhc2UgSnNvblJwY1ZlcnNpb25VbnN1cHBvcnRlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpzb25ScGNWZXJzaW9uVW5zdXBwb3J0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MDAxCiAgICAgICAgICAgIGNhc2UgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFVzZXJSZWplY3RlZFJlcXVlc3RFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0MTAwCiAgICAgICAgICAgIGNhc2UgVW5hdXRob3JpemVkUHJvdmlkZXJFcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBVbmF1dGhvcml6ZWRQcm92aWRlckVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQyMDAKICAgICAgICAgICAgY2FzZSBVbnN1cHBvcnRlZFByb3ZpZGVyTWV0aG9kRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRQcm92aWRlck1ldGhvZEVycm9yKGVycik7CiAgICAgICAgICAgIC8vIDQ5MDAKICAgICAgICAgICAgY2FzZSBQcm92aWRlckRpc2Nvbm5lY3RlZEVycm9yLmNvZGU6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFByb3ZpZGVyRGlzY29ubmVjdGVkRXJyb3IoZXJyKTsKICAgICAgICAgICAgLy8gNDkwMQogICAgICAgICAgICBjYXNlIENoYWluRGlzY29ubmVjdGVkRXJyb3IuY29kZToKICAgICAgICAgICAgICB0aHJvdyBuZXcgQ2hhaW5EaXNjb25uZWN0ZWRFcnJvcihlcnIpOwogICAgICAgICAgICAvLyA0OTAyCiAgICAgICAgICAgIGNhc2UgU3dpdGNoQ2hhaW5FcnJvci5jb2RlOgogICAgICAgICAgICAgIHRocm93IG5ldyBTd2l0Y2hDaGFpbkVycm9yKGVycik7CiAgICAgICAgICAgIC8vIENBSVAtMjU6IFVzZXIgUmVqZWN0ZWQgRXJyb3IKICAgICAgICAgICAgLy8gaHR0cHM6Ly9kb2NzLndhbGxldGNvbm5lY3QuY29tLzIuMC9zcGVjcy9jbGllbnRzL3NpZ24vZXJyb3ItY29kZXMjcmVqZWN0ZWQtY2FpcC0yNQogICAgICAgICAgICBjYXNlIDVlMzoKICAgICAgICAgICAgICB0aHJvdyBuZXcgVXNlclJlamVjdGVkUmVxdWVzdEVycm9yKGVycik7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGVycl8gaW5zdGFuY2VvZiBCYXNlRXJyb3IyKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyXzsKICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5rbm93blJwY0Vycm9yKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9LCB7CiAgICAgICAgZGVsYXk6ICh7IGNvdW50LCBlcnJvciB9KSA9PiB7CiAgICAgICAgICBpZiAoZXJyb3IgJiYgZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yKSB7CiAgICAgICAgICAgIGNvbnN0IHJldHJ5QWZ0ZXIgPSBlcnJvcj8uaGVhZGVycz8uZ2V0KCJSZXRyeS1BZnRlciIpOwogICAgICAgICAgICBpZiAocmV0cnlBZnRlcj8ubWF0Y2goL1xkLykpCiAgICAgICAgICAgICAgcmV0dXJuIE51bWJlci5wYXJzZUludChyZXRyeUFmdGVyKSAqIDFlMzsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB+figxIDw8IGNvdW50KSAqIHJldHJ5RGVsYXk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHNob3VsZFJldHJ5OiAoeyBlcnJvciB9KSA9PiBzaG91bGRSZXRyeShlcnJvcikKICAgICAgfSksIHsgZW5hYmxlZDogZGVkdXBlLCBpZDogcmVxdWVzdElkIH0pOwogICAgfTsKICB9CiAgZnVuY3Rpb24gc2hvdWxkUmV0cnkoZXJyb3IpIHsKICAgIGlmICgiY29kZSIgaW4gZXJyb3IgJiYgdHlwZW9mIGVycm9yLmNvZGUgPT09ICJudW1iZXIiKSB7CiAgICAgIGlmIChlcnJvci5jb2RlID09PSAtMSkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLmNvZGUgPT09IExpbWl0RXhjZWVkZWRScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3IuY29kZSA9PT0gSW50ZXJuYWxScGNFcnJvci5jb2RlKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAoZXJyb3IgaW5zdGFuY2VvZiBIdHRwUmVxdWVzdEVycm9yICYmIGVycm9yLnN0YXR1cykgewogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDQwOCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNDEzKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA0MjkpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwMCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgaWYgKGVycm9yLnN0YXR1cyA9PT0gNTAyKQogICAgICAgIHJldHVybiB0cnVlOwogICAgICBpZiAoZXJyb3Iuc3RhdHVzID09PSA1MDMpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIGlmIChlcnJvci5zdGF0dXMgPT09IDUwNCkKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgcmV0dXJuIHRydWU7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2xpZW50cy90cmFuc3BvcnRzL2NyZWF0ZVRyYW5zcG9ydC5qcwogIGZ1bmN0aW9uIGNyZWF0ZVRyYW5zcG9ydCh7IGtleSwgbmFtZSwgcmVxdWVzdCwgcmV0cnlDb3VudCA9IDMsIHJldHJ5RGVsYXkgPSAxNTAsIHRpbWVvdXQsIHR5cGUgfSwgdmFsdWUpIHsKICAgIGNvbnN0IHVpZDIgPSB1aWQoKTsKICAgIHJldHVybiB7CiAgICAgIGNvbmZpZzogewogICAgICAgIGtleSwKICAgICAgICBuYW1lLAogICAgICAgIHJlcXVlc3QsCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZQogICAgICB9LAogICAgICByZXF1ZXN0OiBidWlsZFJlcXVlc3QocmVxdWVzdCwgeyByZXRyeUNv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3QgfSkgPT4gewogICAgICBsZXQgdHJhbnNwb3J0cyA9IHRyYW5zcG9ydHNfOwogICAgICBsZXQgb25SZXNwb25zZSA9ICgpID0+IHsKICAgICAgfTsKICAgICAgY29uc3QgdHJhbnNwb3J0ID0gY3JlYXRlVHJhbnNwb3J0KHsKICAgICAgICBrZXksCiAgICAgICAgbmFtZSwKICAgICAgICBhc3luYyByZXF1ZXN0KHsgbWV0aG9kLCBwYXJhbXMgfSkgewogICAgICAgICAgY29uc3QgZmV0Y2gyID0gYXN5bmMgKGkgPSAwKSA9PiB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydDIgPSB0cmFuc3BvcnRzW2ldKHsKICAgICAgICAgICAgICAuLi5yZXN0LAogICAgICAgICAgICAgIGNoYWluLAogICAgICAgICAgICAgIHJldHJ5Q291bnQ6IDAsCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IHRyYW5zcG9ydDIucmVxdWVzdCh7CiAgICAgICAgICAgICAgICBtZXRob2QsCiAgICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBvblJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHJlc3BvbnNlLAogICAgICAgICAgICAgICAgdHJhbnNwb3J0OiB0cmFuc3BvcnQyLAogICAgICAgICAgICAgICAgc3RhdHVzOiAic3VjY2VzcyIKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIG9uUmVzcG9uc2UoewogICAgICAgICAgICAgICAgZXJyb3I6IGVyciwKICAgICAgICAgICAgICAgIG1ldGhvZCwKICAgICAgICAgICAgICAgIHBhcmFtcywKICAgICAgICAgICAgICAgIHRyYW5zcG9ydDogdHJhbnNwb3J0MiwKICAgICAgICAgICAgICAgIHN0YXR1czogImVycm9yIgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChzaG91bGRUaHJvdyhlcnIpKQogICAgICAgICAgICAgICAgdGhyb3cgZXJyOwogICAgICAgICAgICAgIGlmIChpID09PSB0cmFuc3BvcnRzLmxlbmd0aCAtIDEpCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgcmV0dXJuIGZldGNoMihpICsgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH07CiAgICAgICAgICByZXR1cm4gZmV0Y2gyKCk7CiAgICAgICAgfSwKICAgICAgICByZXRyeUNvdW50LAogICAgICAgIHJldHJ5RGVsYXksCiAgICAgICAgdHlwZTogImZhbGxiYWNrIgogICAgICB9LCB7CiAgICAgICAgb25SZXNwb25zZTogKGZuKSA9PiBvblJlc3BvbnNlID0gZm4sCiAgICAgICAgdHJhbnNwb3J0czogdHJhbnNwb3J0cy5tYXAoKGZuKSA9PiBmbih7IGNoYWluLCByZXRyeUNvdW50OiAwIH0pKQogICAgICB9KTsKICAgICAgaWYgKHJhbmspIHsKICAgICAgICBjb25zdCByYW5rT3B0aW9ucyA9IHR5cGVvZiByYW5rID09PSAib2JqZWN0IiA/IHJhbmsgOiB7fTsKICAgICAgICByYW5rVHJhbnNwb3J0cyh7CiAgICAgICAgICBjaGFpbiwKICAgICAgICAgIGludGVydmFsOiByYW5rT3B0aW9ucy5pbnRlcnZhbCA/PyBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgICBvblRyYW5zcG9ydHM6ICh0cmFuc3BvcnRzXzIpID0+IHRyYW5zcG9ydHMgPSB0cmFuc3BvcnRzXzIsCiAgICAgICAgICBzYW1wbGVDb3VudDogcmFua09wdGlvbnMuc2FtcGxlQ291bnQsCiAgICAgICAgICB0aW1lb3V0OiByYW5rT3B0aW9ucy50aW1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V0KCgpID0+IHsKICAgICAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgICAgICBjb250cm9sbGVyLmFib3J0KCk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJlamVjdChlcnJvckluc3RhbmNlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sIHRpbWVvdXQpOwogICAgICAgICAgfQogICAgICAgICAgcmVzb2x2ZShhd2FpdCBmbih7IHNpZ25hbDogY29udHJvbGxlcj8uc2lnbmFsIHx8IG51bGwgfSkpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVycj8ubmFtZSA9PT0gIkFib3J0RXJyb3IiKQogICAgICAgICAgICByZWplY3QoZXJyb3JJbnN0YW5jZSk7CiAgICAgICAgICByZWplY3QoZXJyKTsKICAgICAgICB9IGZpbmFsbHkgewogICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXRJZCk7CiAgICAgICAgfQogICAgICB9KSgpOwogICAgfSk7CiAgfQoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvcnBjL2h0dHAuanMKICBpbml0X3N0cmluZ2lmeSgpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvcnBjL2lkLmpzCiAgZnVuY3Rpb24gY3JlYXRlSWRTdG9yZSgpIHsKICAgIHJldHVybiB7CiAgICAgIGN1cnJlbnQ6IDAsCiAgICAgIHRha2UoKSB7CiAgICAgICAgcmV0dXJuIHRoaXMuY3VycmVudCsrOwogICAgICB9LAogICAgICByZXNldCgpIHsKICAgICAgICB0aGlzLmN1cnJlbnQgPSAwOwogICAgICB9CiAgICB9OwogIH0KICB2YXIgaWRDYWNoZSA9IC8qIEBfX1BVUkVfXyAqLyBjcmVhdGVJZFN0b3JlKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9ycGMvaHR0cC5qcwogIGZ1bmN0aW9uIGdldEh0dHBScGNDbGllbnQodXJsLCBvcHRpb25zID0ge30pIHsKICAgIHJldHVybiB7CiAgICAgIGFzeW5jIHJlcXVlc3QocGFyYW1zKSB7CiAgICAgICAgY29uc3QgeyBib2R5LCBvblJlcXVlc3QgPSBvcHRpb25zLm9uUmVxdWVzdCwgb25SZXNwb25zZSA9IG9wdGlvbnMub25SZXNwb25zZSwgdGltZW91dCA9IG9wdGlvbnMudGltZW91dCA/PyAxZTQgfSA9IHBhcmFtczsKICAgICAgICBjb25zdCBmZXRjaE9wdGlvbnMgPSB7CiAgICAgICAgICAuLi5vcHRpb25zLmZldGNoT3B0aW9ucyA/PyB7fSwKICAgICAgICAgIC4uLnBhcmFtcy5mZXRjaE9wdGlvbnMgPz8ge30KICAgICAgICB9OwogICAgICAgIGNvbnN0IHsgaGVhZGVycywgbWV0aG9kLCBzaWduYWw6IHNpZ25hbF8gfSA9IGZldGNoT3B0aW9uczsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB3aXRoVGltZW91dChhc3luYyAoeyBzaWduYWwgfSkgPT4gewogICAgICAgICAgICBjb25zdCBpbml0ID0gewogICAgICAgICAgICAgIC4uLmZldGNoT3B0aW9ucywKICAgICAgICAgICAgICBib2R5OiBBcnJheS5pc0FycmF5KGJvZHkpID8gc3RyaW5naWZ5KGJvZHkubWFwKChib2R5MikgPT4gKHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkyLmlkID8/IGlkQ2FjaGUudGFrZSgpLAogICAgICAgICAgICAgICAgLi4uYm9keTIKICAgICAgICAgICAgICB9KSkpIDogc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgIGpzb25ycGM6ICIyLjAiLAogICAgICAgICAgICAgICAgaWQ6IGJvZHkuaWQgPz8gaWRDYWNoZS50YWtlKCksCiAgICAgICAgICAgICAgICAuLi5ib2R5CiAgICAgICAgICAgICAgfSksCiAgICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICAgIkNvbnRlbnQtVHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgICAgIC4uLmhlYWRlcnMKICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgIG1ldGhvZDogbWV0aG9kIHx8ICJQT1NUIiwKICAgICAgICAgICAgICBzaWduYWw6IHNpZ25hbF8gfHwgKHRpbWVvdXQgPiAwID8gc2lnbmFsIDogbnVsbCkKICAgICAgICAgICAgfTsKICAgICAgICAgICAgY29uc3QgcmVxdWVzdCA9IG5ldyBSZXF1ZXN0KHVybCwgaW5pdCk7CiAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhd2FpdCBvblJlcXVlc3Q/LihyZXF1ZXN0LCBpbml0KSA/PyB7IC4uLmluaXQsIHVybCB9OwogICAgICAgICAgICBjb25zdCByZXNwb25zZTIgPSBhd2FpdCBmZXRjaChhcmdzLnVybCA/PyB1cmwsIGFyZ3MpOwogICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UyOwogICAgICAgICAgfSwgewogICAgICAgICAgICBlcnJvckluc3RhbmNlOiBuZXcgVGltZW91dEVycm9yKHsgYm9keSwgdXJsIH0pLAogICAgICAgICAgICB0aW1lb3V0LAogICAgICAgICAgICBzaWduYWw6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgaWYgKG9uUmVzcG9uc2UpCiAgICAgICAgICAgIGF3YWl0IG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICBpZiAocmVzcG9uc2UuaGVhZGVycy5nZXQoIkNvbnRlbnQtVHlwZSIpPy5zdGFydHNXaXRoKCJhcHBsaWNhdGlvbi9qc29uIikpCiAgICAgICAgICAgIGRhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCk7CiAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgZGF0YSA9IGF3YWl0IHJlc3BvbnNlLnRleHQoKTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBkYXRhID0gSlNPTi5wYXJzZShkYXRhIHx8ICJ7fSIpOwogICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uub2spCiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7CiAgICAgICAgICAgICAgZGF0YSA9IHsgZXJyb3I6IGRhdGEgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICB0aHJvdyBuZXcgSHR0cFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBkZXRhaWxzOiBzdHJpbmdpZnkoZGF0YS5lcnJvcikgfHwgcmVzcG9uc2Uuc3RhdHVzVGV4dCwKICAgICAgICAgICAgICBoZWFkZXJzOiByZXNwb25zZS5oZWFkZXJzLAogICAgICAgICAgICAgIHN0YXR1czogcmVzcG9uc2Uuc3RhdHVzLAogICAgICAgICAgICAgIHVybAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBkYXRhOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIEh0dHBSZXF1ZXN0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBUaW1lb3V0RXJyb3IpCiAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgIHRocm93IG5ldyBIdHRwUmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgY2F1c2U6IGVyciwKICAgICAgICA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nNlLAogICAgICAgIHRpbWVvdXQKICAgICAgfSk7CiAgICAgIHJldHVybiBjcmVhdGVUcmFuc3BvcnQoewogICAgICAgIGtleSwKICAgICAgICBuYW1lLAogICAgICAgIGFzeW5jIHJlcXVlc3QoeyBtZXRob2QsIHBhcmFtcyB9KSB7CiAgICAgICAgICBjb25zdCBib2R5ID0geyBtZXRob2QsIHBhcmFtcyB9OwogICAgICAgICAgY29uc3QgeyBzY2hlZHVsZSB9ID0gY3JlYXRlQmF0Y2hTY2hlZHVsZXIoewogICAgICAgICAgICBpZDogdXJsXywKICAgICAgICAgICAgd2FpdDogd2FpdDIsCiAgICAgICAgICAgIHNob3VsZFNwbGl0QmF0Y2gocmVxdWVzdHMpIHsKICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdHMubGVuZ3RoID4gYmF0Y2hTaXplOwogICAgICAgICAgICB9LAogICAgICAgICAgICBmbjogKGJvZHkyKSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgICAgYm9keTogYm9keTIKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNvcnQ6IChhLCBiKSA9PiBhLmlkIC0gYi5pZAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCBmbiA9IGFzeW5jIChib2R5MikgPT4gYmF0Y2ggPyBzY2hlZHVsZShib2R5MikgOiBbCiAgICAgICAgICAgIGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0KHsKICAgICAgICAgICAgICBib2R5OiBib2R5MgogICAgICAgICAgICB9KQogICAgICAgICAgXTsKICAgICAgICAgIGNvbnN0IFt7IGVycm9yLCByZXN1bHQgfV0gPSBhd2FpdCBmbihib2R5KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAg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FjZS50b0xvd2VyQ2FzZSgpLAogICAgICBjb250cmFjdEFkZHJlc3MsCiAgICAgIHRva2VuSUQKICAgIH07CiAgfQogIGFzeW5jIGZ1bmN0aW9uIGdldE5mdFRva2VuVXJpKGNsaWVudCwgeyBuZnQgfSkgewogICAgaWYgKG5mdC5uYW1lc3BhY2UgPT09ICJlcmM3MjEiKSB7CiAgICAgIHJldHVybiByZWFkQ29udHJhY3QoY2xpZW50LCB7CiAgICAgICAgYWRkcmVzczogbmZ0LmNvbnRyYWN0QWRkcmVzcywKICAgICAgICBhYmk6IFsKICAgICAgICAgIHsKICAgICAgICAgICAgbmFtZTogInRva2VuVVJJIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogInRva2VuSWQiLCB0eXBlOiAidWludDI1NiIgfV0sCiAgICAgICAgICAgIG91dHB1dHM6IFt7IG5hbWU6ICIiLCB0eXBlOiAic3RyaW5nIiB9XQogICAgICAgICAgfQogICAgICAgIF0sCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidG9rZW5VUkkiLAogICAgICAgIGFyZ3M6IFtCaWdJbnQobmZ0LnRva2VuSUQpXQogICAgICB9KTsKICAgIH0KICAgIGlmIChuZnQubmFtZXNwYWNlID09PSAiZXJjMTE1NSIpIHsKICAgICAgcmV0dXJuIHJlYWRDb250cmFjdChjbGllbnQsIHsKICAgICAgICBhZGRyZXNzOiBuZnQuY29udHJhY3RBZGRyZXNzLAogICAgICAgIGFiaTogWwogICAgICAgICAgewogICAgICAgICAgICBuYW1lOiAidXJpIiwKICAgICAgICAgICAgdHlwZTogImZ1bmN0aW9uIiwKICAgICAgICAgICAgc3RhdGVNdXRhYmlsaXR5OiAidmlldyIsCiAgICAgICAgICAgIGlucHV0czogW3sgbmFtZTogIl9pZCIsIHR5cGU6ICJ1aW50MjU2IiB9XSwKICAgICAgIC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XNzLAogICAgICAgIGFiaTogdW5pdmVyc2FsUmVzb2x2ZXJSZXNvbHZlQWJpLAogICAgICAgIGZ1bmN0aW9uTmFtZTogInJlc29sdmUiLAogICAgICAgIGFyZ3M6IFsKICAgICAgICAgIHRvSGV4KHBhY2tldFRvQnl0ZXMobmFtZSkpLAogICAgICAgICAgZW5jb2RlRnVuY3Rpb25EYXRhKHsKICAgICAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgICAgIGZ1bmN0aW9uTmFtZTogInRleHQiLAogICAgICAgICAgICBhcmdzOiBbbmFtZWhhc2gobmFtZSksIGtleV0KICAgICAgICAgIH0pCiAgICAgICAgXSwKICAgICAgICBibG9ja051bWJlciwKICAgICAgICBibG9ja1RhZwogICAgICB9OwogICAgICBjb25zdCByZWFkQ29udHJhY3RBY3Rpb24gPSBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKTsKICAgICAgY29uc3QgcmVzID0gZ2F0ZXdheVVybHMgPyBhd2FpdCByZWFkQ29udHJhY3RBY3Rpb24oewogICAgICAgIC4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMsCiAgICAgICAgYXJnczogWy4uLnJlYWRDb250cmFjdFBhcmFtZXRlcnMuYXJncywgZ2F0ZXdheVVybHNdCiAgICAgIH0pIDogYXdhaXQgcmVhZENvbnRyYWN0QWN0aW9uKHJlYWRDb250cmFjdFBhcmFtZXRlcnMpOwogICAgICBpZiAocmVzWzBdID09PSAiMHgiKQogICAgICAgIHJldHVybiBudWxsOwogICAgICBjb25zdCByZWNvcmQgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgYWJpOiB0ZXh0UmVzb2x2ZXJBYmksCiAgICAgICAgZnVuY3Rpb25OYW1lOiAidGV4dCIsCiAgICAgICAgZGF0YTogcmVzWzBdCiAgICAgIH0pOwogICAgICByZXR1cm4gcmVjb3JkID09PSAiIiA/IG51bGwgOiBy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0IHNvY2tldDsKICAgICAgICBsZXQga2VlcEFsaXZlVGltZXI7CiAgICAgICAgYXN5bmMgZnVuY3Rpb24gc2V0dXAoKSB7CiAgICAgICAgICBjb25zdCByZXN1bHQgPSBhd2FpdCBnZXRTb2NrZXQyKHsKICAgICAgICAgICAgb25DbG9zZSgpIHsKICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3Qgb2YgcmVxdWVzdHMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICByZXF1ZXN0Lm9uRXJyb3I/LihuZXcgU29ja2V0Q2xvc2VkRXJyb3IoeyB1cmwgfSkpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybCB9KSk7CiAgICAgICAgICAgICAgcmVxdWVzdHMuY2xlYXIoKTsKICAgICAgICAgICAgICBzdWJzY3JpcHRpb25zLmNsZWFyKCk7CiAgICAgICAgICAgICAgaWYgKHJlY29ubmVjdCAmJiByZWNvbm5lY3RDb3VudCA8IGF0dGVtcHRzKQogICAgICAgICAgICAgICAgc2V0VGltZW91dChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgIHJlY29ubmVjdENvdW50Kys7CiAgICAgICAgICAgICAgICAgIGF3YWl0IHNldHVwKCkuY2F0Y2goY29uc29sZS5lcnJvcik7CiAgICAgICAgICAgICAgICB9LCBkZWxheSk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uRXJyb3IoZXJyb3JfKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSBlcnJvcl87CiAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0IG9mIHJlcXVlc3RzLnZhbHVlcygpKQogICAgICAgICAgICAgICAgcmVxdWVzdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIGZvciAoY29uc3Qgc3Vic2NyaXB0aW9uIG9mIHN1YnNjcmlwdGlvbnMudmFsdWVzKCkpCiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24ub25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXF1ZXN0cy5jbGVhcigpOwogICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuY2xlYXIoKTsKICAgICAgICAgICAgICBpZiAocmVjb25uZWN0ICYmIHJlY29ubmVjdENvdW50IDwgYXR0ZW1wdHMpCiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGFzeW5jICgpID0+IHsKICAgICAgICAgICAgICAgICAgcmVjb25uZWN0Q291bnQrKzsKICAgICAgICAgICAgICAgICAgYXdhaXQgc2V0dXAoKS5jYXRjaChjb25zb2xlLmVycm9yKTsKICAgICAgICAgICAgICAgIH0sIGRlbGF5KTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25PcGVuKCkgewogICAgICAgICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgICAgICAgIHJlY29ubmVjdENvdW50ID0gMDsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25SZXNwb25zZShkYXRhKSB7CiAgICAgICAgICAgICAgY29uc3QgaXNTdWJzY3JpcHRpb24gPSBkYXRhLm1ldGhvZCA9PT0gImV0aF9zdWJzY3JpcHRpb24iOwogICAgICAgICAgICAgIGNvbnN0IGlkID0gaXNTdWJzY3JpcHRpb24gPyBkYXRhLnBhcmFtcy5zdWJzY3JpcHRpb24gOiBkYXRhLmlkOwogICAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gaXNTdWJzY3JpcHRpb24gPyBzdWJzY3JpcHRpb25zIDogcmVxdWVzdHM7CiAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2sgPSBjYWNoZS5nZXQoaWQpOwogICAgICAgICAgICAgIGlmIChjYWxsYmFjaykKICAgICAgICAgICAgICAgIGNhbGxiYWNrLm9uUmVzcG9uc2UoZGF0YSk7CiAgICAgICAgICAgICAgaWYgKCFpc1N1YnNjcmlwdGlvbikKICAgICAgICAgICAgICAgIGNhY2hlLmRlbGV0ZShpZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgc29ja2V0ID0gcmVzdWx0OwogICAgICAgICAgaWYgKGtlZXBBbGl2ZSkgewogICAgICAgICAgICBpZiAoa2VlcEFsaXZlVGltZXIpCiAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChrZWVwQWxpdmVUaW1lcik7CiAgICAgICAgICAgIGtlZXBBbGl2ZVRpbWVyID0gc2V0SW50ZXJ2YWwoKCkgPT4gc29ja2V0LnBpbmc/LigpLCBrZWVwQWxpdmVJbnRlcnZhbCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0KICAgICAgICBhd2FpdCBzZXR1cCgpOwogICAgICAgIGVycm9yID0gdm9pZCAwOwogICAgICAgIHNvY2tldENsaWVudCA9IHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBrZWVwQWxpdmVUaW1lciAmJiBjbGVhckludGVydmFsKGtlZXBBbGl2ZVRpbWVyKTsKICAgICAgICAgICAgc29ja2V0LmNsb3NlKCk7CiAgICAgICAgICAgIHNvY2tldENsaWVudENhY2hlLmRlbGV0ZShgJHtrZXl9OiR7dXJsfWApOwogICAgICAgICAgfSwKICAgICAgICAgIGdldCBzb2NrZXQoKSB7CiAgICAgICAgICAgIHJldHVybiBzb2NrZXQ7CiAgICAgICAgICB9LAogICAgICAgICAgcmVxdWVzdCh7IGJvZHksIG9uRXJyb3IsIG9uUmVzcG9uc2UgfSkgewogICAgICAgICAgICBpZiAoZXJyb3IgJiYgb25FcnJvcikKICAgICAgICAgICAgICBvbkVycm9yKGVycm9yKTsKICAgICAgICAgICAgY29uc3QgaWQgPSBib2R5LmlkID8/IGlkQ2FjaGUudGFrZSgpOwogICAgICAgICAgICBjb25zdCBjYWxsYmFjayA9IChyZXNwb25zZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzcG9uc2UuaWQgPT09ICJudW1iZXIiICYmIGlkICE9PSByZXNwb25zZS5pZCkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBpZiAoYm9keS5tZXRob2QgPT09ICJldGhfc3Vic2NyaWJlIiAmJiB0eXBlb2YgcmVzcG9uc2UucmVzdWx0ID09PSAic3RyaW5nIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuc2V0KHJlc3BvbnNlLnJlc3VsdCwgewogICAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiBjYWxsYmFjaywKICAgICAgICAgICAgICAgICAgb25FcnJvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgaWYgKGJvZHkubWV0aG9kID09PSAiZXRoX3Vuc3Vic2NyaWJlIikKICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMuZGVsZXRlKGJvZHkucGFyYW1zPy5bMF0pOwogICAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgICB9OwogICAgICAgICAgICByZXF1ZXN0cy5zZXQoaWQsIHsgb25SZXNwb25zZTogY2FsbGJhY2ssIG9uRXJyb3IgfSk7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgc29ja2V0LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBqc29ucnBjOiAiMi4wIiwKICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgIC4uLmJvZHkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yMik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0QXN5bmMoeyBib2R5LCB0aW1lb3V0ID0gMWU0IH0pIHsKICAgICAgICAgICAgcmV0dXJuIHdpdGhUaW1lb3V0KCgpID0+IG5ldyBQcm9taXNlKChvblJlc3BvbnNlLCBvbkVycm9yKSA9PiB0aGlzLnJlcXVlc3QoewogICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgb25FcnJvciwKICAgICAgICAgICAgICBvblJlc3BvbnNlCiAgICAgICAgICAgIH0pKSwgewogICAgICAgICAgICAgIGVycm9ySW5zdGFuY2U6IG5ldyBUaW1lb3V0RXJyb3IoeyBib2R5LCB1cmwgfSksCiAgICAgICAgICAgICAgdGltZW91dAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0cywKICAgICAgICAgIHN1YnNjcmlwdGlvbnMsCiAgICAgICAgICB1cmwKICAgICAgICB9OwogICAgICAgIHNvY2tldENsaWVudENhY2hlLnNldChgJHtrZXl9OiR7dXJsfWAsIHNvY2tldENsaWVudCk7CiAgICAgICAgcmV0dXJuIFtzb2NrZXRDbGllbnRdOwogICAgICB9CiAgICB9KTsKICAgIGNvbnN0IFtfLCBbc29ja2V0Q2xpZW50X11dID0gYXdhaXQgc2NoZWR1bGUoKTsKICAgIHJldHVybiBzb2NrZXRDbGllbnRfOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL3JwYy93ZWJTb2NrZXQuanMKICBhc3luYyBmdW5jdGlvbiBnZXRXZWJTb2NrZXRScGNDbGllbnQodXJsLCBvcHRpb25zID0ge30pIHsKICAgIGNvbnN0IHsga2VlcEFsaXZlLCByZWNvbm5lY3QgfSA9IG9wdGlvbnM7CiAgICByZXR1cm4gZ2V0U29ja2V0UnBjQ2xpZW50KHsKICAgICAgYXN5bmMgZ2V0U29ja2V0KHsgb25DbG9zZSwgb25FcnJvciwgb25PcGVuLCBvblJlc3BvbnNlIH0pIHsKICAgICAgICBjb25z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pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICBpZiAoIXNvY2tldCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHNvY2tldC5vbm9wZW4gPSByZXNvbHZlOwogICAgICAgICAgICBzb2NrZXQub25lcnJvciA9IHJlamVjdDsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBjb25zdCB7IGNsb3NlOiBjbG9zZV8gfSA9IHNvY2tldDsKICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihzb2NrZXQsIHsKICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICBjbG9zZV8uYmluZChzb2NrZXQpKCk7CiAgICAgICAgICAgIG9uQ2xvc2UoKTsKICAgICAgICAgIH0sCiAgICAgICAgICBwaW5nKCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgV2ViU29ja2V0UmVxdWVzdEVycm9yKHsKICAgICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgICBjYXVzZTogbmV3IFNvY2tldENsb3NlZEVycm9yKHsgdXJsOiBzb2NrZXQudXJsIH0pCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICBjb25zdCBib2R5ID0gewogICAgICAgICAgICAgICAganNvbnJwYzogIjIuMCIsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICJuZXRfdmVyc2lvbiIsCiAgICAgICAgICAgICAgICBwYXJhbXM6IFtdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICBzb2NrZXQuc2VuZChKU09OLnN0cmluZ2lmeShib2R5KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0sCiAgICAgICAgICByZXF1ZXN0KHsgYm9keSB9KSB7CiAgICAgICAgICAgIGlmIChzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NFRCB8fCBzb2NrZXQucmVhZHlTdGF0ZSA9PT0gc29ja2V0LkNMT1NJTkcpCiAgICAgICAgICAgICAgdGhyb3cgbmV3IFdlYlNvY2tldFJlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgICBib2R5LAogICAgICAgICAgICAgICAgdXJsOiBzb2NrZXQudXJsLAogICAgICAgICAgICAgICAgY2F1c2U6IG5ldyBTb2NrZXRDbG9zZWRFcnJvcih7IHVybDogc29ja2V0LnVybCB9KQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gc29ja2V0LnNlbmQoSlNPTi5zdHJpbmdpZnkoYm9keSkpOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9LAogICAgICBrZWVwQWxpdmUsCiAgICAgIHJlY29ubmVjdCwKICAgICAgdXJsCiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9ycGMvY29tcGF0LmpzCiAgYXN5bmMgZnVuY3Rpb24gZ2V0U29ja2V0KHVybCkgewogICAgY29uc3QgY2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybCk7CiAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihjbGllbnQuc29ja2V0LCB7CiAgICAgIHJlcXVlc3RzOiBjbGllbnQucmVxdWVzdHMsCiAgICAgIHN1YnNjcmlwdGlvbnM6IGNsaWVudC5zdWJzY3JpcHRpb25zCiAgICB9KTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX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2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3V0aWxzL3R5cGVkRGF0YS5qcwogIGluaXRfaXNBZGRyZXNzKCk7CiAgaW5pdF9zaXplKCk7CiAgaW5pdF90b0hleCgpOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vdXRpbHMvc2lnbmF0dXJlL2hhc2hUeXBlZERhdGEuanMKICBpbml0X2VuY29kZUFiaVBhcmFtZXRlcnMoKTsKICBpbml0X2NvbmNhdCgpOwogIGluaXRfdG9IZXgoKTsKICBpbml0X2tlY2NhazI1NigpOwogIGZ1bmN0aW9uIGhhc2hUeXBlZERhdGEocGFyYW1ldGVycykgewogICAgY29uc3QgeyBkb21haW4gPSB7fSwgbWVzc2FnZSwgcHJpbWFyeVR5cGUgfSA9IHBhcmFtZXRlcnM7CiAgICBjb25zdCB0eXBlcyA9IHsKICAgICAgRUlQNzEyRG9tYWluOiBnZXRUeXBlc0ZvckVJUDcxMkRvbWFpbih7IGRvbWFpbiB9KSwKICAgICAgLi4ucGFyYW1ldGVycy50eXBlcwogICAgfTsKICAgIHZhbGlkYXRlVHlwZWREYXRhKHsKICAgICAgZG9tYWluLAogICAgICBtZXNzYWdlLAogICAgICBwcmltYXJ5VHlwZSwKICAgICAgdHlwZXMKICAgIH0pOwogICAgY29uc3QgcGFydHMgPSBbIjB4MTkwMSJdOwogICAgaWYgKGRvbWFpbikKICAgICAgcGFydHMucHVzaChoYXNoRG9tYWluKHsKICAgICAgICBkb21haW4sCiAgICAgICAgdHlwZXMKICAgICAgfSkpOwogICAgaWYgKHByaW1hcnlUeXBlICE9PSAiRUlQNzEyRG9tYWluIikKICAgICAgcGFydHMucHVzaChoYXNoU3RydWN0KHsKICAgICAgICBkYXRhOiBtZXNzYWdlLAogICAgICAgIHByaW1hcnlUeXBlLAogICAgICAgIHR5cGVzCiAgICAgI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AodHlwZW9mIHZhbHVlID09PSAibnVtYmVyIiB8fCB0eXBlb2YgdmFsdWUgPT09ICJiaWdpbnQiKSkgewogICAgICAgICAgY29uc3QgW190eXBlLCBiYXNlMiwgc2l6ZV9dID0gaW50ZWdlck1hdGNoOwogICAgICAgICAgbnVtYmVyVG9IZXgodmFsdWUsIHsKICAgICAgICAgICAgc2lnbmVkOiBiYXNlMiA9PT0gImludCIsCiAgICAgICAgICAgIHNpemU6IE51bWJlci5wYXJzZUludChzaXplXykgLyA4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaWYgKHR5cGUgPT09ICJhZGRyZXNzIiAmJiB0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciICYmICFpc0FkZHJlc3ModmFsdWUpKQogICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRBZGRyZXNzRXJyb3IoeyBhZGRyZXNzOiB2YWx1ZSB9KTsKICAgICAgICBjb25zdCBieXRlc01hdGNoID0gdHlwZS5tYXRjaChieXRlc1JlZ2V4Mik7CiAgICAgICAgaWYgKGJ5dGVzTWF0Y2gpIHsKICAgICAgICAgIGNvbnN0IFtfdHlwZSwgc2l6ZV9dID0gYnl0ZXNNYXRjaDsKICAgICAgICAgIGlmIChzaXplXyAmJiBzaXplKHZhbHVlKSAhPT0gTnVtYmVyLnBhcnNlSW50KHNpemVfKSkKICAgICAgICAgICAgdGhyb3cgbmV3IEJ5dGVzU2l6ZU1pc21hdGNoRXJyb3IoewogICAgICAgICAgICAgIGV4cGVjdGVkU2l6ZTogTnVtYmVyLnBhcnNlSW50KHNpemVfKSwKICAgICAgICAgICAgICBnaXZlblNpemU6IHNpemUodmFsdWUpCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdHJ1Y3QyID0gdHlwZXNbdHlwZV07CiAgICAgICAgaWYgKHN0cnVjdDIpIHsKICAgICAgICAgIHZhbGlkYXRlUmVmZXJlbmNlKHR5cGUpOwogICAgICAgICAgdmFsaWR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IgKGxldCBncm91cCA9IDA7IGdyb3VwIDwgNTsgZ3JvdXArKykgewogICAgICAgIGNvbnN0IHJHcm91cCA9IDQgLSBncm91cDsKICAgICAgICBjb25zdCBoYmwgPSBLbFtncm91cF0sIGhiciA9IEtyW2dyb3VwXTsKICAgICAgICBjb25zdCBybCA9IGlkeExbZ3JvdXBdLCByciA9IGlkeFJbZ3JvdXBdOwogICAgICAgIGNvbnN0IHNsID0gc2hpZnRzTFtncm91cF0sIHNyID0gc2hpZnRzUltncm91cF07CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCAxNjsgaSsrKSB7CiAgICAgICAgICBjb25zdCB0bCA9IHJvdGwoYWwgKyBmKGdyb3VwLCBibCwgY2wsIGRsKSArIFJfQlVGW3JsW2ldXSArIGhibCwgc2xbaV0pICsgZWwgfCAwOwogICAgICAgICAgYWwgPSBlbCwgZWwgPSBkbCwgZGwgPSByb3RsKGNsLCAxMCkgfCAwLCBjbCA9IGJsLCBibCA9IHRsOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDE2OyBpKyspIHsKICAgICAgICAgIGNvbnN0IHRyID0gcm90bChhciArIGYockdyb3VwLCBiciwgY3IsIGRyKSArIFJfQlVGW3JyW2ldXSArIGhiciwgc3JbaV0pICsgZXIgfCAwOwogICAgICAgICAgYXIgPSBlciwgZXIgPSBkciwgZHIgPSByb3RsKGNyLCAxMCkgfCAwLCBjciA9IGJyLCBiciA9IHRyOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLnNldCh0aGlzLmgxICsgY2wgKyBkciB8IDAsIHRoaXMuaDIgKyBkbCArIGVyIHwgMCwgdGhpcy5oMyArIGVsICsgYXIgfCAwLCB0aGlzLmg0ICsgYWwgKyBiciB8IDAsIHRoaXMuaDAgKyBibCArIGNyIHwgMCk7CiAgICB9CiAgICByb3VuZENsZWFuKCkgewogICAgICBSX0JVRi5maWxsKDApOwogICAgfQogICAgZGVzdHJveSgpIHsKICAgIC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JhbnNhY3Rpb25BcnJheS5sZW5ndGggIT09IDEzKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBjaGFpbklkLAogICAgICAgICAgbm9uY2UsCiAgICAgICAgICBtYXhQcmlvcml0eUZlZVBlckdhcywKICAgICAgICAgIG1heEZlZVBlckdhcywKICAgICAgICAgIGdhcywKICAgICAgICAgIHRvLAogICAgICAgICAgdmFsdWUsCiAgICAgICAgICBkYXRhLAogICAgICAgICAgYWNjZXNzTGlzdCwKICAgICAgICAgIGF1dGhvcml6YXRpb25MaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAiZWlwNzcwMiIKICAgICAgfSk7CiAgICBjb25zdCB0cmFuc2FjdGlvbiA9IHsKICAgICAgY2hhaW5JZDogaGV4VG9OdW1iZXIoY2hhaW5JZCksCiAgICAgIHR5cGU6ICJlaXA3NzAyIgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvT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AgICAgICAgIG1heFByaW9yaXR5RmVlUGVyR2FzLAogICAgICAgICAgbWF4RmVlUGVyR2FzLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICBhY2Nlc3NMaXN0LAogICAgICAgICAgLi4udHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPiA5ID8gewogICAgICAgICAgICB2LAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAiZWlwNDg0NCIKICAgICAgfSk7CiAgICBjb25zdCB0cmFuc2FjdGlvbiA9IHsKICAgICAgYmxvYlZlcnNpb25lZEhhc2hlcywKICAgICAgY2hhaW5JZDogaGV4VG9OdW1iZXIoY2hhaW5JZCksCiAgICAgIHR5cGU6ICJlaXA0ODQ0IgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKSAmJiBnYXMgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLmdhcyA9IGhleFRvQmlnSW50KGdhcyk7CiAgICBpZiAoaXNIZXgoZGF0YSkgJiYgZGF0YSAhPT0gIjB4IikKICAgICAgdHJhbnNhY3Rpb24uZGF0YSA9IGRhdGE7CiAgICBpZiAoaXNIZXgobm9uY2UpICYmIG5vbmNlICE9PSAiMHgiKQogICAgICB0cmFuc2FjdGlvbi5ub25jZSA9IGhleFRvTnVtYmVyKG5vbmNlKTsKICAgIGlmIChpc0hleCh2YWx1ZSkgJiYgdmFsdWUgIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnZhbHVlID0gaGV4VG9CaWdJbnQodmFsdWUpOwogICAgaWYgKGlzSGV4KG1heEZlZVBlckJsb2JHYXMpIC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9uIHBhcnNlVHJhbnNhY3Rpb25FSVAxNTU5KHNlcmlhbGl6ZWRUcmFuc2FjdGlvbikgewogICAgY29uc3QgdHJhbnNhY3Rpb25BcnJheSA9IHRvVHJhbnNhY3Rpb25BcnJheShzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogICAgY29uc3QgW2NoYWluSWQsIG5vbmNlLCBtYXhQcmlvcml0eUZlZVBlckdhcywgbWF4RmVlUGVyR2FzLCBnYXMsIHRvLCB2YWx1ZSwgZGF0YSwgYWNjZXNzTGlzdCwgdiwgciwgc10gPSB0cmFuc2FjdGlvbkFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDkgfHwgdHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDEyKSkKICAgICAgdGhyb3cgbmV3IEludmFsaWRTZXJpYWxpemVkVHJhbnNhY3Rpb25FcnJvcih7CiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2hhaW5JZCwKICAgICAgICAgIG5vbmNlLAogICAgICAgICAgbWF4UHJpb3JpdHlGZWVQZXJHYXMsCiAgICAgICAgICBtYXhGZWVQZXJHYXMsCiAgICAgICAgICBnYXMsCiAgICAgICAgICB0bywKICAgICAgICAgIHZhbHVlLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGFjY2Vzc0xpc3QsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDkgPyB7CiAgICAgICAgICAgIHYsCiAgICAgICAgICAgIHIsCiAgICAgICAgICAgIHMKICAgICAgICAgIH0gOiB7fQogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uLAogICAgICAgIHR5cGU6ICJlaXAxNTU5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICBjaGFpbklkOiBoZXhUb051bWJlcihjaGFpbklkKSwKICAgICAgdHlwZTogImVpcDE1NTkiCiAgICB9OwogICAg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kgOiB2b2lkIDA7CiAgICByZXR1cm4geyAuLi5zaWduYXR1cmUsIC4uLnRyYW5zYWN0aW9uIH07CiAgfQogIGZ1bmN0aW9uIHBhcnNlVHJhbnNhY3Rpb25MZWdhY3koc2VyaWFsaXplZFRyYW5zYWN0aW9uKSB7CiAgICBjb25zdCB0cmFuc2FjdGlvbkFycmF5ID0gZnJvbVJscChzZXJpYWxpemVkVHJhbnNhY3Rpb24sICJoZXgiKTsKICAgIGNvbnN0IFtub25jZSwgZ2FzUHJpY2UsIGdhcywgdG8sIHZhbHVlLCBkYXRhLCBjaGFpbklkT3JWXywgciwgc10gPSB0cmFuc2FjdGlvbkFycmF5OwogICAgaWYgKCEodHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDYgfHwgdHJhbnNhY3Rpb25BcnJheS5sZW5ndGggPT09IDkpKQogICAgICB0aHJvdyBuZXcgSW52YWxpZFNlcmlhbGl6ZWRUcmFuc2FjdGlvbkVycm9yKHsKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBub25jZSwKICAgICAgICAgIGdhc1ByaWNlLAogICAgICAgICAgZ2FzLAogICAgICAgICAgdG8sCiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICAuLi50cmFuc2FjdGlvbkFycmF5Lmxlbmd0aCA+IDYgPyB7CiAgICAgICAgICAgIHY6IGNoYWluSWRPclZfLAogICAgICAgICAgICByLAogICAgICAgICAgICBzCiAgICAgICAgICB9IDoge30KICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0eXBlOiAibGVnYWN5IgogICAgICB9KTsKICAgIGNvbnN0IHRyYW5zYWN0aW9uID0gewogICAgICB0eXBlOiAibGVnYWN5IgogICAgfTsKICAgIGlmIChpc0hleCh0bykgJiYgdG8gIT09ICIweCIpCiAgICAgIHRyYW5zYWN0aW9uLnRvID0gdG87CiAgICBpZiAoaXNIZXgoZ2FzKS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aWduYXR1cmUpIHsKICAgICAgY29uc3QgdiA9ICgoKSA9PiB7CiAgICAgICAgaWYgKHNpZ25hdHVyZS52ID49IDM1bikgewogICAgICAgICAgY29uc3QgaW5mZXJyZWRDaGFpbklkID0gKHNpZ25hdHVyZS52IC0gMzVuKSAvIDJuOwogICAgICAgICAgaWYgKGluZmVycmVkQ2hhaW5JZCA+IDApCiAgICAgICAgICAgIHJldHVybiBzaWduYXR1cmUudjsKICAgICAgICAgIHJldHVybiAyN24gKyAoc2lnbmF0dXJlLnYgPT09IDM1biA/IDBuIDogMW4pOwogICAgICAgIH0KICAgICAgICBpZiAoY2hhaW5JZCA+IDApCiAgICAgICAgICByZXR1cm4gQmlnSW50KGNoYWluSWQgKiAyKSArIEJpZ0ludCgzNW4gKyBzaWduYXR1cmUudiAtIDI3bik7CiAgICAgICAgY29uc3QgdjIgPSAyN24gKyAoc2lnbmF0dXJlLnYgPT09IDI3biA/IDBuIDogMW4pOwogICAgICAgIGlmIChzaWduYXR1cmUudiAhPT0gdjIpCiAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZExlZ2FjeVZFcnJvcih7IHY6IHNpZ25hdHVyZS52IH0pOwogICAgICAgIHJldHVybiB2MjsKICAgICAgfSkoKTsKICAgICAgY29uc3QgciA9IHRyaW0oc2lnbmF0dXJlLnIpOwogICAgICBjb25zdCBzID0gdHJpbShzaWduYXR1cmUucyk7CiAgICAgIHNlcmlhbGl6ZWRUcmFuc2FjdGlvbiA9IFsKICAgICAgICAuLi5zZXJpYWxpemVkVHJhbnNhY3Rpb24sCiAgICAgICAgdG9IZXgodiksCiAgICAgICAgciA9PT0gIjB4MDAiID8gIjB4IiA6IHIsCiAgICAgICAgcyA9PT0gIjB4MDAiID8gIjB4IiA6IHMKICAgICAgXTsKICAgIH0gZWxzZSBpZiAoY2hhaW5JZCA+IDApIHsKICAgICAgc2VyaWFsaXplZFRyYW5zYWN0aW9uID0gWwogICAgICAgIC4uLnNlcmlhbGl6ZWRUcmFuc2FjdGlvbiwKICAgICAgICB0b0hleChjaGFpbklkKSwKICAgICAgICAiMHgiLAogICAgICAgICIweCIKICAgICAgXTsKICAgIH0KICAgIHJldHVybiB0b1JscChzZXJpYWxpemVkVHJhbnNhY3Rpb24pOwogIH0KICBmdW5jdGlvbiB0b1lQYXJpdHlTaWduYXR1cmVBcnJheSh0cmFuc2FjdGlvbiwgc2lnbmF0dXJlXykgewogICAgY29uc3Qgc2lnbmF0dXJlID0gc2lnbmF0dXJlXyA/PyB0cmFuc2FjdGlvbjsKICAgIGNvbnN0IHsgdiwgeVBhcml0eSB9ID0gc2lnbmF0dXJlOwogICAgaWYgKHR5cGVvZiBzaWduYXR1cmUuciA9PT0gInVuZGVmaW5lZCIpCiAgICAgIHJldHVybiBbXTsKICAgIGlmICh0eXBlb2Ygc2lnbmF0dXJlLnMgPT09ICJ1bmRlZmluZWQiKQogICAgICByZXR1cm4gW107CiAgICBpZiAodHlwZW9mIHYgPT09ICJ1bmRlZmluZWQiICYmIHR5cGVvZiB5UGFyaXR5ID09PSAidW5kZWZpbmVkIikKICAgICAgcmV0dXJuIFtdOwogICAgY29uc3QgciA9IHRyaW0oc2lnbmF0dXJlLnIpOwogICAgY29uc3QgcyA9IHRyaW0oc2lnbmF0dXJlLnMpOwogICAgY29uc3QgeVBhcml0eV8gPSAoKCkgPT4gewogICAgICBpZiAodHlwZW9mIHlQYXJpdHkgPT09ICJudW1iZXIiKQogICAgICAgIHJldHVybiB5UGFyaXR5ID8gdG9IZXgoMSkgOiAiMHgiOwogICAgICBpZiAodiA9PT0gMG4pCiAgICAgICAgcmV0dXJuICIweCI7CiAgICAgIGlmICh2ID09PSAxbikKICAgICAgICByZXR1cm4gdG9IZXgoMSk7CiAgICAgIHJldHVybiB2ID09PSAyN24gPyAiMHgiIDogdG9IZXgoMSk7CiAgICB9KSgpOwogICAgcmV0dXJuIFt5UGFyaXR5XywgciA9PT0gIjB4MDAiID8gIjB4IiA6IHIsIHMgPT09ICIweDAwIiA/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0pIHsKICAgICAgICBjb25zdCBrZXkgPSBnZXRLZXkoeyBhZGRyZXNzLCBjaGFpbklkIH0pOwogICAgICAgIGNvbnN0IHByb21pc2UgPSB0aGlzLmdldCh7IGFkZHJlc3MsIGNoYWluSWQsIGNsaWVudCB9KTsKICAgICAgICB0aGlzLmluY3JlbWVudCh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgY29uc3Qgbm9uY2UgPSBhd2FpdCBwcm9taXNlOwogICAgICAgIGF3YWl0IHNvdXJjZS5zZXQoeyBhZGRyZXNzLCBjaGFpbklkIH0sIG5vbmNlKTsKICAgICAgICBub25jZU1hcC5zZXQoa2V5LCBub25jZSk7CiAgICAgICAgcmV0dXJuIG5vbmNlOwogICAgICB9LAogICAgICBhc3luYyBpbmNyZW1lbnQoeyBhZGRyZXNzLCBjaGFpbklkIH0pIHsKICAgICAgICBjb25zdCBrZXkgPSBnZXRLZXkoeyBhZGRyZXNzLCBjaGFpbklkIH0pOwogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICBkZWx0YU1hcC5zZXQoa2V5LCBkZWx0YSArIDEpOwogICAgICB9LAogICAgICBhc3luYyBnZXQoeyBhZGRyZXNzLCBjaGFpbklkLCBjbGllbnQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgbGV0IHByb21pc2UgPSBwcm9taXNlTWFwLmdldChrZXkpOwogICAgICAgIGlmICghcHJvbWlzZSkgewogICAgICAgICAgcHJvbWlzZSA9IChhc3luYyAoKSA9PiB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgY29uc3Qgbm9uY2UgPSBhd2FpdCBzb3VyY2UuZ2V0KHsgYWRkcmVzcywgY2hhaW5JZCwgY2xpZW50IH0pOwogICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzTm9uY2UgPSBub25jZU1hcC5nZXQoa2V5KSA/PyAwOwogICAgICAgICAgICAgIGlmIChwcmV2aW91c05vbmNlID4gMCAmJiBub25jZSA8PSBwcmV2aW91c05vbmNlKQogICAgICAgICAgICAgICAgcmV0dXJuIHByZXZpb3VzTm9uY2UgKyAxOwogICAgICAgICAgICAgIG5vbmNlTWFwLmRlbGV0ZShrZXkpOwogICAgICAgICAgICAgIHJldHVybiBub25jZTsKICAgICAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgICAgICB0aGlzLnJlc2V0KHsgYWRkcmVzcywgY2hhaW5JZCB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkoKTsKICAgICAgICAgIHByb21pc2VNYXAuc2V0KGtleSwgcHJvbWlzZSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGRlbHRhID0gZGVsdGFNYXAuZ2V0KGtleSkgPz8gMDsKICAgICAgICByZXR1cm4gZGVsdGEgKyBhd2FpdCBwcm9taXNlOwogICAgICB9LAogICAgICByZXNldCh7IGFkZHJlc3MsIGNoYWluSWQgfSkgewogICAgICAgIGNvbnN0IGtleSA9IGdldEtleSh7IGFkZHJlc3MsIGNoYWluSWQgfSk7CiAgICAgICAgZGVsdGFNYXAuZGVsZXRlKGtleSk7CiAgICAgICAgcHJvbWlzZU1hcC5kZWxldGUoa2V5KTsKICAgICAgfQogICAgfTsKICB9CiAgZnVuY3Rpb24ganNvblJwYygpIHsKICAgIHJldHVybiB7CiAgICAgIGFzeW5jIGdldChwYXJhbWV0ZXJzKSB7CiAgICAgICAgY29uc3QgeyBhZGRyZXNzLCBjbGllbnQgfSA9IHBhcmFtZXRlcnM7CiAgICAgICAgcmV0dXJuIGdldFRyYW5zYWN0aW9uQ291bnQoY2xpZW50LCB7CiAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgYmxvY2tUYWc6ICJwZW5kaW5nIgogICAgICAgIH0pOwogICAgICB9LAogICAgICBzZXQoKSB7CiAgICAgIH0KICAgIH07CiAgfQogIHZhciBub25jZU1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cnJlbnRDaHVua10gPSBbXTsKICAgICAgICB9CiAgICAgICAgY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10gPSBbCiAgICAgICAgICAuLi5jaHVua2VkQ2FsbHNbY3VycmVudENodW5rXSwKICAgICAgICAgIHsKICAgICAgICAgICAgYWxsb3dGYWlsdXJlOiB0cnVlLAogICAgICAgICAgICBjYWxsRGF0YSwKICAgICAgICAgICAgdGFyZ2V0OiBhZGRyZXNzCiAgICAgICAgICB9CiAgICAgICAgXTsKICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgYWJpOiBhYmkyLAogICAgICAgICAgYWRkcmVzcywKICAgICAgICAgIGFyZ3MsCiAgICAgICAgICBkb2NzUGF0aDogIi9kb2NzL2NvbnRyYWN0L211bHRpY2FsbCIsCiAgICAgICAgICBmdW5jdGlvbk5hbWUKICAgICAgICB9KTsKICAgICAgICBpZiAoIWFsbG93RmFpbHVyZSkKICAgICAgICAgIHRocm93IGVycm9yOwogICAgICAgIGNodW5rZWRDYWxsc1tjdXJyZW50Q2h1bmtdID0gWwogICAgICAgICAgLi4uY2h1bmtlZENhbGxzW2N1cnJlbnRDaHVua10sCiAgICAgICAgICB7CiAgICAgICAgICAgIGFsbG93RmFpbHVyZTogdHJ1ZSwKICAgICAgICAgICAgY2FsbERhdGE6ICIweCIsCiAgICAgICAgICAgIHRhcmdldDogYWRkcmVzcwogICAgICAgICAgfQogICAgICAgIF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGFnZ3JlZ2F0ZTNSZXN1bHRzID0gYXdhaXQgUHJvbWlzZS5hbGxTZXR0bGVkKGNodW5rZWRDYWxscy5tYXAoKGNhbGxzKSA9PiBnZXRBY3Rpb24oY2xpZW50LCByZWFkQ29udHJhY3QsICJyZWFkQ29udHJhY3QiKSh7CiAgICAgIGFiaTogbXVsdGljYWxsM0FiaSwKICAgICAgYW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cywgZnVuY3Rpb25OYW1lLCBhcmdzIH0gPSBjb250cmFjdHMyW3Jlc3VsdHMubGVuZ3RoXTsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGNhbGxEYXRhID09PSAiMHgiKQogICAgICAgICAgICB0aHJvdyBuZXcgQWJpRGVjb2RpbmdaZXJvRGF0YUVycm9yKCk7CiAgICAgICAgICBpZiAoIXN1Y2Nlc3MpCiAgICAgICAgICAgIHRocm93IG5ldyBSYXdDb250cmFjdEVycm9yKHsgZGF0YTogcmV0dXJuRGF0YSB9KTsKICAgICAgICAgIGNvbnN0IHJlc3VsdDIgPSBkZWNvZGVGdW5jdGlvblJlc3VsdCh7CiAgICAgICAgICAgIGFiaTogYWJpMiwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgZGF0YTogcmV0dXJuRGF0YSwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIHJlc3VsdHMucHVzaChhbGxvd0ZhaWx1cmUgPyB7IHJlc3VsdDogcmVzdWx0Miwgc3RhdHVzOiAic3VjY2VzcyIgfSA6IHJlc3VsdDIpOwogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgY29uc3QgZXJyb3IgPSBnZXRDb250cmFjdEVycm9yKGVyciwgewogICAgICAgICAgICBhYmk6IGFiaTIsCiAgICAgICAgICAgIGFkZHJlc3MsCiAgICAgICAgICAgIGFyZ3MsCiAgICAgICAgICAgIGRvY3NQYXRoOiAiL2RvY3MvY29udHJhY3QvbXVsdGljYWxsIiwKICAgICAgICAgICAgZnVuY3Rpb25OYW1lCiAgICAgICAgICB9KTsKICAgICAgICAgIGlmICghYWxsb3dGYWlsdXJlKQogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIHJlc3VsdHMucHVzaCh7IGVycm9yLCByZXN1bHQ6IHZvaWQgMCwgc3RhdHVzOiAiZmFpbHVyZSIgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiA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VtaXQpID0+IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgIHRyeSB7CiAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7IGNhY2hlVGltZTogMCB9KTsKICAgICAgICAgIGlmIChwcmV2QmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgaWYgKGJsb2NrTnVtYmVyID09PSBwcmV2QmxvY2tOdW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2tOdW1iZXIgLSBwcmV2QmxvY2tOdW1iZXIgPiAxICYmIGVtaXRNaXNzZWQpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBpID0gcHJldkJsb2NrTnVtYmVyICsgMW47IGkgPCBibG9ja051bWJlcjsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoaSwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoIXByZXZCbG9ja051bWJlciB8fCBibG9ja051bWJlciA+IHByZXZCbG9ja051bWJlcikgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2tOdW1iZXIoYmxvY2tOdW1iZXIsIHByZXZCbG9ja051bWJlcik7CiAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja051bWJlciA9ICgpID0+IHsKICAgICAgY29uc3Qgb2JzZXJ2ZXJJZCA9IHN0cmluZ2lmeShbCiAgICAgICAgIndhdGNoQmxvY2tOdW1iZXIiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgZW1pdE9uQmVnaW4sCiAgICAgICAgZW1pdE1pc3NlZAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrTnVtYmVyLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IGFjdGl2ZSA9IHRydWU7CiAgICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgICAgaWYgKGNsaWVudC50cmFuc3BvcnQudHlwZSA9PT0gImZhbGxiYWNrIikgewogICAgICAgICAgICAgICAgY29uc3QgdHJhbnNwb3J0MiA9IGNsaWVudC50cmFuc3BvcnQudHJhbnNwb3J0cy5maW5kKCh0cmFuc3BvcnQzKSA9PiB0cmFuc3BvcnQzLmNvbmZpZy50eXBlID09PSAid2ViU29ja2V0Iik7CiAgICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICAgICAgcmV0dXJuIHRyYW5zcG9ydDIudmFsdWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJldHVybiBjbGllbnQudHJhbnNwb3J0OwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICAgIHBhcmFtczogWyJuZXdIZWFkcyJdLAogICAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2tOdW1iZXIgPSBoZXhUb0JpZ0ludChkYXRhLnJlc3VsdD8ubnVtYmVyKTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9ja051bWJlcihibG9ja051bWJlciwgcHJldkJsb2NrTnVtYmVyKTsKICAgICAgICAgICAgICAgIHByZXZCbG9ja051bWJlciA9IGJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyb3IpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIHVuc3Vic2NyaWJlID0gdW5zdWJzY3JpYmVfOwogICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICB1bnN1YnNjcmliZSgpOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgICAgfQogICAgICAgIH0pKCk7CiAgICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICAgIH0pOwogICAgfTsKICAgIHJldHVybiBlbmFibGVQb2xsaW5nID8gcG9sbEJsb2NrTnVtYmVyKCkgOiBzdWJzY3JpYmVCbG9ja051bWJlcigpOwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2FjdGlvbnMvcHVibGljL3dhaXRGb3JUcmFuc2FjdGlvblJlY2VpcHQuanMKICBhc3luYyBmdW5jdGlvbiB3YWl0Rm9yVHJhbnNhY3Rpb25SZWNlaXB0KGNsaWVudCwgewogICA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gICAgICAgcG9sbDogdHJ1ZSwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwsCiAgICAgICAgYXN5bmMgb25CbG9ja051bWJlcihibG9ja051bWJlcl8pIHsKICAgICAgICAgIGNvbnN0IGRvbmUgPSAoZm4pID0+IHsKICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTsKICAgICAgICAgICAgX3Vud2F0Y2goKTsKICAgICAgICAgICAgZm4oKTsKICAgICAgICAgICAgX3Vub2JzZXJ2ZSgpOwogICAgICAgICAgfTsKICAgICAgICAgIGxldCBibG9ja051bWJlciA9IGJsb2NrTnVtYmVyXzsKICAgICAgICAgIGlmIChyZXRyeWluZykKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgaWYgKHJlY2VpcHQpIHsKICAgICAgICAgICAgICBpZiAoY29uZmlybWF0aW9ucyA+IDEgJiYgKCFyZWNlaXB0LmJsb2NrTnVtYmVyIHx8IGJsb2NrTnVtYmVyIC0gcmVjZWlwdC5ibG9ja051bWJlciArIDFuIDwgY29uZmlybWF0aW9ucykpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgZG9uZSgoKSA9PiBlbWl0LnJlc29sdmUocmVjZWlwdCkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgIGF3YWl0IHdpdGhSZXRyeShhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uLCAiZ2V0VHJhbnNhY3Rpb24iKSh7IGhhc2g6IGhhc2gzIH0pOwogICAgICAgICAgICAgICAgaWYgKHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyKQogICAgICAgICAgICAgICAgICBibG9ja051bWJlciA9IHRyYW5zYWN0aW9uLmJsb2NrTnVtYmVyOwogICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgcmV0cnlDb3VudAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIHJldHJ5aW5nID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVjZWlwdCA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldFRyYW5zYWN0aW9uUmVjZWlwdCwgImdldFRyYW5zYWN0aW9uUmVjZWlwdCIpKHsgaGFzaDogaGFzaDMgfSk7CiAgICAgICAgICAgIGlmIChjb25maXJtYXRpb25zID4gMSAmJiAoIXJlY2VpcHQuYmxvY2tOdW1iZXIgfHwgYmxvY2tOdW1iZXIgLSByZWNlaXB0LmJsb2NrTnVtYmVyICsgMW4gPCBjb25maXJtYXRpb25zKSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZXNvbHZlKHJlY2VpcHQpKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVHJhbnNhY3Rpb25Ob3RGb3VuZEVycm9yIHx8IGVyciBpbnN0YW5jZW9mIFRyYW5zYWN0aW9uUmVjZWlwdE5vdEZvdW5kRXJyb3IpIHsKICAgICAgICAgICAgICBpZiAoIXRyYW5zYWN0aW9uKSB7CiAgICAgICAgICAgICAgICByZXRyeWluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiA9IHRyYW5zYWN0aW9uOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCB3aXRoUmV0cnkoKCkgPT4gZ2V0QWN0aW9uKGNsaWVudCwgZ2V0QmxvY2ssICJnZXRCbG9jayIpKHsKICAgICAgICAgICAgICAgICAgYmxvY2tOdW1iZXIsCiAgICAgICAgICAgICAgICAgIGluY2x1ZGVUcmFuc2FjdGlvbnM6IHRydWUKICAgICAgICAgICAgICAgIH0pLCB7CiAgICAgICAgICAgICAgICAgIGRlbGF5OiByZXRyeURlbGF5LAogICAgICAgICAgICAgICAgICByZXRyeUNvdW50LAogICAgICAgICAgICAgICAgICBzaG91bGRSZXRyeTogKHsgZXJyb3IgfSkgPT4gZXJyb3IgaW5zdGFuY2VvZiBCbG9ja05vdEZvdW5kRXJyb3IKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0cnlpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcGxhY2VtZW50VHJhbnNhY3Rpb24gPSBibG9jay50cmFuc2FjdGlvbnMuZmluZCgoeyBmcm9tLCBub25jZSB9KSA9PiBmcm9tID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLmZyb20gJiYgbm9uY2UgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24ubm9uY2UpOwogICAgICAgICAgICAgICAgaWYgKCFyZXBsYWNlbWVudFRyYW5zYWN0aW9uKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICByZWNlaXB0ID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0VHJhbnNhY3Rpb25SZWNlaXB0LCAiZ2V0VHJhbnNhY3Rpb25SZWNlaXB0IikoewogICAgICAgICAgICAgICAgICBoYXNoOiByZXBsYWNlbWVudFRyYW5zYWN0aW9uLmhhc2gKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgaWYgKGNvbmZpcm1hdGlvbnMgPiAxICYmICghcmVjZWlwdC5ibG9ja051bWJlciB8fCBibG9ja051bWJlciAtIHJlY2VpcHQuYmxvY2tOdW1iZXIgKyAxbiA8IGNvbmZpcm1hdGlvbnMpKQogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgcmVhc29uID0gInJlcGxhY2VkIjsKICAgICAgICAgICAgICAgIGlmIChyZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvID09PSByZXBsYWNlZFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IHJlcGxhY2VkVHJhbnNhY3Rpb24udmFsdWUpIHsKICAgICAgICAgICAgICAgICAgcmVhc29uID0gInJlcHJpY2VkIjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVwbGFjZW1lbnRUcmFuc2FjdGlvbi5mcm9tID09PSByZXBsYWNlbWVudFRyYW5zYWN0aW9uLnRvICYmIHJlcGxhY2VtZW50VHJhbnNhY3Rpb24udmFsdWUgPT09IDBuKSB7CiAgICAgICAgICAgICAgICAgIHJlYXNvbiA9ICJjYW5jZWxsZWQiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZG9uZSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgIGVtaXQub25SZXBsYWNlZD8uKHsKICAgICAgICAgICAgICAgICAgICByZWFzb24sCiAgICAgICAgICAgICAgICAgICAgcmVwbGFjZWRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvbjogcmVwbGFjZW1lbnRUcmFuc2FjdGlvbiwKICAgICAgICAgICAgICAgICAgICB0cmFuc2FjdGlvblJlY2VpcHQ6IHJlY2VpcHQKICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgIGVtaXQucmVzb2x2ZShyZWNlaXB0KTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0gY2F0Y2ggKGVycl8pIHsKICAgICAgICAgICAgICAgIGRvbmUoKCkgPT4gZW1pdC5yZWplY3QoZXJyXykpOwogICAgICAgICAgICA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JhbnNhY3Rpb25zXyA/PyBmYWxzZTsKICAgIGxldCBwcmV2QmxvY2s7CiAgICBjb25zdCBwb2xsQmxvY2tzID0gKCkgPT4gewogICAgICBjb25zdCBvYnNlcnZlcklkID0gc3RyaW5naWZ5KFsKICAgICAgICAid2F0Y2hCbG9ja3MiLAogICAgICAgIGNsaWVudC51aWQsCiAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgZW1pdE1pc3NlZCwKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zLAogICAgICAgIHBvbGxpbmdJbnRlcnZhbAogICAgICBdKTsKICAgICAgcmV0dXJuIG9ic2VydmUob2JzZXJ2ZXJJZCwgeyBvbkJsb2NrLCBvbkVycm9yIH0sIChlbWl0KSA9PiBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgYmxvY2sgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRCbG9jaywgImdldEJsb2NrIikoewogICAgICAgICAgICBibG9ja1RhZywKICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgfSk7CiAgICAgICAgICBpZiAoYmxvY2subnVtYmVyICYmIHByZXZCbG9jaz8ubnVtYmVyKSB7CiAgICAgICAgICAgIGlmIChibG9jay5udW1iZXIgPT09IHByZXZCbG9jay5udW1iZXIpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmxvY2subnVtYmVyIC0gcHJldkJsb2NrLm51bWJlciA+IDEgJiYgZW1pdE1pc3NlZCkgewogICAgICAgICAgICAgIGZvciAobGV0IGkgPSBwcmV2QmxvY2s/Lm51bWJlciArIDFuOyBpIDwgYmxvY2subnVtYmVyOyBpKyspIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrMiA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgICAgIGJsb2NrTnVtYmVyOiBpLAogICAgICAgICAgICAgICAgICBpbmNsdWRlVHJhbnNhY3Rpb25zCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGVtaXQub25CbG9jayhibG9jazIsIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoCiAgICAgICAgICAgIC8vIElmIG5vIHByZXZpb3VzIGJsb2NrIGV4aXN0cywgZW1pdC4KICAgICAgICAgICAgIXByZXZCbG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBibG9jayB0YWcgaXMgInBlbmRpbmciIHdpdGggbm8gYmxvY2sgbnVtYmVyLCBlbWl0LgogICAgICAgICAgICBibG9ja1RhZyA9PT0gInBlbmRpbmciICYmICFibG9jaz8ubnVtYmVyIHx8IC8vIElmIHRoZSBuZXh0IGJsb2NrIG51bWJlciBpcyBncmVhdGVyIHRoYW4gdGhlIHByZXZpb3VzIGJsb2NrIG51bWJlciwgZW1pdC4KICAgICAgICAgICAgLy8gV2UgZG9uJ3Qgd2FudCB0byBlbWl0IGJsb2NrcyBpbiB0aGUgcGFzdC4KICAgICAgICAgICAgYmxvY2subnVtYmVyICYmIGJsb2NrLm51bWJlciA+IHByZXZCbG9jay5udW1iZXIKICAgICAgICAgICkgewogICAgICAgICAgICBlbWl0Lm9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgIHByZXZCbG9jayA9IGJsb2NrOwogICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgZW1pdC5vbkVycm9yPy4oZXJyKTsKICAgICAgICB9CiAgICAgIH0sIHsKICAgICAgICBlbWl0T25CZWdpbiwKICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgIH0pKTsKICAgIH07CiAgICBjb25zdCBzdWJzY3JpYmVCbG9ja3MgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgZW1pdEZldGNoZWQgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGVtaXRPbkJlZ2luKSB7CiAgICAgICAgICAgIGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrLCAiZ2V0QmxvY2siKSh7CiAgICAgICAgICAgICAgYmxvY2tUYWcsCiAgICAgICAgICAgICAgaW5jbHVkZVRyYW5zYWN0aW9ucwogICAgICAgICAgICB9KS50aGVuKChibG9jaykgPT4gewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGlmICghZW1pdEZldGNoZWQpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgb25CbG9jayhibG9jaywgdm9pZCAwKTsKICAgICAgICAgICAgICBlbWl0RmV0Y2hlZCA9IGZhbHNlOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibmV3SGVhZHMiXSwKICAgICAgICAgICAgb25EYXRhKGRhdGEpIHsKICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBjb25zdCBmb3JtYXQgPSBjbGllbnQuY2hhaW4/LmZvcm1hdHRlcnM/LmJsb2NrPy5mb3JtYXQgfHwgZm9ybWF0QmxvY2s7CiAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBmb3JtYXQoZGF0YS5yZXN1bHQpOwogICAgICAgICAgICAgIG9uQmxvY2soYmxvY2ssIHByZXZCbG9jayk7CiAgICAgICAgICAgICAgZW1pdEZldGNoZWQgPSBmYWxzZTsKICAgICAgICAgICAgICBwcmV2QmxvY2sgPSBibG9jazsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIG9uRXJyb3I/LihlcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgdW5zdWJzY3JpYmUgPSB1bnN1YnNjcmliZV87CiAgICAgICAgICBpZiAoIWFjdGl2ZSkKICAgICAgICAgICAgdW5zdWJzY3JpYmUoKTsKICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgIG9uRXJyb3I/LihlcnIpOwogICAgICAgIH0KICAgICAgfSkoKTsKICAgICAgcmV0dXJuICgpID0+IHVuc3Vic2NyaWJlKCk7CiAgICB9OwogICAgcmV0dXJuIGVuYWJsZVBvbGxpbmcgPyBwb2xsQmxvY2tzKCkgOiBzdWJzY3JpYmVCbG9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eShbCiAgICAgICAgIndhdGNoRXZlbnQiLAogICAgICAgIGFkZHJlc3MsCiAgICAgICAgYXJncywKICAgICAgICBiYXRjaCwKICAgICAgICBjbGllbnQudWlkLAogICAgICAgIGV2ZW50LAogICAgICAgIHBvbGxpbmdJbnRlcnZhbCwKICAgICAgICBmcm9tQmxvY2sKICAgICAgXSk7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25Mb2dzLCBvbkVycm9yIH0sIChlbWl0KSA9PiB7CiAgICAgICAgbGV0IHByZXZpb3VzQmxvY2tOdW1iZXI7CiAgICAgICAgaWYgKGZyb21CbG9jayAhPT0gdm9pZCAwKQogICAgICAgICAgcHJldmlvdXNCbG9ja051bWJlciA9IGZyb21CbG9jayAtIDFuOwogICAgICAgIGxldCBmaWx0ZXI7CiAgICAgICAgbGV0IGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgY29uc3QgdW53YXRjaCA9IHBvbGwoYXN5bmMgKCkgPT4gewogICAgICAgICAgaWYgKCFpbml0aWFsaXplZCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZUV2ZW50RmlsdGVyLCAiY3JlYXRlRXZlbnRGaWx0ZXIiKSh7CiAgICAgICAgICAgICAgICBhZGRyZXNzLAogICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgIGV2ZW50LAogICAgICAgICAgICAgICAgZXZlbnRzLAogICAgICAgICAgICAgICAgc3RyaWN0LAogICAgICAgICAgICAgICAgZnJvbUJsb2NrCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gY2F0Y2ggewogICAgICAgICAgICB9CiAgICAgICAgICAgIGluaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgbGV0IGxvZ3M7CiAgICAgICAgICAgIGlmIChmaWx0ZXIpIHsKICAgICAgICAgICAgICBsb2dzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBibG9ja051bWJlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGdldEJsb2NrTnVtYmVyLCAiZ2V0QmxvY2tOdW1iZXIiKSh7fSk7CiAgICAgICAgICAgICAgaWYgKHByZXZpb3VzQmxvY2tOdW1iZXIgJiYgcHJldmlvdXNCbG9ja051bWJlciAhPT0gYmxvY2tOdW1iZXIpIHsKICAgICAgICAgICAgICAgIGxvZ3MgPSBhd2FpdCBnZXRBY3Rpb24oY2xpZW50LCBnZXRMb2dzLCAiZ2V0TG9ncyIpKHsKICAgICAgICAgICAgICAgICAgYWRkcmVzcywKICAgICAgICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgICAgICAgZXZlbnQsCiAgICAgICAgICAgICAgICAgIGV2ZW50cywKICAgICAgICAgICAgICAgICAgZnJvbUJsb2NrOiBwcmV2aW91c0Jsb2NrTnVtYmVyICsgMW4sCiAgICAgICAgICAgICAgICAgIHRvQmxvY2s6IGJsb2NrTnVtYmVyCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbG9ncyA9IFtdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwcmV2aW91c0Jsb2NrTnVtYmVyID0gYmxvY2tOdW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGxvZ3MubGVuZ3RoID09PSAwKQogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgaWYgKGJhdGNoKQogICAgICAgICAgICAgIGVtaXQub25Mb2dzKGxvZ3MpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBsb2cgb2YgbG9ncykKICAgICAgICAgICAgICAgIGVtaXQub25Mb2dzKFtsb2ddKTsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZmlsdGVyICYmIGVyciBpbnN0YW5jZW9mIEludmFsaWRJbnB1dFJwY0Vycm9yKQogICAgICAgICAgICAgIGluaXRpYWxpemVkID0gZmFsc2U7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZUV2ZW50ID0gKCkgPT4gewogICAgICBsZXQgYWN0aXZlID0gdHJ1ZTsKICAgICAgbGV0IHVuc3Vic2NyaWJlID0gKCkgPT4gYWN0aXZlID0gZmFsc2U7CiAgICAgIChhc3luYyAoKSA9PiB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9ICgoKSA9PiB7CiAgICAgICAgICAgIGlmIChjbGllbnQudHJhbnNwb3J0LnR5cGUgPT09ICJmYWxsYmFjayIpIHsKICAgICAgICAgICAgICBjb25zdCB0cmFuc3BvcnQyID0gY2xpZW50LnRyYW5zcG9ydC50cmFuc3BvcnRzLmZpbmQoKHRyYW5zcG9ydDMpID0+IHRyYW5zcG9ydDMuY29uZmlnLnR5cGUgPT09ICJ3ZWJTb2NrZXQiKTsKICAgICAgICAgICAgICBpZiAoIXRyYW5zcG9ydDIpCiAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwb3J0Mi52YWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xpZW50LnRyYW5zcG9ydDsKICAgICAgICAgIH0pKCk7CiAgICAgICAgICBjb25zdCBldmVudHNfID0gZXZlbnRzID8/IChldmVudCA/IFtldmVudF0gOiB2b2lkIDApOwogICAgICAgICAgbGV0IHRvcGljcyA9IFtdOwogICAgICAgICAgaWYgKGV2ZW50c18pIHsKICAgICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGV2ZW50c18uZmxhdE1hcCgoZXZlbnQyKSA9PiBlbmNvZGVFdmVudFRvcGljcyh7CiAgICAgICAgICAgICAgYWJpOiBbZXZlbnQyXSwKICAgICAgICAgICAgICBldmVudE5hbWU6IGV2ZW50Mi5uYW1lLAogICAgICAgICAgICAgIGFyZ3MKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB0b3BpY3MgPSBbZW5jb2RlZF07CiAgICAgICAgICAgIGlmIChldmVudCkKICAgICAgICAgICAgICB0b3BpY3MgPSB0b3BpY3NbMF07CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCB7IHVuc3Vic2NyaWJlOiB1bnN1YnNjcmliZV8gfSA9IGF3YWl0IHRyYW5zcG9ydC5zdWJzY3JpYmUoewogICAgICAgICAgICBwYXJhbXM6IFsibG9ncyIsIHsgYWRkcmVzcywgdG9waWNzIH1dLAogICAgICAgICAgICBvbkRhdGEoZGF0YSkgewogICAgICAgICAgICAgIGlmICghYWN0aXZlKQogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIGNvbnN0IGxvZyA9IGRhdGEucmVzdWx0OwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBjb25zdCB7IGV2ZW50TmFtZSwgYXJnczogYXJnczIgfSA9IGRlY29kZUV2ZW50TG9nKHsKICAgICAgICAgICAgICAgICAgYWJpOiBldmVudHNfID8/IFtdLAogICAgICAgICAgICAgICAgICBkYXRhOiBsb2cuZGF0YSwKICAgICAgICAgICAgICAgICAgdG9waWNzOiBsb2cudG9waWNzLAogICAgICAgICAgICAgICAgICBzdHJpY3QKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgY29uc3QgZm9ybWF0dGVkID0gZm9ybWF0TG9nKGxvZywgeyBhcmdzOiBhcmdzMiwgZXZlbnROYW1lIH0pOwogICAgICAgICAgICAgICAgb25Mb2dzKFtmb3JtYXR0ZWRdKTsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIGxldCBldmVudE5hbWU7CiAgICAgICAgICAgICAgICBsZXQgaXNVbm5hbWVkOwogICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIERlY29kZUxvZ0RhdGFNaXNtYXRjaCB8fCBlcnIgaW5zdGFuY2VvZiBEZWNvZGVMb2dUb3BpY3NNaXNtYXRjaCkgewogICAgICAgICAgICAgICAgICBpZiAoc3RyaWN0XykKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgIGV2ZW50TmFtZSA9IGVyci5hYmlJdGVtLm5hbWU7CiAgICAgICAgICAgICAgICAgIGlzVW5uYW1lZCA9IGVyci5hYmlJdGVtLmlucHV0cz8uc29tZSgoeCkgPT4gISgibmFtZSIgaW4geCAmJiB4Lm5hbWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGZvcm1hdHRlZCA9IGZvcm1hdExvZyhsb2csIHsKICAgICAgICAgICAgICAgICAgYXJnczogaXNVbm5hbWVkID8gW10gOiB7fSwKICAgICAgICAgICAgICAgICAgZXZlbnROYW1lCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG9uTG9ncyhbZm9ybWF0dGVkXSk7CiAgICAg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GNoUGVuZGluZ1RyYW5zYWN0aW9ucyIsCiAgICAgICAgY2xpZW50LnVpZCwKICAgICAgICBiYXRjaCwKICAgICAgICBwb2xsaW5nSW50ZXJ2YWwKICAgICAgXSk7CiAgICAgIHJldHVybiBvYnNlcnZlKG9ic2VydmVySWQsIHsgb25UcmFuc2FjdGlvbnMsIG9uRXJyb3IgfSwgKGVtaXQpID0+IHsKICAgICAgICBsZXQgZmlsdGVyOwogICAgICAgIGNvbnN0IHVud2F0Y2ggPSBwb2xsKGFzeW5jICgpID0+IHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGlmICghZmlsdGVyKSB7CiAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGZpbHRlciA9IGF3YWl0IGdldEFjdGlvbihjbGllbnQsIGNyZWF0ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciwgImNyZWF0ZVBlbmRpbmdUcmFuc2FjdGlvbkZpbHRlciIpKHt9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICAgIHVud2F0Y2goKTsKICAgICAgICAgICAgICAgIHRocm93IGVycjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgaGFzaGVzID0gYXdhaXQgZ2V0QWN0aW9uKGNsaWVudCwgZ2V0RmlsdGVyQ2hhbmdlcywgImdldEZpbHRlckNoYW5nZXMiKSh7IGZpbHRlciB9KTsKICAgICAgICAgICAgaWYgKGhhc2hlcy5sZW5ndGggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoYmF0Y2gpCiAgICAgICAgICAgICAgZW1pdC5vblRyYW5zYWN0aW9ucyhoYXNoZXMpOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgZm9yIChjb25zdCBoYXNoMyBvZiBoYXNoZXMpCiAgICAgICAgICAgICAgICBlbWl0Lm9uVHJhbnNhY3Rpb25zKFtoYXNoM10pOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGVtaXQub25FcnJvcj8uKGVycik7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAgZW1pdE9uQmVnaW46IHRydWUsCiAgICAgICAgICBpbnRlcnZhbDogcG9sbGluZ0ludGVydmFsCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIGFzeW5jICgpID0+IHsKICAgICAgICAgIGlmIChmaWx0ZXIpCiAgICAgICAgICAgIGF3YWl0IGdldEFjdGlvbihjbGllbnQsIHVuaW5zdGFsbEZpbHRlciwgInVuaW5zdGFsbEZpbHRlciIpKHsgZmlsdGVyIH0pOwogICAgICAgICAgdW53YXRjaCgpOwogICAgICAgIH07CiAgICAgIH0pOwogICAgfTsKICAgIGNvbnN0IHN1YnNjcmliZVBlbmRpbmdUcmFuc2FjdGlvbnMgPSAoKSA9PiB7CiAgICAgIGxldCBhY3RpdmUgPSB0cnVlOwogICAgICBsZXQgdW5zdWJzY3JpYmUgPSAoKSA9PiBhY3RpdmUgPSBmYWxzZTsKICAgICAgKGFzeW5jICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgeyB1bnN1YnNjcmliZTogdW5zdWJzY3JpYmVfIH0gPSBhd2FpdCBjbGllbnQudHJhbnNwb3J0LnN1YnNjcmliZSh7CiAgICAgICAgICAgIHBhcmFtczogWyJuZXdQZW5kaW5nVHJhbnNhY3Rpb25zIl0sCiAgICAgICAgICAgIG9uRGF0YShkYXRhKSB7CiAgICAgICAgICAgICAgaWYgKCFhY3RpdmUpCiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSBkYXRhLnJlc3VsdDsKICAgICAgICAgICAgICBvblRyYW5zYWN0aW9ucyhbdHJhbnNhY3Rpb25dKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJv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wga2V5ID0gIndlYlNvY2tldCIsIG5hbWUgPSAiV2ViU29ja2V0IEpTT04tUlBDIiwgcmVjb25uZWN0LCByZXRyeURlbGF5IH0gPSBjb25maWc7CiAgICByZXR1cm4gKHsgY2hhaW4sIHJldHJ5Q291bnQ6IHJldHJ5Q291bnRfLCB0aW1lb3V0OiB0aW1lb3V0XyB9KSA9PiB7CiAgICAgIGNvbnN0IHJldHJ5Q291bnQgPSBjb25maWcucmV0cnlDb3VudCA/PyByZXRyeUNvdW50XzsKICAgICAgY29uc3QgdGltZW91dCA9IHRpbWVvdXRfID8/IGNvbmZpZy50aW1lb3V0ID8/IDFlNDsKICAgICAgY29uc3QgdXJsXyA9IHVybCB8fCBjaGFpbj8ucnBjVXJscy5kZWZhdWx0LndlYlNvY2tldD8uWzBdOwogICAgICBpZiAoIXVybF8pCiAgICAgICAgdGhyb3cgbmV3IFVybFJlcXVpcmVkRXJyb3IoKTsKICAgICAgcmV0dXJuIGNyZWF0ZVRyYW5zcG9ydCh7CiAgICAgICAga2V5LAogICAgICAgIG5hbWUsCiAgICAgICAgYXN5bmMgcmVxdWVzdCh7IG1ldGhvZCwgcGFyYW1zIH0pIHsKICAgICAgICAgIGNvbnN0IGJvZHkgPSB7IG1ldGhvZCwgcGFyYW1zIH07CiAgICAgICAgICBjb25zdCBycGNDbGllbnQgPSBhd2FpdCBnZXRXZWJTb2NrZXRScGNDbGllbnQodXJsXywgewogICAgICAgICAgICBrZWVwQWxpdmUsCiAgICAgICAgICAgIHJlY29ubmVjdAogICAgICAgICAgfSk7CiAgICAgICAgICBjb25zdCB7IGVycm9yLCByZXN1bHQgfSA9IGF3YWl0IHJwY0NsaWVudC5yZXF1ZXN0QXN5bmMoewogICAgICAgICAgICBib2R5LAogICAgICAgICAgICB0aW1lb3V0CiAgICAgICAgICB9KTsKICAgICAgICAgIGlmIChlcnJvcikKICAgICAgICAgICAgdGhyb3cgbmV3IFJwY1JlcXVlc3RFcnJvcih7CiAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICBlcnJvciwKICAgICAgICAgICAgICB1cmw6IHVybF8KICAgICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0sCiAgICAgICAgcmV0cnlDb3VudCwKICAgICAgICByZXRyeURlbGF5LAogICAgICAgIHRpbWVvdXQsCiAgICAgICAgdHlwZTogIndlYlNvY2tldCIKICAgICAgfSwgewogICAgICAgIGdldFNvY2tldCgpIHsKICAgICAgICAgIHJldHVybiBnZXRTb2NrZXQodXJsXyk7CiAgICAgICAgfSwKICAgICAgICBnZXRScGNDbGllbnQoKSB7CiAgICAgICAgICByZXR1cm4gZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgIH0sCiAgICAgICAgYXN5bmMgc3Vic2NyaWJlKHsgcGFyYW1zLCBvbkRhdGEsIG9uRXJyb3IgfSkgewogICAgICAgICAgY29uc3QgcnBjQ2xpZW50ID0gYXdhaXQgZ2V0V2ViU29ja2V0UnBjQ2xpZW50KHVybF8pOwogICAgICAgICAgY29uc3QgeyByZXN1bHQ6IHN1YnNjcmlwdGlvbklkIH0gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiBycGNDbGllbnQucmVxdWVzdCh7CiAgICAgICAgICAgIGJvZHk6IHsKICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfc3Vic2NyaWJlIiwKICAgICAgICAgICAgICBwYXJhbXMKICAgICAgICAgICAgfSwKICAgICAgICAgICAgb25FcnJvcihlcnJvcikgewogICAgICAgICAgICAgIHJlamVjdChlcnJvcik7CiAgICAgICAgICAgICAgb25FcnJvcj8uKGVycm9yKTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIG9uUmVzcG9uc2UocmVzcG9uc2UpIHsKICAgICAgICAgICAgICBpZiAocmVzcG9uc2UuZXJyb3IpIHsKICAgICAgICAgICAgICAgIHJlamVjdChyZXNwb25zZS5lcnJvcik7CiAgICAgICAgICAgICAgICBvbkVycm9yPy4ocmVzcG9uc2UuZXJyb3IpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc3BvbnNlLmlkID09PSAibnVtYmVyIikgewogICAgICAgICAgICAgICAgcmVzb2x2ZShyZXNwb25zZSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChyZXNwb25zZS5tZXRob2QgIT09ICJldGhfc3Vic2NyaXB0aW9uIikKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICBvbkRhdGEocmVzcG9uc2UucGFyYW1zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgc3Vic2NyaXB0aW9uSWQsCiAgICAgICAgICAgIGFzeW5jIHVuc3Vic2NyaWJlKCkgewogICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4gcnBjQ2xpZW50LnJlcXVlc3QoewogICAgICAgICAgICAgICAgYm9keTogewogICAgICAgICAgICAgICAgICBtZXRob2Q6ICJldGhfdW5zdWJzY3JpYmUiLAogICAgICAgICAgICAgICAgICBwYXJhbXM6IFtzdWJzY3JpcHRpb25JZF0KICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBvblJlc3BvbnNlOiByZXNvbHZlCiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgfSk7CiAgICB9OwogIH0KCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2luZGV4LmpzCiAgaW5pdF9hYmlzKCk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEu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hdHVyZUhleCkgewogICAgY29uc3QgeyByLCBzIH0gPSBzZWNwMjU2azEuU2lnbmF0dXJlLmZyb21Db21wYWN0KHNpZ25hdHVyZUhleC5zbGljZSgyLCAxMzApKTsKICAgIGNvbnN0IHlQYXJpdHlPclYgPSBOdW1iZXIoYDB4JHtzaWduYXR1cmVIZXguc2xpY2UoMTMwKX1gKTsKICAgIGNvbnN0IFt2LCB5UGFyaXR5XSA9ICgoKSA9PiB7CiAgICAgIGlmICh5UGFyaXR5T3JWID09PSAwIHx8IHlQYXJpdHlPclYgPT09IDEpCiAgICAgICAgcmV0dXJuIFt2b2lkIDAsIHlQYXJpdHlPclZdOwogICAgICBpZiAoeVBhcml0eU9yViA9PT0gMjcpCiAgICAgICAgcmV0dXJuIFtCaWdJbnQoeVBhcml0eU9yViksIDBdOwogICAgICBpZiAoeVBhcml0eU9yViA9PT0gMjgpCiAgICAgICAgcmV0dXJuIFtCaWdJbnQoeVBhcml0eU9yViksIDFdOwogICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgeVBhcml0eU9yViB2YWx1ZSIpOwogICAgfSkoKTsKICAgIGlmICh0eXBlb2YgdiAhPT0gInVuZGVmaW5lZCIpCiAgICAgIHJldHVybiB7CiAgICAgICAgcjogbnVtYmVyVG9IZXgociwgeyBzaXplOiAzMiB9KSwKICAgICAgICBzOiBudW1iZXJUb0hleChzLCB7IHNpemU6IDMyIH0pLAogICAgICAgIHYsCiAgICAgICAgeVBhcml0eQogICAgICB9OwogICAgcmV0dXJuIHsKICAgICAgcjogbnVtYmVyVG9IZXgociwgeyBzaXplOiAzMiB9KSwKICAgICAgczogbnVtYmVyVG9IZXgocywgeyBzaXplOiAzMiB9KSwKICAgICAgeVBhcml0eQogICAgfTsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS91dGlscy9zaWduYXR1cmUvcmVjb3ZlclRyYW5zYWN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pcHQ6IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVUcmFuc2FjdGlvblJlY2VpcHQoewogICAgICBmb3JtYXQoYXJncykgewogICAgICAgIHJldHVybiB7CiAgICAgICAgICBsMUJhdGNoTnVtYmVyOiBhcmdzLmwxQmF0Y2hOdW1iZXIgPyBoZXhUb0JpZ0ludChhcmdzLmwxQmF0Y2hOdW1iZXIpIDogbnVsbCwKICAgICAgICAgIGwxQmF0Y2hUeEluZGV4OiBhcmdzLmwxQmF0Y2hUeEluZGV4ID8gaGV4VG9CaWdJbnQoYXJncy5sMUJhdGNoVHhJbmRleCkgOiBudWxsLAogICAgICAgICAgbG9nczogYXJncy5sb2dzLm1hcCgobG9nKSA9PiB7CiAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgLi4uZm9ybWF0TG9nKGxvZyksCiAgICAgICAgICAgICAgbDFCYXRjaE51bWJlcjogbG9nLmwxQmF0Y2hOdW1iZXIgPyBoZXhUb0JpZ0ludChsb2cubDFCYXRjaE51bWJlcikgOiBudWxsLAogICAgICAgICAgICAgIHRyYW5zYWN0aW9uTG9nSW5kZXg6IGhleFRvTnVtYmVyKGxvZy50cmFuc2FjdGlvbkxvZ0luZGV4KSwKICAgICAgICAgICAgICBsb2dUeXBlOiBsb2cubG9nVHlwZQogICAgICAgICAgICB9OwogICAgICAgICAgfSksCiAgICAgICAgICBsMlRvTDFMb2dzOiBhcmdzLmwyVG9MMUxvZ3MubWFwKChsMlRvTDFMb2cpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICBibG9ja051bWJlcjogaGV4VG9CaWdJbnQobDJUb0wxTG9nLmJsb2NrSGFzaCksCiAgICAgICAgICAgICAgYmxvY2tIYXNoOiBsMlRvTDFMb2cuYmxvY2tIYXNoLAogICAgICAgICAgICAgIGwxQmF0Y2hOdW1iZXI6IGhleFRvQmlnSW50KGwyVG9MMUxvZy5sMUJhdGNoTnVtYmVyKSwKICAgICAgICAgICAgICB0cmFuc2FjdGlvbkluZGV4OiBoZXhUb0JpZ0ludChsMlRvTDFMb2cudHJhbnNhY3Rpb25JbmRleCksCiAgICAgICAgICAgICAgc2hhcmRJZDogaGV4VG9CaWdJbnQobDJUb0wxTG9nLnNoYXJkSWQpLAogICAgICAgICAgICAgIGlzU2VydmljZTogbDJUb0wxTG9nLmlzU2VydmljZSwKICAgICAgICAgICAgICBzZW5kZXI6IGwyVG9MMUxvZy5zZW5kZXIsCiAgICAgICAgICAgICAga2V5OiBsMlRvTDFMb2cua2V5LAogICAgICAgICAgICAgIHZhbHVlOiBsMlRvTDFMb2cudmFsdWUsCiAgICAgICAgICAgICAgdHJhbnNhY3Rpb25IYXNoOiBsMlRvTDFMb2cudHJhbnNhY3Rpb25IYXNoLAogICAgICAgICAgICAgIGxvZ0luZGV4OiBoZXhUb0JpZ0ludChsMlRvTDFMb2cubG9nSW5kZXgpCiAgICAgICAgICAgIH07CiAgICAgICAgICB9KQogICAgICAgIH07CiAgICAgIH0KICAgIH0pLAogICAgdHJhbnNhY3Rpb25SZXF1ZXN0OiAvKiBAX19QVVJFX18gKi8gZGVmaW5lVHJhbnNhY3Rpb25SZXF1ZXN0KHsKICAgICAgZXhjbHVkZTogWwogICAgICAgICJjdXN0b21TaWduYXR1cmUiLAogICAgICAgICJmYWN0b3J5RGVwcyIsCiAgICAgICAgImdhc1BlclB1YmRhdGEiLAogICAgICAgICJwYXltYXN0ZXIiLAogICAgICAgICJwYXltYXN0ZXJJbnB1dCIKICAgICAgXSwKICAgICAgZm9ybWF0KGFyZ3MpIHsKICAgICAgICBpZiAoYXJncy5nYXNQZXJQdWJkYXRhIHx8IGFyZ3MucGF5bWFzdGVyICYmIGFyZ3MucGF5bWFzdGVySW5wdXQgfHwgYXJncy5mYWN0b3J5RGVwcyB8fCBhcmdzLmN1c3RvbVNpZ25hdHVyZSkKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIGVpcDcxMk1ldGE6IHsKICAgICAgICAgICAgICAuLi5hcmdzLmdhc1BlclB1YmRhdGEgPyB7IGdhc1BlclB1YmRhdGE6IHRvSGV4KGFyZ3MuZ2FzUGVyUHViZGF0YSkgfSA6IHsgZ2FzUGVyUHViZGF0YTogdG9IZXgoZ2FzUGVyUHViZGF0YURlZmF1bHQpIH0sCiAgICAgICAgICAgICAgLi4uYXJncy5wYXltYXN0ZXIgJiYgYXJncy5wYXltYXN0ZXJJbnB1dCA/IHsKICAgICAgICAgICAgICAgIHBheW1hc3RlclBhcmFtczogewogICAgICAgICAgICAgICAgICBwYXltYXN0ZXI6IGFyZ3MucGF5bWFzdGVyLAogICAgICAgICAgICAgICAgICBwYXltYXN0ZXJJbnB1dDogQXJyYXkuZnJvbShoZXhUb0J5dGVzKGFyZ3MucGF5bWFzdGVySW5wdXQpKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0gOiB7fSwKICAgICAgICAgICAgICAuLi5hcmdzLmZhY3RvcnlEZXBzID8gewogICAgICAgICAgICAgICAgZmFjdG9yeURlcHM6IGFyZ3MuZmFjdG9yeURlcHMubWFwKChkZXApID0+IEFycmF5LmZyb20oaGV4VG9CeXRlcyhkZXApKSkKICAgICAgICAgICAgICB9IDoge30sCiAgICAgICAgICAgICAgLi4uYXJncy5jdXN0b21TaWduYXR1cmUgPyB7CiAgICAgICAgICAgICAgICBjdXN0b21TaWduYXR1cmU6IEFycmF5LmZyb20oaGV4VG9CeXRlcyhhcmdzLmN1c3RvbVNpZ25hdHVyZSkpCiAgICAgICAgICAgICAgfSA6IHt9CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHR5cGU6ICIweDcxIgogICAgICAgICAgfTsKICAgICAgICByZXR1cm4ge307CiAgICAgIH0KICAgIH0pCiAgfTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL3prc3luYy9zZXJpYWxpemVycy5qcwogIGluaXRfY29uY2F0KCk7CiAga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BpZiAoZm9ybWF0dGVkLnR5cGVIZXggPT09ICIweDdlIikgewogICAgICAgICAgICBmb3JtYXR0ZWQuaXNTeXN0ZW1UeCA9IHRyYW5zYWN0aW9uLmlzU3lzdGVtVHg7CiAgICAgICAgICAgIGZvcm1hdHRlZC5taW50ID0gdHJhbnNhY3Rpb24ubWludCA/IGhleFRvQmlnSW50KHRyYW5zYWN0aW9uLm1pbnQpIDogdm9pZCAwOwogICAgICAgICAgICBmb3JtYXR0ZWQuc291cmNlSGFzaCA9IHRyYW5zYWN0aW9uLnNvdXJjZUhhc2g7CiAgICAgICAgICAgIGZvcm1hdHRlZC50eXBlID0gImRlcG9zaXQiOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGZvcm1hdHRlZDsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgdHJhbnNhY3Rpb25zLAogICAgICAgICAgc3RhdGVSb290OiBhcmdzLnN0YXRlUm9vdAogICAgICAgIH07CiAgICAgIH0KICAgIH0pLAogICAgdHJhbnNhY3Rpb246IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVUcmFuc2FjdGlvbih7CiAgICAgIGZvcm1hdChhcmdzKSB7CiAgICAgICAgY29uc3QgdHJhbnNhY3Rpb24gPSB7fTsKICAgICAgICBpZiAoYXJncy50eXBlID09PSAiMHg3ZSIpIHsKICAgICAgICAgIHRyYW5zYWN0aW9uLmlzU3lzdGVtVHggPSBhcmdzLmlzU3lzdGVtVHg7CiAgICAgICAgICB0cmFuc2FjdGlvbi5taW50ID0gYXJncy5taW50ID8gaGV4VG9CaWdJbnQoYXJncy5taW50KSA6IHZvaWQgMDsKICAgICAgICAgIHRyYW5zYWN0aW9uLnNvdXJjZUhhc2ggPSBhcmdzLnNvdXJjZUhhc2g7CiAgICAgICAgICB0cmFuc2FjdGlvbi50eXBlID0gImRlcG9zaXQiOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJhbnNhY3Rpb247CiAgICAgIH0KICAgIH0pL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ogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkFzdGFyIHprRVZNIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2FzdGFyLXprZXZtLmV4cGxvcmVyLnN0YXJ0YWxlLmNvbSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiA5MzUyOAogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9hc3RhclpreW90by5qcwogIHZhciBhc3RhclpreW90byA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNjAzODM2MSwKICAgIG5hbWU6ICJBc3RhciB6a0VWTSBUZXN0bmV0IHpLeW90byIsCiAgICBuZXR3b3JrOiAiekt5b3RvIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5zdGFydGFsZS5jb20vemt5b3RvIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiekt5b3RvIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3preW90by5leHBsb3Jlci5zdGFydGFsZS5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgb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wKICAgICAgbmFtZTogIkJOQiIsCiAgICAgIHN5bWJvbDogIkJOQiIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL3JwYy5hbmtyLmNvbS9ic2MiXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJCc2NTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2JzY3NjYW4uY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS5ic2NzY2FuLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTU5MjE0NTIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2JzY0dyZWVuZmllbGQuanMKICB2YXIgYnNjR3JlZW5maWVsZCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMTAxNywKICAgIG5hbWU6ICJCTkIgR3JlZW5maWVsZCBDaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJCTkIiLAogICAgICBzeW1ib2w6ICJCTkIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ncmVlbmZpZWxkLWNoYWluLmJuYmNoYWluLm9yZyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7C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dHJhbnNhY3Rpb24uZ2F0ZXdheUZlZVJlY2lwaWVudAogICAgICAgICAgICB9IDoge30sCiAgICAgICAgICAgIGZlZUN1cnJlbmN5OiB0cmFuc2FjdGlvbi5mZWVDdXJyZW5jeQogICAgICAgICAgfTsKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgdHJhbnNhY3Rpb25zLAogICAgICAgICAgLi4uYXJncy5yYW5kb21uZXNzID8geyByYW5kb21uZXNzOiBhcmdzLnJhbmRvbW5lc3MgfSA6IHt9CiAgICAgICAgfTsKICAgICAgfQogICAgfSksCiAgICB0cmFuc2FjdGlvbjogLyogQF9fUFVSRV9fICovIGRlZmluZVRyYW5zYWN0aW9uKHsKICAgICAgZm9ybWF0KGFyZ3MpIHsKICAgICAgICBpZiAoYXJncy50eXBlID09PSAiMHg3ZSIpCiAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICBpc1N5c3RlbVR4OiBhcmdzLmlzU3lzdGVtVHgsCiAgICAgICAgICAgIG1pbnQ6IGFyZ3MubWludCA/IGhleFRvQmlnSW50KGFyZ3MubWludCkgOiB2b2lkIDAsCiAgICAgICAgICAgIHNvdXJjZUhhc2g6IGFyZ3Muc291cmNlSGFzaCwKICAgICAgICAgICAgdHlwZTogImRlcG9zaXQiCiAgICAgICAgICB9OwogICAgICAgIGNvbnN0IHRyYW5zYWN0aW9uID0geyBmZWVDdXJyZW5jeTogYXJncy5mZWVDdXJyZW5jeSB9OwogICAgICAgIGlmIChhcmdzLnR5cGUgPT09ICIweDdiIikKICAgICAgICAgIHRyYW5zYWN0aW9uLnR5cGUgPSAiY2lwNjQiOwogICAgICAgIGVsc2UgewogICAgICAgICAgaWYgKGFyZ3MudHlwZSA9PT0gIjB4N2MiKQogICAgICAgICAgICB0cmFuc2FjdGlvbi50eXBlID0gImNpcDQyIjsKICAgICAgICAgIHRyYW5zYWN0aW9uLmdhdGV3YXlGZWUgPSBhcmdzLmdhdGV3YXlGZWUgPyBoZXhUb0J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bGZham9yZXMgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vY2Vsby1hbGZham9yZXMuYmxvY2tzY291dC5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vY2Vsby1hbGZham9yZXMuYmxvY2tzY291dC5jb20vYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMy5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDE0NTY5MDAxCiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDEzXTogewogICAgICAgICAgYWRkcmVzczogIjB4ODI1MjczNTM5MjdkOEQwNjliM0I0NTI5MDRjOTQyZEExNDlCQTM4MSIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDI0MTEzMjQKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGRpc3B1dGVHYW1lRmFjdG9yeTogewogICAgICAgIFtzb3VyY2VJZDEzXTogewogICAgICAgICAgYWRkcmVzczogIjB4RTI4QUFkY2Q5ODgzNzQ2YzBlNTA2OEY1OGY5ZWEwNjAyN2IyMTRjYiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDI0MTEzMjQKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwyT3V0cHV0T3JhY2xlOiB7CiAgICAgICAgW3NvdXJjZUlkMTNdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHg0YTI2MzVlOWU0ZjZlNDU4MTdiMUQ0MDJhYzQ5MDRjMWQxNzUyNDM4IiwKICAgICAgICAgIGJsb2NrQ3JlYXRlZDogMjQxMTMyNAogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3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DaGlsaXogQ2hhaW4iLAogICAgbmV0d29yazogImNoaWxpei1jaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJDSFoiLAogICAgICBzeW1ib2w6ICJDSFoiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vcnBjLmFua3IuY29tL2NoaWxpeiIsCiAgICAgICAgICAiaHR0cHM6Ly9jaGlsaXotcnBjLnB1YmxpY25vZGUuY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiQ2hpbGl6IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3NjYW4uY2hpbGl6LmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9zY2FuLmNoaWxpei5jb20vYXBpIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvY2hpcHMuanMKICB2YXIgY2hpcHMgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDI4ODIsCiAgICBuYW1lOiAiQ2hpcHMgTmV0d29yayIsCiAgICBuZXR3b3JrOiAiQ0hJUFMiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiSU9UQSIsCiAgICAgIHN5bWJvbDogIklPVEEiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vbm9kZS5jaGlwcy5vb28vd2FzcC9hcG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iaHR0cHM6Ly9ycGMuZG9nZWNoYWluLmRvZyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkRvZ2VDaGFpbkV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLmRvZ2VjaGFpbi5kb2ciLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuZG9nZWNoYWluLmRvZy9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweDY4YTg2MDlhNjBhMDA4RUZBNjMzZGZkZWM1OTJjMDNCMDMwY0M1MDgiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjUzODQwMzEKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2Rvc0NoYWluLmpzCiAgdmFyIGRvc0NoYWluID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA3OTc5LAogICAgbmFtZTogIkRPUyBDaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJET1MgQ2hhaW4iLAogICAgICBzeW1ib2w6ICJET1MiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9tYWluLmRvc2NoYWluLmNvbSJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkRPUyBDaGFpbiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9kb3NjYW4uaW8iLAogICAgICAgIGFwaVVybDog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pYyBPcGVuIFRlc3RuZXQiLAogICAgbmV0d29yazogImZhbnRvbS1zb25pYy10ZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkZhbnRvbSIsCiAgICAgIHN5bWJvbDogIkZUTSIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL3JwY2FwaS5zb25pYy5mYW50b20ubmV0d29yayJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZhbnRvbSBTb25pYyBPcGVuIFRlc3RuZXQgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vcHVibGljLXNvbmljLmZhbnRvbS5uZXR3b3JrIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2ZhbnRvbVRlc3RuZXQuanMKICB2YXIgZmFudG9tVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogNDAwMiwKICAgIG5hbWU6ICJGYW50b20gVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJGYW50b20iLAogICAgICBzeW1ib2w6ICJGVE0iCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9ycGMudGVzdG5ldC5mYW50b20ubmV0d29yayJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkZUTVNjYW4iLAogICAgICAg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ih7CiAgICBpZDogMTE0LAogICAgbmFtZTogIkZsYXJlIFRlc3RuZXQgQ29zdG9uMiIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJDb3N0b24yIEZsYXJlIiwKICAgICAgc3ltYm9sOiAiQzJGTFIiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9jb3N0b24yLWFwaS5mbGFyZS5uZXR3b3JrL2V4dC9DL3JwYyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkNvc3RvbjIgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vY29zdG9uMi1leHBsb3Jlci5mbGFyZS5uZXR3b3JrIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2Nvc3RvbjItZXhwbG9yZXIuZmxhcmUubmV0d29yay9hcGkiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvZmxvd01haW5uZXQuanMKICB2YXIgZmxvd01haW5uZXQgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDc0NywKICAgIG5hbWU6ICJGbG93RVZNIE1haW5uZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRmxvdyIsCiAgICAgIHN5bWJvbDogIkZMT1ciCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL21haW5uZXQuZXZtLm5vZGVzLm9uZmxvdy5vcmciXQogICAgICB9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Bub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2dhcm5ldC5qcwogIHZhciBzb3VyY2VJZDE4ID0gMTdlMzsKICB2YXIgZ2FybmV0ID0gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgbmFtZTogIkdhcm5ldCBUZXN0bmV0IiwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBpZDogMTcwNjksCiAgICBzb3VyY2VJZDogc291cmNlSWQxOCwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5nYXJuZXRjaGFpbi5jb20iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vcnBjLmdhcm5ldGNoYWluLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIuZ2FybmV0Y2hhaW4uY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQxOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDU3ZWU0MDU4NmZiRTI4NkFmQzc1RTY3Y2I2OTUxMUE2RDlhRjU5MDkiLAogICAgICAgICAgYm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ICAgaHR0cDogWyJodHRwczovL21haW5uZXQuaGFzaGlvLmlvL2FwaSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkhhc2hzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2hhc2hzY2FuLmlvL21haW5uZXQiCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiBmYWxzZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2hlZGVyYVByZXZpZXduZXQuanMKICB2YXIgaGVkZXJhUHJldmlld25ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMjk3LAogICAgbmFtZTogIkhlZGVyYSBQcmV2aWV3bmV0IiwKICAgIG5ldHdvcms6ICJoZWRlcmEtcHJldmlld25ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBzeW1ib2w6ICJIQkFSIiwKICAgICAgbmFtZTogIkhCQVIiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcHJldmlld25ldC5oYXNoaW8uaW8vYXBpIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSGFzaHNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vaGFzaHNjYW4uaW8vcHJldmlld25ldCIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpb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ZmF1bHQ6IHsgaHR0cDogWyJodHRwczovL3JwYy5oeWNoYWluLmNvbS9odHRwIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSFlDSEFJTiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly90ZXN0bmV0LXJwYy5oeWNoYWluLmNvbS9odHRwIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2ltbXV0YWJsZVprRXZtLmpzCiAgdmFyIGltbXV0YWJsZVprRXZtID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMzM3MSwKICAgIG5hbWU6ICJJbW11dGFibGUgemtFVk0iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiSW1tdXRhYmxlIENvaW4iLAogICAgICBzeW1ib2w6ICJJTVgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5pbW11dGFibGUuY29tIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiSW1tdXRhYmxlIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLmltbXV0YWJsZS5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuaW1tdXRhYmxlLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6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cnBjLmtpbnRvLnh5ei9odHRwIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiS2ludG8gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIua2ludG8ueHl6IgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogZmFsc2UKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9rbGF5dG4uanMKICB2YXIga2xheXRuID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiA4MjE3LAogICAgbmFtZTogIktsYXl0biIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJLbGF5dG4iLAogICAgICBzeW1ib2w6ICJLTEFZIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcHVibGljLWVuLWN5cHJlc3Mua2xheXRuLm5ldCJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIktsYXl0blNjb3BlIiwKICAgICAgICB1cmw6ICJodHRwczovL3Njb3BlLmtsYXl0bi5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogOTYwMDI0MTUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2thaWEuanMKICB2YXIga2FpYSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODIxNywKICAgIG5hbWU6ICJLYWlhIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkthaWEiLAogICAgICBzeW1ib2w6ICJLQUlBIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcHVibGljLWVuLm5vZGUua2FpYS5pbyJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkthaWFTY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL2thaWFzY2FuLmlvIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2FwaS1jeXByZXNzLmtsYXl0bnNjb3BlLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogOTYwMDI0MTUKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2thaXJvcy5qcwogIHZhciBrYWlyb3MgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEwMDEsCiAgICBuYW1lOiAiS2Fpcm9zIFRlc3RuZXQiLAogICAgbmV0d29yazogImthaXJvcyIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgs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H0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIktsYXl0blNjb3BlIiwKICAgICAgICB1cmw6ICJodHRwczovL2Jhb2JhYi5rbGF5dG5zY29wZS5jb20iCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTIzMzkwNTkzCiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlCiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMva29pLmpzCiAgdmFyIGtvaSA9IGRlZmluZUNoYWluKHsKICAgIGlkOiA3MDEsCiAgICBuYW1lOiAiS29pIE5ldHdvcmsiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiS29pIE5ldHdvcmsgTmF0aXZlIFRva2VuIiwKICAgICAgc3ltYm9sOiAiS1JJTkciCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2tvaS1ycGMuZGFyd2luaWEubmV0d29yayJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly9rb2ktcnBjLmRhcndpbmlhLm5ldHdvcmsiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogeyBuYW1lOiAiQmxvY2tzY291dCIsIHVybDogImh0dHBzOi8va29pLXNjYW4uZGFyd2luaWEubmV0d29yayIgfQogICAgfSwKICAgIGNvbnRyYWN0czogew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HByaW9yaXR5RmVlUGVyR2FzKQogICAgICB9OwogICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgIHRocm93IGdldENhbGxFcnJvcihlcnIsIHsKICAgICAgICAuLi5hcmdzLAogICAgICAgIGFjY291bnQsCiAgICAgICAgY2hhaW46IGNsaWVudC5jaGFpbgogICAgICB9KTsKICAgIH0KICB9CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9saW5lYS9jaGFpbkNvbmZpZy5qcwogIHZhciBjaGFpbkNvbmZpZzQgPSB7CiAgICBmZWVzOiB7CiAgICAgIGVzdGltYXRlRmVlc1BlckdhczogZXN0aW1hdGVGZWVzUGVyR2FzMiwKICAgICAgYXN5bmMgbWF4UHJpb3JpdHlGZWVQZXJHYXMoeyBibG9jaywgY2xpZW50LCByZXF1ZXN0IH0pIHsKICAgICAgICBjb25zdCByZXNwb25zZSA9IGF3YWl0IGVzdGltYXRlRmVlc1BlckdhczIoewogICAgICAgICAgYmxvY2ssCiAgICAgICAgICBjbGllbnQsCiAgICAgICAgICBtdWx0aXBseTogKHgpID0+IHgsCiAgICAgICAgICByZXF1ZXN0LAogICAgICAgICAgdHlwZTogImVpcDE1NTkiCiAgICAgICAgfSk7CiAgICAgICAgaWYgKCFyZXNwb25zZT8ubWF4UHJpb3JpdHlGZWVQZXJHYXMpCiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICByZXR1cm4gcmVzcG9uc2UubWF4UHJpb3JpdHlGZWVQZXJHYXM7CiAgICAgIH0KICAgIH0KICB9OwogIGFzeW5jIGZ1bmN0aW9uIGVzdGltYXRlRmVlc1BlckdhczIoeyBjbGllbnQsIG11bHRpcGx5LCByZXF1ZXN0LCB0eXBlIH0pIHsKICAgIHRyeSB7CiAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZXN0aW1hdGVHYXMyKGNsaWVudCwgewogICAgICAgIC4uLnJlc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ogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDQ5ODYyMwogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2xpc2suanMKICB2YXIgc291cmNlSWQxOSA9IDE7CiAgdmFyIGxpc2sgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDExMzUsCiAgICBuYW1lOiAiTGlzayIsCiAgICBuZXR3b3JrOiAibGlzayIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFdGhlciIsCiAgICAgIHN5bWJvbDogIkVUSCIKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLmFwaS5saXNrLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vYmxvY2tzY291dC5saXNrLmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9ibG9ja3Njb3V0Lmxpc2suY29tL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIj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gcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5zZXBvbGlhLWFwaS5saXNrLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vc2Vwb2xpYS1ibG9ja3Njb3V0Lmxpc2suY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3NlcG9saWEtYmxvY2tzY291dC5saXNrLmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyMF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEEwRTM1RjU2QzMxOERFMWJENUQ5Y2E2QTk0RmU3ZTM3QzU2NjMzNDgiCiAgICAgICAgfQogICAgICB9LAogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y2ExMWJkZTA1OTc3YjM2MzExNjcwMjg4NjJiZTJhMTczOTc2Y2ExMSIKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjBdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhlM2Q5MEYyMTQ5MDY4NkVjN2VGMzdCRTc4OEUwMmRmQzEyNzg3MjY0IgogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDIwXTogewogICAgICAgICAgYWRkcmVzczogIjB4MUZiMzBlNDQ2ZUE3OTFjZDFmMDExNjc1RTVGM2Y1MzExYjcwZmFGNSIKICAgICAgICB9CiAgICAgIH0KICAgIH0sCiAgICB0ZXN0bmV0OiB0cnVlLAogICAgc291cmNl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YWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vZXUtd2VzdC5seWNhbmNoYWluLmNvbSIsCiAgICAgICAgICAid3NzOi8vYXNpYS1zb3V0aGVhc3QubHljYW5jaGFpbi5jb20iCiAgICAgICAgXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJMeWNhbiBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5seWNhbmNoYWluLmNvbSIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL2x5cmEuanMKICB2YXIgbHlyYSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogOTU3LAogICAgbmFtZTogIkx5cmEgQ2hhaW4iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkV0aGVyIiwgc3ltYm9sOiAiRVRIIiwgZGVjaW1hbHM6IDE4IH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vcnBjLmx5cmEuZmluYW5jZSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIkx5cmEgRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubHlyYS5maW5hbmNlIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL2V4cGxvcmVyLmx5cmEuZmluYW5jZS9hcGkvdjIiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxM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ICJNZXRhQ2hhaW4gTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiTWV0YXRpbWUgQ29pbiIsIHN5bWJvbDogIk1UQyIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5tZXRhdGltZS5jb20iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJNZXRhRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXIubWV0YXRpbWUuY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAzMDAxIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDAKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21ldGFjaGFpbklzdGFuYnVsLmpzCiAgdmFyIG1ldGFjaGFpbklzdGFuYnVsID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxNDUzLAogICAgbmFtZTogIk1ldGFDaGFpbiBJc3RhbmJ1bCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiTWV0YXRpbWUgQ29pbiIsIHN5bWJvbDogIk1UQyIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL2lzdGFuYnVsLXJwYy5tZXRhY2hhaW4uZGV2Il0KICAgICAgfQogICAgfSwKICAgIGJs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g2LAogICAgbmFtZTogIk1pbnQgU2Vwb2xpYSBUZXN0bmV0IiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3Rlc3RuZXQtcnBjLm1pbnRjaGFpbi5pbyJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1pbnRjaGFpbiBUZXN0bmV0IGV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL3Rlc3RuZXQtZXhwbG9yZXIubWludGNoYWluLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21vZGUuanMKICB2YXIgc291cmNlSWQyMiA9IDE7CiAgdmFyIG1vZGUgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDM0NDQzLAogICAgbmFtZTogIk1vZGUgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tYWlubmV0Lm1vZGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIk1vZGVzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL21vZGVz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tb29uc2Nhbi5pby9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMTg1MDY4NgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL21vb25iZWFtLmpzCiAgdmFyIG1vb25iZWFtID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMjg0LAogICAgbmFtZTogIk1vb25iZWFtIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIkdMTVIiLAogICAgICBzeW1ib2w6ICJHTE1SIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tb29uYmVhbS5wdWJsaWMuYmxhc3RhcGkuaW8iXSwKICAgICAgICB3ZWJTb2NrZXQ6IFsid3NzOi8vbW9vbmJlYW0ucHVibGljLmJsYXN0YXBpLmlvIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiTW9vbnNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vbW9vbnNjYW4uaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLW1vb25iZWFtLm1vb25zY2FuLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmV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29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIC4uLmNoYWluQ29uZmlnMi5jb250cmFjdHMsCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJFMmExNzM5NzZDQTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDM3MDUxMDgKICAgICAgfSwKICAgICAgbDJPdXRwdXRPcmFjbGU6IHsKICAgICAgICBbc291cmNlSWQyNV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweEZmMjM5NEJiODQzMDEyNTYyZjQzNDlDNjYzMmEwRWNCOTJmQzg4MTAiCiAgICAgICAgfQogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQyNV06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDQzODZDOEFCZjIwMDlhQzBjMjYzNDYyRGE1NjhERDlkNDZlNTJhMzEiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMjVdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHg2NzczMTFGZDJjQ2M1MTFCYmMwZjU4MUU4ZDlhMDdCMDMzRDVFODQwIgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQyNQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL29wdGltaXNtLmpzCiAgdmFyIHNvdXJjZUlkMjYgPSAxOwogIHZhciBvcHRpbWlzbSA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICAuLi5jaGFpbkNvbmZpZzIsCiAgICBpZDogMTAsCiAgICBuYW1lOiAiT1AgTWFpbm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiRXRoZXIiLCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tYWlubmV0Lm9wdGltaXNtLmlvIl0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiT3B0aW1pc20gRXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vb3B0aW1pc3RpYy5ldGhlcnNjYW4uaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLW9wdGltaXN0aWMuZXRoZXJzY2FuLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQyNl06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGU1OTY1QWI1OTYyZURjNzQ3N0M4NTIwMjQzQTk1NTE3Q0QyNTJmQTkiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDI2XTogewogICAgICAgICAgYWRkcmVzczogIjB4ZGZlOTc4NjgyMzNkMWFhMjJlODE1YTI2Njk4MmYyY2YxNzY4NWEyNyIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDQyODYyNjMKICAgICAgfSwKICAgICAgcG9ydGFsOiB7CiAgICAgICAgW3NvdXJjZUlkMjZdOiB7CiAgICAgICA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KHsKICAgIGlkOiA0MTE0NDExNCwKICAgIG5hbWU6ICJPdGltIERldm5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFVEgiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwOi8vZGV2bmV0Lm90aW0ueHl6Il0KICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBiYXRjaEludm9rZXI6IHsKICAgICAgICBhZGRyZXNzOiAiMHg1RmJEQjIzMTU2NzhhZmVjYjM2N2YwMzJkOTNGNjQyZjY0MTgwYWEzIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvcGFsbS5qcwogIHZhciBwYWxtID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMTI5NzEwODEwOSwKICAgIG5hbWU6ICJQYWxtIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7CiAgICAgIGRlY2ltYWxzOiAxOCwKICAgICAgbmFtZTogIlBBTE0iLAogICAgICBzeW1ib2w6ICJQQUxNIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9wYWxtLW1haW5uZXQucHVibGljLmJsYXN0YXBpLmlvIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL3BhbG0tbWFpbm5ldC5wdWJsaWMuYmxhc3RhcGkuaW8iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJDaGFpbmxlbnMiLAogICAgICAgIHVybDogIm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zLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9waG9lbml4LmpzCiAgdmFyIHBob2VuaXggPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDEzMzgxLAogICAgbmFtZTogIlBob2VuaXggQmxvY2tjaGFpbiIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiUGhvZW5peCIsIHN5bWJvbDogIlBIWCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3JwYy5waG9lbml4cGxvcmVyLmNvbSJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlBob2VuaXhwbG9yZXIiLAogICAgICAgIHVybDogImh0dHBzOi8vcGhvZW5peHBsb3Jlci5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vcGhvZW5peHBsb3Jlci5jb20vYXBpIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHg0OThjRjc1N2E1NzVjRkYyYzJFZDlmNTMyZjU2RWZhNzk3Zjg2NDQyIiwKICAgICAgICBibG9ja0NyZWF0ZWQ6IDU2MjAxOTIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3BsYXlmaUFsYmlyZW8uanMKICB2YXIgcGxheWZpQWxiaXJlbyA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICAuLi5jaGFpbkNvbmZpZywKICAgIGlkOiAxNjEyMTI3LAogICA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6IHsKICAgICAgICBuYW1lOiAiUm9vdHNjYW4iLAogICAgICAgIHVybDogImh0dHBzOi8vcG9yY2luaS5yb290c2Nhbi5pbyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4YzlDMkUyNDI5QWVDMzU0OTE2YzQ3NkIzMGQ3MjlkZURkQzk0OTg4ZCIsCiAgICAgICAgYmxvY2tDcmVhdGVkOiAxMDU1NTY5MgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3Jvb3RzdG9jay5qcwogIHZhciByb290c3RvY2sgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDMwLAogICAgbmFtZTogIlJvb3RzdG9jayBNYWlubmV0IiwKICAgIG5ldHdvcms6ICJyb290c3RvY2siLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiUm9vdHN0b2NrIEJpdGNvaW4iLAogICAgICBzeW1ib2w6ICJSQlRDIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcHVibGljLW5vZGUucnNrLmNvIl0gfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiUlNLIEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwczovL2V4cGxvcmVyLnJzay5jbyIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICBtdWx0aWNhbGwzOiB7CiAgICAgICAgYWRkcmVzczogIjB4Y0ExMWJkZTA1OTc3YjM2MzExNjcw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3NzYzNjFjODM3NDFkZDMiLAogICAgICAgICAgYmxvY2tDcmVhdGVkOiAyMDM2OTkzMwogICAgICAgIH0KICAgICAgfSwKICAgICAgbDFTdGFuZGFyZEJyaWRnZTogewogICAgICAgIFtzb3VyY2VJZDM1XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjJFZGQ1ZjQ5MzBFYTkyZENhM2ZCODE2ODliREQ5YjlkMDc2YjU3QiIsCiAgICAgICAgICBibG9ja0NyZWF0ZWQ6IDIwMzY5OTM1CiAgICAgICAgfQogICAgICB9CiAgICB9LAogICAgc291cmNlSWQ6IHNvdXJjZUlkMzUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy9zaGFwZVNlcG9saWEuanMKICB2YXIgc291cmNlSWQzNiA9IDExMTU1MTExOwogIHZhciBzaGFwZVNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDExMDExLAogICAgbmFtZTogIlNoYXBlIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogeyBuYW1lOiAiU2Vwb2xpYSBFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3NlcG9saWEuc2hhcGUubmV0d29yayJdCiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogImJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vZXhwbG9yZXItc2Vwb2xpYS5zaGFwZS5uZXR3b3JrLyIsCiAgICAgICAgYXBpVXJsOiAiaHR0cHM6Ly9leHBsb3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LCBzeW1ib2w6ICJFVEgiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsKICAgICAgICAgICJodHRwczovL3JwYy5zaWxpY29uLm5ldHdvcmsiLAogICAgICAgICAgImh0dHBzOi8vc2lsaWNvbi1tYWlubmV0Lm5vZGVpbmZyYS5jb20iCiAgICAgICAgXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTaWxpY29uU2NvcGUiLAogICAgICAgIHVybDogImh0dHBzOi8vc2NvcGUuc2lsaWNvbi5uZXR3b3JrIgogICAgICB9CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8uZGVuby92aWVtQDIuMjEuMzUvbm9kZV9tb2R1bGVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvc2lsaWNvblNlcG9saWEuanMKICB2YXIgc2lsaWNvblNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDE3MjI2NDExNjAsCiAgICBuYW1lOiAiU2lsaWNvbiBTZXBvbGlhIHprRVZNIiwKICAgIG5hdGl2ZUN1cnJlbmN5OiB7IG5hbWU6ICJFdGhlciIsIHN5bWJvbDogIkVUSCIsIGRlY2ltYWxzOiAxOCB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vcnBjLXNlcG9saWEuc2lsaWNvbi5uZXR3b3JrIiwKICAgICAgICAgICJodHRwczovL3NpbGljb24tdGVzdG5ldC5ub2RlaW5mcmEuY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiU2lsaWNvblNlcG9saWFTY29wZ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gICAgd2ViU29ja2V0OiBbIndzczovL21haW5uZXQuc2thbGVub2Rlcy5jb20vdjEvd3MvbGlnaHQtdmFzdC1kaXBoZGEiXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTS0FMRSBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9saWdodC12YXN0LWRpcGhkYS5leHBsb3Jlci5tYWlubmV0LnNrYWxlbm9kZXMuY29tIgogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7fQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NrYWxlL2h1bWFuUHJvdG9jb2wuanMKICB2YXIgc2thbGVIdW1hblByb3RvY29sID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIGlkOiAxMjczMjI3NDUzLAogICAgbmFtZTogIlNLQUxFIHwgSHVtYW4gUHJvdG9jb2wiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogInNGVUVMIiwgc3ltYm9sOiAic0ZVRUwiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIGh0dHA6IFsiaHR0cHM6Ly9tYWlubmV0LnNrYWxlbm9kZXMuY29tL3YxL3dhbi1yZWQtYWluIl0sCiAgICAgICAgd2ViU29ja2V0OiBbIndzczovL21haW5uZXQuc2thbGVub2Rlcy5jb20vdjEvd3Mvd2FuLXJlZC1haW4iXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJTS0FMRSBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly93YW4tcmVkLWFpbi5leHBsb3Jlci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gIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiU25heCBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9leHBsb3Jlci5zbmF4Y2hhaW4uaW8iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vZXhwbG9yZXIuc25heGNoYWluLmlvL2FwaSIKICAgICAgfQogICAgfSwKICAgIGNvbnRyYWN0czogewogICAgICAuLi5jaGFpbkNvbmZpZzIuY29udHJhY3RzLAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQzN106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDQ3MjU2MkZjZjI2RDZiMjc5M2Y4RTBiMGZCNjYwYmEwRTVlMDhBNDYiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM3XTogewogICAgICAgICAgYWRkcmVzczogIjB4MjE3MmU0OTJGYzgwN0Y1ZDU2NDVEMEUzNTQzZjEzOUVDRjUzOTI5NCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzN106IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDc5ZjQ0NkQwMjRkNzREMEJiNkU2OTlDMTMxYzcwMzQ2M2M1RDY1RTkiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMzddOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHg2NTM0QmRiNmI1YzA2MGQzZTZhYTgzMzQzMzMzMzEzNWVGRThFMGFBIgogICAgICAgIH0KICAgICAgfQogICAgfSwKIC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REQwOWY1NUUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDM4XTogewogICAgICAgICAgYWRkcmVzczogIjB4NjBlM0EzNjhhNGNkQ0VmODVmZkI5NjRlMzcyNzI2RjU2QTQ2MjIxZSIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjYTExYmRlMDU5NzdiMzYzMTE2NzAyODg2MmJlMmExNzM5NzZjYTExIgogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICAgICBbc291cmNlSWQzOF06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweGI1YWZkZDBFOGRERjA4MUVmOTBlOEEzZTBjN2I1Nzk4ZTY2RTk1NEUiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMVN0YW5kYXJkQnJpZGdlOiB7CiAgICAgICAgW3NvdXJjZUlkMzhdOiB7CiAgICAgICAgICBhZGRyZXNzOiAiMHhiZDM3RTFhNTlENEMwMEM5QTQ2Rjc1MDE4ZGZmZDg0MDYxYkM1Zjc0IgogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBzb3VyY2VJZDogc291cmNlSWQzOAogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3NvbmVpdW1NaW5hdG8uanMKICB2YXIgc291cmNlSWQzOSA9IDExMTU1MTExOwogIHZhciBzb25laXVtTWluYXRvID0gLyogQF9fUFVSRV9fICovIGRlZmluZUNoYWluKHsKICAgIC4uLmNoYWluQ29uZmlnMiwKICAgIGlkOiAxOTQ2LAogICAgbmFtZTogIlNvbmVpdW0gTWluYXRvIFRlc3RuZXQiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIlNlcG9saWEgRX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dmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJDSFoiLAogICAgICBzeW1ib2w6ICJDSFoiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWwogICAgICAgICAgImh0dHBzOi8vc3BpY3ktcnBjLmNoaWxpei5jb20iLAogICAgICAgICAgImh0dHBzOi8vY2hpbGl6LXNwaWN5LXJwYy5wdWJsaWNub2RlLmNvbSIKICAgICAgICBdLAogICAgICAgIHdlYlNvY2tldDogWwogICAgICAgICAgIndzczovL3NwaWN5LXJwYy13cy5jaGlsaXouY29tIiwKICAgICAgICAgICJ3c3M6Ly9jaGlsaXotc3BpY3ktcnBjLnB1YmxpY25vZGUuY29tIgogICAgICAgIF0KICAgICAgfQogICAgfSwKICAgIGJsb2NrRXhwbG9yZXJzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBuYW1lOiAiQ2hpbGl6IEV4cGxvcmVyIiwKICAgICAgICB1cmw6ICJodHRwOi8vc3BpY3ktZXhwbG9yZXIuY2hpbGl6LmNvbSIsCiAgICAgICAgYXBpVXJsOiAiaHR0cDovL3NwaWN5LWV4cGxvcmVyLmNoaWxpei5jb20vYXBpIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3N0ZXAuanMKICB2YXIgc3RlcCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogMTIzNCwKICAgIG5hbWU6ICJTdGVwIE5ldHdvcmsiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsgbmFtZTogIkZJVEZJIiwgc3ltYm9sOiAiRklURkkiLCBkZWNpbWFsczogMTggfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGV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XhwbG9yZXIudWx0cm9uLWRldi5pbyIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUKICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5kZW5vL3ZpZW1AMi4yMS4zNS9ub2RlX21vZHVsZXMvdmllbS9fZXNtL2NoYWlucy9kZWZpbml0aW9ucy91bmljaGFpblNlcG9saWEuanMKICB2YXIgc291cmNlSWQ0MCA9IDExMTU1MTExOwogIHZhciB1bmljaGFpblNlcG9saWEgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcyLAogICAgaWQ6IDEzMDEsCiAgICBuYW1lOiAiVW5pY2hhaW4gU2Vwb2xpYSIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiLAogICAgICBkZWNpbWFsczogMTgKICAgIH0sCiAgICBycGNVcmxzOiB7CiAgICAgIGRlZmF1bHQ6IHsKICAgICAgICBodHRwOiBbImh0dHBzOi8vc2Vwb2xpYS51bmljaGFpbi5vcmciXQogICAgICB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJVbmlzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3NlcG9saWEudW5pc2Nhbi54eXoiLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vYXBpLXNlcG9saWEudW5pc2Nhbi54eXoiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMAogICAgICB9LAogICAgICBwb3J0YWw6IHsKICAgICA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sOiAiUVRaIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjLXF1YXJ0ei51bmlxdWUubmV0d29yayJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlF1YXJ0eiBTdWJzY2FuIiwKICAgICAgICB1cmw6ICJodHRwczovL3F1YXJ0ei5zdWJzY2FuLmlvLyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3VucmVhbC5qcwogIHZhciB1bnJlYWwgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDE4MjMzLAogICAgbmFtZTogIlVucmVhbCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBuYW1lOiAicmVFVEgiLAogICAgICBkZWNpbWFsczogMTgsCiAgICAgIHN5bWJvbDogInJlRVRIIgogICAgfSwKICAgIHJwY1VybHM6IHsKICAgICAgZGVmYXVsdDogeyBodHRwOiBbImh0dHBzOi8vcnBjLnVucmVhbC1vcmJpdC5nZWxhdG8uZGlnaXRhbCJdIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlVucmVhbCBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly91bnJlYWwuYmxvY2tzY291dC5jb20iLAogICAgICAgIGFwaVVybDogImh0dHBzOi8vdW5yZWFsLmJsb2Nrc2NvdXQuY29tL2FwaS92MiIKICAgICAgfQogICAgfSwKICAgIHRlc3RuZXQ6IHRydWUsCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweDhiNkIwZTYw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zY2FuIFNlcG9saWEiLAogICAgICAgIHVybDogImh0dHBzOi8vc2Vwb2xpYS53b3JsZHNjYW4ub3JnIgogICAgICB9LAogICAgICBibG9ja3Njb3V0OiB7CiAgICAgICAgbmFtZTogIkJsb2Nrc2NvdXQiLAogICAgICAgIHVybDogImh0dHBzOi8vd29ybGRjaGFpbi1zZXBvbGlhLmV4cGxvcmVyLmFsY2hlbXkuY29tIiwKICAgICAgICBhcGlVcmw6ICJodHRwczovL3dvcmxkY2hhaW4tc2Vwb2xpYS5leHBsb3Jlci5hbGNoZW15LmNvbS9hcGkiCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgLi4uY2hhaW5Db25maWcyLmNvbnRyYWN0cywKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNhMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYmUyYTE3Mzk3NmNhMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMAogICAgICB9LAogICAgICBkaXNwdXRlR2FtZUZhY3Rvcnk6IHsKICAgICAgICBbc291cmNlSWQ0Ml06IHsKICAgICAgICAgIGFkZHJlc3M6ICIweDhjRjk3RWU2MTZDOTg2YTA3MEY1MDIwZDk3M2I0NTZEMDEyMEMyNTMiCiAgICAgICAgfQogICAgICB9LAogICAgICBsMk91dHB1dE9yYWNsZTogewogICAgICAgIFtzb3VyY2VJZDQyXTogewogICAgICAgICAgYWRkcmVzczogIjB4Yzg4ODZmOEJBYjZFYWViMjE1YURCNWYxYzY4NkJGNjk5MjQ4MzAwZSIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHBvcnRhbDogewogICAgICAgIFtzb3VyY2VJZDQyXTogewogICAgICAgICAgYWRkcmVzczogIjB4RmY2RUJhMTA5MjcxZmU2ZDQyMzdFZWVENGJBYjFkRDlBNzdkRDFBNCIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIGwxU3RhbmRhcmRCcmlkZ2U6IHsKICAgIC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aXR5LmlvL3B1YmxpYyJdLAogICAgICAgIHdlYlNvY2tldDogWyJ3c3M6Ly96ZW5jaGFpbi10ZXN0bmV0LmFwaS5vbmZpbmFsaXR5LmlvL3B1YmxpYy13cyJdCiAgICAgIH0KICAgIH0sCiAgICBjb250cmFjdHM6IHsKICAgICAgbXVsdGljYWxsMzogewogICAgICAgIGFkZHJlc3M6ICIweGNBMTFiZGUwNTk3N2IzNjMxMTY3MDI4ODYyYkUyYTE3Mzk3NkNBMTEiLAogICAgICAgIGJsb2NrQ3JlYXRlZDogMjMwMDE5CiAgICAgIH0KICAgIH0sCiAgICBibG9ja0V4cGxvcmVyczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgbmFtZTogIlplbnRyYWNlIiwKICAgICAgICB1cmw6ICJodHRwczovL3plbnRyYWNlLmlvIgogICAgICB9CiAgICB9LAogICAgdGVzdG5ldDogdHJ1ZQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3pldGFjaGFpbi5qcwogIHZhciB6ZXRhY2hhaW4gPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgaWQ6IDdlMywKICAgIG5hbWU6ICJaZXRhQ2hhaW4iLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiWmV0YSIsCiAgICAgIHN5bWJvbDogIlpFVEEiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaHR0cDogWyJodHRwczovL3pldGFjaGFpbi1ldm0uYmxvY2twaS5uZXR3b3JrL3YxL3JwYy9wdWJsaWMiXQogICAgICB9CiAgICB9LAogICAgY29udHJhY3RzOiB7CiAgICAgIG11bHRpY2FsbDM6IHsKICAgICAgICBhZGRyZXNzOiAiMHhjQTExYmRlMDU5NzdiMzY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GVzL3ZpZW0vX2VzbS9jaGFpbnMvZGVmaW5pdGlvbnMvemtMaW5rTm92YVNlcG9saWFUZXN0bmV0LmpzCiAgdmFyIHprTGlua05vdmFTZXBvbGlhVGVzdG5ldCA9IC8qIEBfX1BVUkVfXyAqLyBkZWZpbmVDaGFpbih7CiAgICBpZDogODEwMTgxLAogICAgbmFtZTogInprTGluayBOb3ZhIFNlcG9saWEgVGVzdG5ldCIsCiAgICBuYXRpdmVDdXJyZW5jeTogewogICAgICBkZWNpbWFsczogMTgsCiAgICAgIG5hbWU6ICJFVEgiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7IGh0dHA6IFsiaHR0cHM6Ly9zZXBvbGlhLnJwYy56a2xpbmsuaW8iXSB9CiAgICB9LAogICAgYmxvY2tFeHBsb3JlcnM6IHsKICAgICAgZGVmYXVsdDogewogICAgICAgIG5hbWU6ICJ6a0xpbmsgTm92YSBCbG9jayBFeHBsb3JlciIsCiAgICAgICAgdXJsOiAiaHR0cHM6Ly9zZXBvbGlhLmV4cGxvcmVyLnprbGluay5pbyIKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLmRlbm8vdmllbUAyLjIxLjM1L25vZGVfbW9kdWxlcy92aWVtL19lc20vY2hhaW5zL2RlZmluaXRpb25zL3prc3luYy5qcwogIHZhciB6a3N5bmMgPSAvKiBAX19QVVJFX18gKi8gZGVmaW5lQ2hhaW4oewogICAgLi4uY2hhaW5Db25maWcsCiAgICBpZDogMzI0LAogICAgbmFtZTogIlpLc3luYyBFcmEiLAogICAgbmV0d29yazogInprc3luYy1lcmEiLAogICAgbmF0aXZlQ3VycmVuY3k6IHsKICAgICAgZGVjaW1hbHM6IDE4LAogICAgICBuYW1lOiAiRXRoZXIiLAogICAgICBzeW1ib2w6ICJFVEgiCiAgICB9LAogICAgcnBjVXJsczogewogICAgICBkZWZhdWx0OiB7CiAgICAgICAgaH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udHMiOgogICAgICAgICAgcmV0dXJuIHRoaXMucmVxdWVzdEFjY291bnRzKCk7CiAgICAgICAgY2FzZSAiZXRoX2FjY291bnRzIjoKICAgICAgICAgIHJldHVybiB0aGlzLmdldEFjY291bnRzKCk7CiAgICAgICAgY2FzZSAiZXRoX3NlbmRUcmFuc2FjdGlvbiI6CiAgICAgICAgICByZXR1cm4gdGhpcy5zZW5kVHJhbnNhY3Rpb24ocGFyYW1zWzBdKTsKICAgICAgICBjYXNlICJldGhfc2lnbiI6CiAgICAgICAgICByZXR1cm4gdGhpcy5zaWduKHBhcmFtc1swXSwgcGFyYW1zWzFdKTsKICAgICAgICBjYXNlICJwZXJzb25hbF9zaWduIjoKICAgICAgICAgIHJldHVybiB0aGlzLnBlcnNvbmFsU2lnbihwYXJhbXNbMF0sIHBhcmFtc1sxXSk7CiAgICAgICAgY2FzZSAiZXRoX3NpZ25UeXBlZERhdGEiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2lnblR5cGVkRGF0YShwYXJhbXNbMF0sIHBhcmFtc1sxXSk7CiAgICAgICAgY2FzZSAiZXRoX2NoYWluSWQiOgogICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0Q2hhaW5JZCgpOwogICAgICAgIGNhc2UgIm5ldF92ZXJzaW9uIjoKICAgICAgICAgIHJldHVybiB0aGlzLmdldE5ldHdvcmtJZCgpOwogICAgICAgIGNhc2UgImV0aF9ibG9ja051bWJlciI6CiAgICAgICAgICByZXR1cm4gdGhpcy5nZXRCbG9ja051bWJlcigpOwogICAgICAgIGNhc2UgImV0aF9nZXRUcmFuc2FjdGlvbkNvdW50IjoKICAgICAgICAgIHJldHVybiB0aGlzLmdldFRyYW5zYWN0aW9uQ291bnQocGFyYW1zWzBdKTsKICAgICAgICBjYXNlICJldGhfZ2V0VHJhbnNhY3Rpb25CeUhhc2giOgogICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0VHJhbnNhY3Rpb24ocGFyYW1zWzBdKTsKICAgICAgICBjY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kRGF0YSkgewogICAgICBpZiAoYWRkcmVzcyAhPT0gdGhpcy5zZWxlY3RlZEFkZHJlc3MpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkFkZHJlc3MgbWlzbWF0Y2giKTsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5jbGllbnQuc2lnblR5cGVkRGF0YSh7CiAgICAgICAgYWNjb3VudDogYWRkcmVzcywKICAgICAgICBkb21haW46IHR5cGVkRGF0YS5kb21haW4sCiAgICAgICAgdHlwZXM6IHR5cGVkRGF0YS50eXBlcywKICAgICAgICBtZXNzYWdlOiB0eXBlZERhdGEubWVzc2FnZSwKICAgICAgICBwcmltYXJ5VHlwZTogdHlwZWREYXRhLnByaW1hcnlUeXBlCiAgICAgIH0pOwogICAgfQogICAgYXN5bmMgZ2V0Q2hhaW5JZCgpIHsKICAgICAgY29uc3QgY2hhaW5JZCA9IGF3YWl0IHRoaXMuY2xpZW50LmdldENoYWluSWQoKTsKICAgICAgY29uc29sZS5sb2coImdldENoYWluSWQiLCBjaGFpbklkKTsKICAgICAgcmV0dXJuIGNoYWluSWQ7CiAgICB9CiAgICBhc3luYyBnZXROZXR3b3JrSWQoKSB7CiAgICAgIGNvbnN0IGNoYWluSWQgPSBhd2FpdCB0aGlzLmdldENoYWluSWQoKTsKICAgICAgcmV0dXJuIGNoYWluSWQudG9TdHJpbmcoKTsKICAgIH0KICB9OwogIGZ1bmN0aW9uIGFkZEVpcDY5NjNMaXN0ZW5lcihpbmZvLCBwcm92aWRlcikgewogICAgY29uc3QgYW5ub3VuY2VFdmVudCA9IG5ldyBDdXN0b21FdmVudCgKICAgICAgImVpcDY5NjM6YW5ub3VuY2VQcm92aWRlciIsCiAgICAgIHsKICAgICAgICBkZXRhaWw6IE9iamVjdC5mcmVlemUoeyBpbmZvLCBwcm92aWRlciB9KQogICAgICB9CiAgICApOwogICAgd2luZG93LmRpc3BhdGNoRXZlbnQoYW5ub3VuY2VFdmVudCk7CiAgICB3aW5kb3cu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N1cnZlcy9lc20vc2VjcDI1NmsxLmpzOgogICgqISBub2JsZS1jdXJ2ZXMgLSBNSVQgTGljZW5zZSAoYykgMjAyMiBQYXVsIE1pbGxlciAocGF1bG1pbGxyLmNvbSkgKikKKi8K'); diff --git a/apps/shinkai-tool-playwright-example/src/index.ts b/apps/shinkai-tool-playwright-example/src/index.ts index 211dc9a..ca1728d 100644 --- a/apps/shinkai-tool-playwright-example/src/index.ts +++ b/apps/shinkai-tool-playwright-example/src/index.ts @@ -1,5 +1,6 @@ import * as playwright from 'npm:playwright@1.48.2'; import chromePaths from 'npm:chrome-paths@1.0.1'; +import process from 'node:process'; type Configurations = { chromePath?: string; @@ -13,7 +14,11 @@ export const run: Run = async ( configurations, parameters, ): Promise => { - const chromePath = configurations?.chromePath || chromePaths.chrome; + const chromePath = + configurations?.chromePath || + process.env.CHROME_BIN || + chromePaths.chrome || + chromePaths.chromium; console.log('executing chrome from', chromePath); const browser = await playwright['chromium'].launch({ executablePath: chromePath, diff --git a/libs/shinkai-tools-runner/Cargo.toml b/libs/shinkai-tools-runner/Cargo.toml index df86720..ff9e073 100644 --- a/libs/shinkai-tools-runner/Cargo.toml +++ b/libs/shinkai-tools-runner/Cargo.toml @@ -30,6 +30,8 @@ tempfile = "3.13.0" log = "0.4.22" once_cell = { version = "1.20.2" } env_logger = "0.11.5" +anyhow = { version = "1.0.93" } +chrono = { version = "0.4.38" } [build-dependencies] copy_to_output = "2.2.0" diff --git a/libs/shinkai-tools-runner/src/lib.test.rs b/libs/shinkai-tools-runner/src/lib.test.rs index 70d3152..89d27ca 100644 --- a/libs/shinkai-tools-runner/src/lib.test.rs +++ b/libs/shinkai-tools-runner/src/lib.test.rs @@ -360,6 +360,7 @@ async fn shinkai_tool_duckduckgo_search() { #[tokio::test] async fn shinkai_tool_playwright_example() { + let _ = env_logger::builder() .filter_level(log::LevelFilter::Info) .is_test(true) diff --git a/libs/shinkai-tools-runner/src/tools/container_utils.rs b/libs/shinkai-tools-runner/src/tools/container_utils.rs new file mode 100644 index 0000000..0cbf4f4 --- /dev/null +++ b/libs/shinkai-tools-runner/src/tools/container_utils.rs @@ -0,0 +1,54 @@ +use std::process::Command; + +#[derive(Debug, PartialEq)] +pub enum DockerStatus { + NotInstalled, + NotRunning, + Running, +} + +/// Checks if Docker is available on the system by attempting to run 'docker info' command. +/// This function verifies both that Docker is installed and that the Docker daemon is running. +/// +/// # Details +/// +/// The function executes `docker info` which requires: +/// - Docker CLI to be installed and in PATH +/// - Docker daemon to be running and accessible +/// - Current user to have permissions to access Docker +/// +/// # Returns +/// +/// * `true` - If Docker is fully operational (installed, running and accessible) +/// * `false` - If Docker is not available for any reason: +/// - Docker is not installed +/// - Docker daemon is not running +/// - User lacks permissions +/// - Other Docker configuration issues +/// +/// # Example +/// +/// ``` +/// use shinkai_tools_runner::tools::container_utils; +/// +/// let docker_available = container_utils::is_docker_available(); +/// if docker_available { +/// println!("docker is available and ready to use"); +/// } else { +/// println!("docker is not available - check installation and permissions"); +/// } +/// ``` +pub fn is_docker_available() -> DockerStatus { + let docker_check = Command::new("docker").arg("info").output(); + + match docker_check { + Ok(output) => { + if output.status.success() { + DockerStatus::Running + } else { + DockerStatus::NotRunning + } + } + Err(_) => DockerStatus::NotInstalled, + } +} diff --git a/libs/shinkai-tools-runner/src/tools/deno_execution_storage.rs b/libs/shinkai-tools-runner/src/tools/deno_execution_storage.rs new file mode 100644 index 0000000..592ddfe --- /dev/null +++ b/libs/shinkai-tools-runner/src/tools/deno_execution_storage.rs @@ -0,0 +1,147 @@ +use std::{io::Write, path::PathBuf}; + +use nanoid::nanoid; + +use super::execution_context::ExecutionContext; + +#[derive(Default)] +pub struct DenoExecutionStorage { + pub context: ExecutionContext, + pub code_id: String, + pub root: PathBuf, + pub root_code: PathBuf, + pub code: PathBuf, + pub code_entrypoint: PathBuf, + pub deno_cache: PathBuf, + pub logs: PathBuf, + pub log_file: PathBuf, + pub home: PathBuf, +} + +impl DenoExecutionStorage { + pub fn new(context: ExecutionContext) -> Self { + let code_id = format!("{}-{}", context.code_id, nanoid!()); + let root = context.storage.clone(); + let root_code = root.join("code"); + let code = root_code.join(code_id.clone()); + let logs = context.storage.join("logs"); + let log_file = logs.join(format!( + "log_{}_{}.log", + context.context_id, context.execution_id, + )); + Self { + context, + code_id: code_id.clone(), + root: root.clone(), + root_code, + code: code.clone(), + code_entrypoint: code.join("index.ts"), + deno_cache: root.join("deno-cache"), + logs: logs.clone(), + log_file, + home: root.join("home"), + } + } + + pub fn init(&self, code: &str, pristine_cache: Option) -> anyhow::Result<()> { + for dir in [ + &self.root, + &self.root_code, + &self.code, + &self.deno_cache, + &self.logs, + &self.home, + ] { + log::info!("creating directory: {}", dir.display()); + std::fs::create_dir_all(dir).map_err(|e| { + log::error!("failed to create directory {}: {}", dir.display(), e); + e + })?; + } + + log::info!("creating code file: {}", self.code_entrypoint.display()); + std::fs::write(&self.code_entrypoint, code).map_err(|e| { + log::error!("failed to write code to index.ts: {}", e); + e + })?; + + log::info!( + "creating log file if not exists: {}", + self.log_file.display() + ); + if !self.log_file.exists() { + std::fs::write(&self.log_file, "").map_err(|e| { + log::error!("failed to create log file: {}", e); + e + })?; + } + + if pristine_cache.unwrap_or(false) { + std::fs::remove_dir_all(&self.deno_cache)?; + std::fs::create_dir(&self.deno_cache)?; + log::info!( + "cleared deno cache directory: {}", + self.deno_cache.display() + ); + } + + Ok(()) + } + + pub fn get_relative_code_entrypoint(&self) -> anyhow::Result { + self.code_entrypoint + .strip_prefix(&self.root) + .map(|p| p.to_string_lossy().to_string()) + .map_err(|e| { + log::error!("failed to get relative path: {}", e); + anyhow::anyhow!("failed to get relative path: {}", e) + }) + } + + pub fn get_relative_deno_cache(&self) -> anyhow::Result { + self.deno_cache + .strip_prefix(&self.root) + .map(|p| p.to_string_lossy().to_string()) + .map_err(|e| { + log::error!("failed to get relative path: {}", e); + anyhow::anyhow!("failed to get relative path: {}", e) + }) + } + + pub fn append_log(&self, log: &str) -> anyhow::Result<()> { + let timestamp = chrono::Local::now().format("%Y%m%d_%H%M%S"); + let log_line = format!( + "{},{},{},{},{}\n", + timestamp, self.context.context_id, self.context.execution_id, self.code_id, log, + ); + let mut file = std::fs::OpenOptions::new() + .append(true) + .create(true) // Create the file if it doesn't exist + .open(self.log_file.clone()) + .map_err(|e| { + log::error!("failed to open log file: {}", e); + e + })?; + file.write_all(log_line.as_bytes())?; + Ok(()) + } +} + +// We do best effort to remove ephemereal folders +impl Drop for DenoExecutionStorage { + fn drop(&mut self) { + if let Err(e) = std::fs::remove_dir_all(&self.code) { + log::warn!( + "failed to remove code directory {}: {}", + self.code.display(), + e + ); + } else { + log::info!("removed code directory: {}", self.code.display()); + } + } +} + +#[cfg(test)] +#[path = "deno_execution_storage.test.rs"] +mod tests; diff --git a/libs/shinkai-tools-runner/src/tools/deno_execution_storage.test.rs b/libs/shinkai-tools-runner/src/tools/deno_execution_storage.test.rs new file mode 100644 index 0000000..1e713cc --- /dev/null +++ b/libs/shinkai-tools-runner/src/tools/deno_execution_storage.test.rs @@ -0,0 +1,70 @@ +use crate::tools::{ + deno_execution_storage::DenoExecutionStorage, execution_context::ExecutionContext, +}; + +#[tokio::test] +async fn test_execution_storage_init() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + + let test_dir = + std::path::PathBuf::from("./shinkai-tools-runner-execution-storage/test-execution-storage"); + let storage = DenoExecutionStorage::new(ExecutionContext { + storage: test_dir.clone(), + ..Default::default() + }); + + let test_code = "console.log('test');"; + storage.init(test_code, None).unwrap(); + + // Verify directories were created + assert!(storage.root.exists()); + assert!(storage.code.exists()); + assert!(storage.deno_cache.exists()); + assert!(storage.logs.exists()); + assert!(storage.home.exists()); + + // Verify code file was written correctly + let code_contents = std::fs::read_to_string(storage.code_entrypoint.clone()).unwrap(); + assert_eq!(code_contents, test_code); + + // Clean up test directory + std::fs::remove_dir_all(test_dir).unwrap(); +} + +#[tokio::test] +async fn test_execution_storage_clean_cache() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + + let test_dir = + std::path::PathBuf::from("./shinkai-tools-runner-execution-storage/test-clean-cache"); + let storage = DenoExecutionStorage::new(ExecutionContext { + storage: test_dir.clone(), + ..Default::default() + }); + + // Initialize with some test code + let test_code = "console.log('test');"; + storage.init(test_code, None).unwrap(); + + // Create a test file in the cache directory + let test_cache_file = storage.deno_cache.join("test_cache.txt"); + std::fs::write(&test_cache_file, "test cache content").unwrap(); + assert!(test_cache_file.exists()); + + // Reinitialize with pristine cache enabled + storage.init(test_code, Some(true)).unwrap(); + + // Verify cache directory was cleared + assert!(!test_cache_file.exists()); + assert!(storage.deno_cache.exists()); // Directory should still exist but be empty + assert!(std::fs::read_dir(&storage.deno_cache).unwrap().count() == 0); + + // Clean up test directory + std::fs::remove_dir_all(test_dir).unwrap(); +} diff --git a/libs/shinkai-tools-runner/src/tools/deno_runner.rs b/libs/shinkai-tools-runner/src/tools/deno_runner.rs index 265af29..772124d 100644 --- a/libs/shinkai-tools-runner/src/tools/deno_runner.rs +++ b/libs/shinkai-tools-runner/src/tools/deno_runner.rs @@ -1,6 +1,12 @@ -use std::{collections::HashMap, process::Command}; +use tokio::{ + io::{AsyncBufReadExt, BufReader}, + select, +}; -use super::deno_runner_options::DenoRunnerOptions; +use crate::tools::deno_execution_storage::DenoExecutionStorage; + +use super::{container_utils::DockerStatus, deno_runner_options::DenoRunnerOptions}; +use std::{collections::HashMap, time::Duration}; #[derive(Default)] pub struct DenoRunner { @@ -8,57 +14,262 @@ pub struct DenoRunner { } impl DenoRunner { - const DENO_PERMISSIONS: [&'static str; 4] = [ - "--allow-all", - "--deny-write=/etc", - "--deny-write=/usr", - "--deny-write=C:\\Windows", - ]; pub fn new(options: DenoRunnerOptions) -> Self { DenoRunner { options } } + /// Runs Deno code either in a Docker container or directly on the host system. + /// + /// The execution environment is determined automatically based on whether Docker is available. + /// If Docker is detected, the code runs in an isolated container using the configured Deno image. + /// Otherwise, it falls back to running directly on the host using a local Deno binary. + /// + /// # Arguments + /// + /// * `code` - The Deno/TypeScript code to execute as a string + /// * `envs` - Optional HashMap of environment variables to pass to the execution environment + /// * `max_execution_time_s` - Optional timeout in seconds after which execution will be terminated + /// + /// # Returns + /// + /// Returns a Result containing: + /// - Ok(String): The combined stdout/stderr output from the code execution + /// - Err(anyhow::Error): Any errors that occurred during setup or execution + /// + /// # Example + /// + /// ```no_run + /// let mut runner = DenoRunner::new(DenoRunnerOptions::default()); + /// let result = runner.run( + /// "console.log('Hello from Deno!')", + /// None, + /// Some(30) + /// ).await?; + /// ``` pub async fn run( &mut self, code: &str, envs: Option>, - max_execution_time_s: Option, - ) -> Result { - log::info!("using deno binary at path: {:?}", self.options.binary_path); - let binary_path = self.options.binary_path.clone(); - - let temp_file = tempfile::NamedTempFile::new()?; - log::info!("created temporary file for code at: {:?}", temp_file.path()); - std::fs::write(temp_file.path(), code).map_err(|e| { - log::error!("failed to write code to temporary file: {}", e); + max_execution_time_ms: Option, + ) -> anyhow::Result> { + let force_deno_in_host = + std::env::var("CI_FORCE_DENO_IN_HOST").unwrap_or(String::from("false")) == *"true"; + if !force_deno_in_host + && super::container_utils::is_docker_available() == DockerStatus::Running + { + self.run_in_docker(code, envs, max_execution_time_ms).await + } else { + self.run_in_host(code, envs, max_execution_time_ms).await + } + } + + async fn run_in_docker( + &mut self, + code: &str, + envs: Option>, + max_execution_time_ms: Option, + ) -> anyhow::Result> { + log::info!( + "using deno from container image:{:?}", + self.options.deno_image_name + ); + + let execution_storage = DenoExecutionStorage::new(self.options.context.clone()); + execution_storage.init(code, None)?; + + let mount_param = format!("{}:/app", execution_storage.root.to_str().unwrap()); + + let mut container_envs = Vec::::new(); + + container_envs.push(String::from("-e")); + container_envs.push(format!( + "DENO_DIR={}", + execution_storage.get_relative_deno_cache()? + )); + if let Some(envs) = envs { + for (key, value) in envs { + let env = format!("{}={}", key, value); + container_envs.push(String::from("-e")); + container_envs.push(env); + } + } + let code_entrypoint = execution_storage.get_relative_code_entrypoint()?; + let mut command = tokio::process::Command::new("docker"); + let mut args = ["run", "-it", "-v", mount_param.as_str()].to_vec(); + args.extend(container_envs.iter().map(|s| s.as_str())); + args.extend([ + "--workdir", + "/app", + self.options.deno_image_name.as_str(), + "run", + "--ext", + "ts", + "--allow-all", + code_entrypoint.as_str(), + ]); + let command = command + .args(args) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .kill_on_drop(true); + + log::info!("spawning docker command"); + let mut child = command.spawn().map_err(|e| { + log::error!("failed to spawn command: {}", e); e })?; + let stdout = child.stdout.take().expect("Failed to get stdout"); + let mut stdout_stream = BufReader::new(stdout).lines(); + + let stderr = child.stderr.take().expect("Failed to get stderr"); + let mut stderr_stream = BufReader::new(stderr).lines(); + + let mut stdout_lines = Vec::new(); + let mut stderr_lines = Vec::new(); + + loop { + select! { + Ok(line) = stdout_stream.next_line() => match line { + Some(line) => { + stdout_lines.push(line.clone()); + let _ = execution_storage.append_log(line.as_str()); + }, + None => break, + }, + Ok(line) = stderr_stream.next_line() => match line { + Some(line) => { + stderr_lines.push(line.clone()); + let _ = execution_storage.append_log(line.as_str()); + }, + None => break, + }, + else => break, + } + } + + let output = if let Some(timeout) = max_execution_time_ms { + let timeout_duration = std::time::Duration::from_millis(timeout); + log::info!("executing command with {}ms timeout", timeout); + match tokio::time::timeout(timeout_duration, child.wait_with_output()).await { + Ok(result) => result?, + Err(_) => { + log::error!("command execution timed out after {}ms", timeout); + return Err(anyhow::anyhow!( + "process timed out after {} seconds", + timeout + )); + } + } + } else { + log::info!("executing command without timeout"); + child.wait_with_output().await? + }; + if !output.status.success() { + let error = String::from_utf8_lossy(&output.stdout); + log::error!("command execution failed: {}", error); + return Err(anyhow::anyhow!("command execution failed: {}", error)); + } + + log::debug!( + "command completed successfully with output: {:?}", + stdout_lines + ); + Ok(stdout_lines) + } + + async fn run_in_host( + &mut self, + code: &str, + envs: Option>, + max_execution_time_ms: Option, + ) -> anyhow::Result> { + log::info!( + "using deno from host at path: {:?}", + self.options.deno_binary_path + ); + let binary_path = self.options.deno_binary_path.clone(); + + let execution_storage = DenoExecutionStorage::new(self.options.context.clone()); + execution_storage.init(code, None)?; + + let home_permissions = + format!("--allow-write={}", execution_storage.home.to_string_lossy()); + let deno_permissions_host: Vec<&str> = vec![ + "--allow-env", + "--allow-run", + "--allow-net", + "--allow-sys", + "--allow-scripts", + "--allow-ffi", + "--allow-import", + "--allow-read=.", + "--allow-write=/var/folders", + "--allow-read=/var/folders", + "--allow-read=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", + "--allow-read=/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary", + "--allow-read=/Applications/Chromium.app/Contents/MacOS/Chromium", + "--allow-read=C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", + "--allow-read=C:\\Program Files (x86)\\Google\\Chrome SxS\\Application\\chrome.exe", + "--allow-read=C:\\Program Files (x86)\\Chromium\\Application\\chrome.exe", + home_permissions.as_str(), + ]; + let mut command = tokio::process::Command::new(binary_path); let command = command .args(["run", "--ext", "ts"]) - .args(DenoRunner::DENO_PERMISSIONS) - .arg(temp_file.path().to_str().unwrap()) + .args(deno_permissions_host) + .arg(execution_storage.code_entrypoint.clone()) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) .kill_on_drop(true); + + command.env("DENO_DIR", execution_storage.deno_cache.clone()); if let Some(envs) = envs { command.envs(envs); } log::info!("prepared command with arguments: {:?}", command); - let child = command.spawn()?; + let mut child = command.spawn()?; + + let stdout = child.stdout.take().expect("Failed to get stdout"); + let mut stdout_stream = BufReader::new(stdout).lines(); - let output = if let Some(timeout) = max_execution_time_s { + let stderr = child.stderr.take().expect("Failed to get stderr"); + let mut stderr_stream = BufReader::new(stderr).lines(); + + let mut stdout_lines = Vec::new(); + let mut stderr_lines = Vec::new(); + loop { + select! { + Ok(line) = stdout_stream.next_line() => match line { + Some(line) => { + stdout_lines.push(line.clone()); + let _ = execution_storage.append_log(line.as_str()); + }, + None => break, + }, + Ok(line) = stderr_stream.next_line() => match line { + Some(line) => { + stderr_lines.push(line.clone()); + let _ = execution_storage.append_log(line.as_str()); + }, + None => break, + }, + else => break, + } + } + + let output = if let Some(timeout) = max_execution_time_ms { let timeout_duration = std::time::Duration::from_millis(timeout); log::info!("executing command with {}ms timeout", timeout); match tokio::time::timeout(timeout_duration, child.wait_with_output()).await { Ok(result) => result?, Err(_) => { log::error!("command execution timed out after {}ms", timeout); - return Err(std::io::Error::new( + return Err(anyhow::Error::new(std::io::Error::new( std::io::ErrorKind::TimedOut, format!("process timed out after {} seconds", timeout), - )); + ))); } } } else { @@ -68,13 +279,16 @@ impl DenoRunner { if !output.status.success() { let error = String::from_utf8_lossy(&output.stderr); log::error!("command execution failed: {}", error); - return Err(std::io::Error::new(std::io::ErrorKind::Other, error)); + return Err(anyhow::Error::new(std::io::Error::new( + std::io::ErrorKind::Other, + error.to_string(), + ))); } - - let output = String::from_utf8_lossy(&output.stdout); - - log::info!("command completed successfully with output: {}", output); - Ok(output.to_string()) + log::info!( + "command completed successfully with output: {:?}", + stdout_lines + ); + Ok(stdout_lines) } } diff --git a/libs/shinkai-tools-runner/src/tools/deno_runner.test.rs b/libs/shinkai-tools-runner/src/tools/deno_runner.test.rs index 405749a..9abd28d 100644 --- a/libs/shinkai-tools-runner/src/tools/deno_runner.test.rs +++ b/libs/shinkai-tools-runner/src/tools/deno_runner.test.rs @@ -1,21 +1,40 @@ +use crate::tools::{ + deno_execution_storage::DenoExecutionStorage, deno_runner::DenoRunner, + deno_runner_options::DenoRunnerOptions, execution_context::ExecutionContext, +}; use std::collections::HashMap; -use crate::tools::deno_runner::DenoRunner; - #[tokio::test] async fn test_run_echo_tool() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + let mut deno_runner = DenoRunner::default(); let code = r#" console.log('{"message":"hello world"}'); "#; - let result = deno_runner.run(code, None, None).await.unwrap(); + let result = deno_runner + .run(code, None, None) + .await + .map_err(|e| { + log::error!("Failed to run deno code: {}", e); + e + }) + .unwrap(); - assert_eq!(result, "{\"message\":\"hello world\"}\n"); + assert_eq!(result.first().unwrap(), "{\"message\":\"hello world\"}"); } #[tokio::test] async fn test_run_with_env() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + let mut deno_runner = DenoRunner::default(); let code = r#" console.log(process.env.HELLO_WORLD); @@ -25,5 +44,72 @@ async fn test_run_with_env() { envs.insert("HELLO_WORLD".to_string(), "hello world!".to_string()); // Insert the key-value pair let result = deno_runner.run(code, Some(envs), None).await.unwrap(); - assert_eq!(result, "hello world!\n"); + assert_eq!(result.first().unwrap(), "hello world!"); +} + +#[tokio::test] +async fn test_write_forbidden_folder() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + + std::env::set_var("CI_FORCE_DENO_IN_HOST", "true"); + + let mut deno_runner = DenoRunner::default(); + let code = r#" + try { + await Deno.writeTextFile("/test.txt", "This should fail"); + console.log('write succeeded'); + } catch (e) { + // We expect this to fail due to permissions + console.log('error', e); + throw e; + } + "#; + + let result = deno_runner.run(code, None, None).await.map_err(|e| { + log::error!("Failed to run deno code: {}", e); + e + }); + + assert!(result.is_err()); +} + +#[tokio::test] +async fn test_execution_storage_cache_contains_files() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + + let test_dir = + std::path::PathBuf::from("./shinkai-tools-runner-execution-storage/test-cache-files"); + + let test_code = r#" + import { assertEquals } from "https://deno.land/std@0.201.0/assert/mod.ts"; + console.log('test'); + "#; + // Run the code to ensure dependencies are downloaded + let mut deno_runner = DenoRunner::new(DenoRunnerOptions { + context: ExecutionContext { + storage: test_dir.clone(), + ..Default::default() + }, + ..Default::default() + }); + let _ = deno_runner.run(test_code, None, None).await.unwrap(); + + // Verify cache directory contains files + let storage = DenoExecutionStorage::new(ExecutionContext { + storage: test_dir.clone(), + ..Default::default() + }); + + assert!(storage.deno_cache.exists()); + let cache_files = std::fs::read_dir(&storage.deno_cache).unwrap(); + assert!(cache_files.count() > 0); + + // Clean up test directory + std::fs::remove_dir_all(test_dir).unwrap(); } diff --git a/libs/shinkai-tools-runner/src/tools/deno_runner_options.rs b/libs/shinkai-tools-runner/src/tools/deno_runner_options.rs index 7731ea0..da96cdb 100644 --- a/libs/shinkai-tools-runner/src/tools/deno_runner_options.rs +++ b/libs/shinkai-tools-runner/src/tools/deno_runner_options.rs @@ -1,14 +1,20 @@ use std::path::PathBuf; +use super::execution_context::ExecutionContext; + #[derive(Clone)] pub struct DenoRunnerOptions { - pub binary_path: PathBuf, + pub context: ExecutionContext, + pub deno_binary_path: PathBuf, + pub deno_image_name: String, } impl Default for DenoRunnerOptions { fn default() -> Self { Self { - binary_path: PathBuf::from(if cfg!(windows) { + context: ExecutionContext::default(), + deno_image_name: String::from("denoland/deno:alpine-2.0.6"), + deno_binary_path: PathBuf::from(if cfg!(windows) { "./shinkai-tools-runner-resources/deno.exe" } else { "./shinkai-tools-runner-resources/deno" diff --git a/libs/shinkai-tools-runner/src/tools/execution_context.rs b/libs/shinkai-tools-runner/src/tools/execution_context.rs new file mode 100644 index 0000000..7025a0d --- /dev/null +++ b/libs/shinkai-tools-runner/src/tools/execution_context.rs @@ -0,0 +1,21 @@ +use std::path::PathBuf; + +#[derive(Clone)] +pub struct ExecutionContext { + pub context_id: String, + pub execution_id: String, + pub code_id: String, + pub storage: PathBuf, +} + +impl Default for ExecutionContext { + fn default() -> Self { + Self { + context_id: nanoid::nanoid!(), + execution_id: nanoid::nanoid!(), + code_id: nanoid::nanoid!(), + storage: PathBuf::from("./shinkai-tools-runner-execution-storage") + .join(nanoid::nanoid!()), + } + } +} diff --git a/libs/shinkai-tools-runner/src/tools/mod.rs b/libs/shinkai-tools-runner/src/tools/mod.rs index 32ee1a1..54f6471 100644 --- a/libs/shinkai-tools-runner/src/tools/mod.rs +++ b/libs/shinkai-tools-runner/src/tools/mod.rs @@ -1,6 +1,9 @@ -pub mod tool; +pub mod container_utils; +pub mod deno_execution_storage; +pub mod deno_runner; +pub mod deno_runner_options; +pub mod execution_context; +pub mod execution_error; pub mod run_result; +pub mod tool; pub mod tool_definition; -pub mod execution_error; -pub mod deno_runner_options; -pub mod deno_runner; diff --git a/libs/shinkai-tools-runner/src/tools/tool.rs b/libs/shinkai-tools-runner/src/tools/tool.rs index 1f07e27..00c8fa7 100644 --- a/libs/shinkai-tools-runner/src/tools/tool.rs +++ b/libs/shinkai-tools-runner/src/tools/tool.rs @@ -50,11 +50,12 @@ impl Tool { .map_err(|e| ExecutionError::new(format!("failed to run deno: {}", e), None))?; let result_text = result - .lines() + .iter() .skip_while(|line| !line.contains("")) .skip(1) .take_while(|line| !line.contains("")) - .collect::>() + .map(|s| s.to_string()) + .collect::>() .join("\n"); log::info!("result text: {}", result_text); @@ -75,7 +76,7 @@ impl Tool { &self, envs: Option>, parameters: Value, - max_execution_time_s: Option, + max_execution_time_ms: Option, ) -> Result { log::info!("preparing to run tool"); log::info!("configurations: {}", self.configurations.to_string()); @@ -102,19 +103,20 @@ impl Tool { .replace("\\", "\\\\"), ); let result = deno_runner - .run(&code, envs, max_execution_time_s) + .run(&code, envs, max_execution_time_ms) .await .map_err(|e| ExecutionError::new(format!("failed to run deno: {}", e), None))?; let result_text = result - .lines() + .iter() .skip_while(|line| !line.contains("")) .skip(1) .take_while(|line| !line.contains("")) - .collect::>() + .map(|s| s.to_string()) + .collect::>() .join("\n"); - log::info!("result text: {}", result_text); + log::info!("result text: {:?}", result); let result: Value = serde_json::from_str(&result_text).map_err(|e| { log::info!("failed to parse result: {}", e); diff --git a/libs/shinkai-tools-runner/src/tools/tool.test.rs b/libs/shinkai-tools-runner/src/tools/tool.test.rs index a5c063d..b8f78d3 100644 --- a/libs/shinkai-tools-runner/src/tools/tool.test.rs +++ b/libs/shinkai-tools-runner/src/tools/tool.test.rs @@ -2,7 +2,10 @@ use std::collections::HashMap; use serde_json::Value; -use crate::tools::tool::Tool; +use crate::tools::{ + deno_runner_options::DenoRunnerOptions, + execution_context::ExecutionContext, tool::Tool, +}; #[tokio::test] async fn get_tool_definition() { @@ -66,7 +69,102 @@ async fn shinkai_tool_with_env() { envs.insert("BAR".to_string(), "bar".to_string()); let run_result = tool .run(Some(envs), serde_json::json!({ "name": "world" }), None) - .await - .unwrap(); - assert_eq!(run_result.data["foo"], "bar"); + .await; + assert!(run_result.is_ok()); + assert_eq!(run_result.unwrap().data["foo"], "bar"); +} + +#[tokio::test] +async fn shinkai_tool_run_concurrency() { + let _ = env_logger::builder() + .filter_level(log::LevelFilter::Info) + .is_test(true) + .try_init(); + let js_code1 = r#" + import axios from 'npm:axios'; + async function run(configurations, params) { + const result = await axios.get('https://jsonplaceholder.typicode.com/todos/1') + .then(response => { + return { + status: response.status, + data: response.data + }; + }); + return result; + } + "#; + let js_code2 = r#" + import _ from 'npm:lodash'; + function run(configurations, params) { + return { + foo: _.add(1, 2) + }; + } + "#; + + let js_code3 = r#" + import { sum } from 'npm:mathjs'; + function run(configurations, params) { + return { + foo: sum([1, 2, 3, 4]) + }; + } + "#; + + let execution_storage = "./shinkai-tools-runner-execution-storage/concurrent-runs"; + let context_id = nanoid::nanoid!(); + let execution_id = nanoid::nanoid!(); + let tool1 = Tool::new( + js_code1.to_string(), + serde_json::Value::Null, + Some(DenoRunnerOptions { + context: ExecutionContext { + storage: execution_storage.into(), + execution_id: context_id.clone(), + context_id: execution_id.clone(), + code_id: "js_code1".into(), + }, + ..Default::default() + }), + ); + let tool2 = Tool::new( + js_code2.to_string(), + serde_json::Value::Null, + Some(DenoRunnerOptions { + context: ExecutionContext { + storage: execution_storage.into(), + execution_id: context_id.clone(), + context_id: execution_id.clone(), + code_id: "js_code2".into(), + }, + ..Default::default() + }), + ); + let tool3 = Tool::new( + js_code3.to_string(), + serde_json::Value::Null, + Some(DenoRunnerOptions { + context: ExecutionContext { + storage: execution_storage.into(), + execution_id: context_id.clone(), + context_id: execution_id.clone(), + code_id: "js_code3".into(), + }, + ..Default::default() + }), + ); + + let (result1, result2, result3) = tokio::join!( + tool1.run(None, serde_json::json!({ "name": "world" }), None), + tool2.run(None, serde_json::Value::Null, None), + tool3.run(None, serde_json::Value::Null, None) + ); + + let run_result1 = result1.unwrap(); + let run_result2 = result2.unwrap(); + let run_result3 = result3.unwrap(); + + assert_eq!(run_result1.data["status"], 200); + assert_eq!(run_result2.data["foo"], 3); + assert_eq!(run_result3.data["foo"], 10); }