no_name on Nostr: #mediagallery ...
#mediagallery
data:text/html;base64,PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPm1lZGlhPC90aXRsZT4KICAgIDxzdHlsZT4KICAgIGJvZHkgewogICAgICBtYXJnaW46IDA7CiAgICAgIHBhZGRpbmc6IDIuMmVtOwogICAgICBiYWNrZ3JvdW5kOiBibGFjazsgCiAgICAgIGNvbG9yOiAjZmZmOwogICAgICBmb250LWZhbWlseTogTm90byBTZXJpZjsKICAgICAgbWluLWhlaWdodDogY2FsYyggMTAwdmggLSA1ZW0gKTsKICAgIH0KICAgICNtZWRpYSA+IGRpdiB7CiAgICAgIGRpc3BsYXk6IGlubGluZS1ibG9jazsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgfQogICAgI2NvdW50ZXJzIHsKICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICBib3R0b206IDA7CiAgICAgIGxlZnQ6IDA7CiAgICAgIHotaW5kZXg6IDE7CiAgICB9CiAgICAuY291bnRlciwgCiAgICAuY291bnRlciAudGl0bGUsCiAgICAjY2hhdF9tc2csCiAgICBib2R5Om5vdCgubWF4aW1pemUtY2hhdCkgI2NoYXRfbXNnIGgyLAogICAgYm9keSAuY2xvc2UgewogICAgICBiYWNrZ3JvdW5kOiAjMjIyOwogICAgfQogICAgLmNvdW50ZXIgewogICAgICBjb2xvcjogcmdiKDkwLCAyNTUsIDkwKTsKICAgICAgd2lkdGg6IDEuOWVtOwogICAgICBoZWlnaHQ6IDIuMmVtOwogICAgICBwYWRkaW5nLXJpZ2h0OiAuM2VtOwogICAgfQogICAgLmNvdW50ZXIgLnRpdGxlLAogICAgI3RpdGxlLAogICAgI21lZGlhIC50YWdzLCAKICAgICNtc2dfZm9ybSwKICAgICNtc2dfbGlzdCB7CiAgICAgIHBvc2l0aW9uOiBhYnNvbHV0ZTsKICAgIH0KICAgIC5jb3VudGVyIC50aXRsZSB7CiAgICAgIGxlZnQ6IDIuMmVtOwogICAgICBtYXgtd2lkdGg6IDUwdnc7CiAgICAgIHRleHQtb3ZlcmZsb3c6IGVsbGlwc2lzOwogICAgICBvdmVyZmxvdzogaGlkZGVuOwogICAgICB3aGl0ZS1zcGFjZTogbm93cmFwOwogICAgICBwYWRkaW5nOiAwIC4zZW07CiAgICAgIGRpc3BsYXk6IG5vbmU7CiAgICB9CiAgICAuY291bnRlcjpob3ZlciAudGl0bGUgewogICAgICBkaXNwbGF5OiBibG9jazsKICAgIH0KICAgIC5jb3VudGVyIHNwYW4gewogICAgICBmbG9hdDogbGVmdDsKICAgICAgbGluZS1oZWlnaHQ6IDIuMmVtOwogICAgfQogICAgLmNvdW50ZXIgc3Bhbi5jb3VudCB7CiAgICAgIHRleHQtYWxpZ246IGNlbnRlcjsKICAgICAgd2lkdGg6IDIuMmVtOwogICAgfQogICAgI3RpdGxlIHsKICAgICAgcGFkZGluZzogLjJlbTsKICAgICAgbGVmdDogMDsKICAgICAgdG9wOiAwOwogICAgICB0ZXh0LW92ZXJmbG93OiBlbGxpcHNpczsKICAgICAgd2hpdGUtc3BhY2U6IG5vd3JhcDsKICAgICAgb3ZlcmZsb3c6IGhpZGRlbjsKICAgICAgcmlnaHQ6IDRlbTsKICAgIH0KICAgICNtZWRpYSAudGFncyB7CiAgICAgIHJpZ2h0OiAwOwogICAgICBib3R0b206IDA7CiAgICAgIHdoaXRlLXNwYWNlOiBub3dyYXA7CiAgICAgIGJhY2tncm91bmQ6ICMwMDA7CiAgICAgIG92ZXJmbG93OiBoaWRkZW47CiAgICAgIG1heC13aWR0aDogMTAwJTsKICAgICAgdGV4dC1hbGlnbjogcmlnaHQ7CiAgICB9CiAgICAudGFncyA+IGE6bm90KDpmaXJzdC1jaGlsZCkgewogICAgICBtYXJnaW4tbGVmdDogLjVlbTsKICAgIH0KICAgIGJvZHkubWF4aW1pemUtY2hhdCB7CiAgICAgIHBhZGRpbmctcmlnaHQ6IGNhbGMoIDMwdncgKyAyZW0gKTsKICAgIH0KICAgIGEgewogICAgICBjb2xvcjogaW5oZXJpdDsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgfQogICAgaDIgewogICAgICBmb250LXNpemU6IDFlbTsKICAgIH0KICAgICNtc2dfZm9ybSB7CiAgICAgIGJvdHRvbTogMDsKICAgICAgbWFyZ2luOiAxZW07CiAgICB9CiAgICAjbXNnX2Zvcm0gLnN1Ym1pdCB7CiAgICAgIHdpZHRoOiAzZW07CiAgICB9CiAgICAjbXNnX2lucHV0IHsKICAgICAgd2lkdGg6IGNhbGMoIDMwdncgLSA3ZW0gKTsKICAgIH0KICAgICNjaGF0X21zZyB7CiAgICAgIHdpZHRoOiAzMHZ3OwogICAgICB3b3JkLXdyYXA6IGJyZWFrLXdvcmQ7CiAgICAgIHJpZ2h0OiBjYWxjKCAtMzB2dyArIDRlbSApOwogICAgICBwb3NpdGlvbjogZml4ZWQ7CiAgICAgIHRvcDogMDsKICAgICAgYm90dG9tOiAwOwogICAgfQogICAgI21zZ19saXN0IHsKICAgICAgb3ZlcmZsb3c6IGF1dG87CiAgICAgIHRvcDogM2VtOwogICAgICBib3R0b206IDNlbTsKICAgICAgcmlnaHQ6IDA7CiAgICAgIHdpZHRoOiAzMHZ3OwogICAgfQogICAgLm1heGltaXplLWNoYXQgI2NoYXRfbXNnIHsKICAgICAgcmlnaHQ6IDA7CiAgICAgIG9wYWNpdHk6IDE7CiAgICB9CiAgICBib2R5Om5vdCgubWF4aW1pemUtY2hhdCkgI2NoYXRfbXNnIGgyIHsKICAgICAgZm9udC1zaXplOiAxLjZlbTsKICAgICAgcm90YXRlOiA5MGRlZzsKICAgICAgd2lkdGg6IDEwMHZoOwogICAgICB0ZXh0LWFsaWduOiBjZW50ZXI7CiAgICAgIG1hcmdpbjogMDsKICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICB0b3A6IGNhbGMoIDUwdmggLSAxZW0gKTsKICAgICAgbWFyZ2luLWxlZnQ6IGNhbGMoIC01MHZoICsgMS4xZW0gKTsKICAgICAgei1pbmRleDogMTsKICAgICAgcGFkZGluZzogLjVlbTsKICAgICAgY29sb3I6ICNhYWE7CiAgICB9CiAgICAjY2hhdF9tc2cgcCwKICAgICNjaGF0X21zZyBoMiB7CiAgICAgIG1hcmdpbjogMWVtOwogICAgfQogICAgaW1nLCB2aWRlbyB7CiAgICAgIGhlaWdodDogMzN2aDsKICAgICAgbWF4LXdpZHRoOiA1MHZ3OwogICAgfQogICAgI21lZGlhIGRpdi5tYXhpbWl6ZSB7CiAgICAgIHBvc2l0aW9uOiBmaXhlZDsKICAgICAgei1pbmRleDogMTsKICAgICAgd2lkdGg6IDEwMCU7CiAgICAgIGhlaWdodDogMTAwJTsKICAgICAgYmFja2dyb3VuZDogcmdiYSgwLCAwLCAwLCAuOCk7CiAgICAgIHRleHQtYWxpZ246IGNlbnRlcjsKICAgICAgbGVmdDogMDsKICAgICAgdG9wOiAwOwogICAgfSAKICAgIC5tYXhpbWl6ZSA+IGEgewogICAgICB3aWR0aDogMTAwJTsKICAgICAgaGVpZ2h0OiAxMDAlOwogICAgfQogICAgLm1heGltaXplID4gYSBpbWcsIAogICAgLm1heGltaXplID4gYSB2aWRlbyB7CiAgICAgIG1heC13aWR0aDogMTAwdnc7CiAgICAgIG1heC1oZWlnaHQ6IDEwMHZoOyAKICAgICAgZGlzcGxheTogaW5saW5lOwogICAgfQogICAgLm1heGltaXplID4gYSBpbWcgewogICAgICBoZWlnaHQ6IGF1dG87CiAgICB9CiAgICAubWF4aW1pemUgPiBhIHZpZGVvIHsKICAgICAgaGVpZ2h0OiAxMDB2aDsgCiAgICB9CiAgICBib2R5IC5jbG9zZSB7IAogICAgICBkaXNwbGF5OiBub25lOwogICAgICBwb3NpdGlvbjogZml4ZWQ7CiAgICAgIHRvcDogMDsKICAgICAgbGVmdDogMDsKICAgICAgd2lkdGg6IDJlbTsKICAgICAgaGVpZ2h0OiAyZW07CiAgICAgIHotaW5kZXg6IDI7CiAgICAgIGxpbmUtaGVpZ2h0O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UgPSB0aGlzLmRhdGFzZXQub3JpZ2luYWxfdXJsICYmICJwcm94aWVkX21lZGlhX2NvdW50IiB8fCAibWVkaWFfY291bnQiCiAgICAgIGNvbnN0IG1lZGlhX2NvdW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiIyIgKyB0eXBlICsiIHNwYW4iKQogICAgICBtZWRpYV9jb3VudC5pbm5lclRleHQgPSBwYXJzZUludChtZWRpYV9jb3VudC5pbm5lclRleHQsIDEwKSArIDEKICAgIH0KICAgIAogICAgZnVuY3Rpb24gbWVkaWFfZXJyb3IoZWwsIHVybCwgcHJveHkpewogICAgICBpZihlbC5kYXRhc2V0LmFsdHVybHMpewogICAgICAgIGxldCBhbHR1cmxzID0gSlNPTi5wYXJzZShlbC5kYXRhc2V0LmFsdHVybHMpCiAgICAgICAgZWwuc3JjID0gYWx0dXJscy5zaGlmdCgpCiAgICAgICAgZWwuZGF0YXNldC5hbHR1cmxzID0gSlNPTi5zdHJpbmdpZnkoYWx0dXJscykKICAgICAgICByZXR1cm4KICAgICAgfQogICAgICBpZihwcm94eSAmJiAhZWwuZGF0YXNldC5vcmlnaW5hbF91cmwpewogICAgICAgIGVsLmRhdGFzZXQub3JpZ2luYWxfdXJsID0gdXJsCiAgICAgICAgcHJveGllZF9tZWRpYV9jb3VudAogICAgICAgIGVsLnNyYyA9IHByb3h5X3VybCh1cmwpCiAgICAgICAgcmV0dXJuCiAgICAgIH0KICAgICAgCiAgICAgIGVsLnBhcmVudEVsZW1lbnQuc3R5bGUuZGlzcGxheSA9ICJub25lIgogICAgICBjb25zdCBsb2FkX2Vycm9ycyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoIiNsb2FkX2Vycm9ycyBzcGFuIikKICAgICAgbG9hZF9lcnJvcnMuaW5uZXJUZXh0ID0gcGFyc2VJbnQobG9hZF9lcnJvcnMuaW5uZXJUZXh0LCAxMCkgKyAxCiAgICB9CgogICAgZnVuY3Rpb24gbWFrZV9lbGVtZW50KHBhcmVudF9lbCwgYmVjaDMyaWQsIHR5cGUsIHVybCwgZXZlbnQsIHByb3h5LCBpbmRleCl7CiAgICAgIGxldCBjb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKQogICAgICBsZXQgY2xvc2UgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuY2xvc2UiKS5jbG9uZU5vZGUodHJ1ZSkKICAgICAgbGV0IGxpbmtfZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJhIikKICAgICAgbGlua19lbC5ocmVmID0gIndlYitub3N0cjoiICsgYmVjaDMyaWQKICAgICAgbGV0IGVsID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCh0eXBlKQogICAgICBsZXQgdGFnc19lbCA9IGNyZWF0ZV90YWdzX2VsKGV2ZW50LnRhZ3MuZmlsdGVyKHQgPT4gdFswXSA9PSAidCIpLm1hcCh0ID0+IHRbMV0pLCB0YWdzX2xjLCAyKQogICAgICBlbC5kYXRhc2V0LnNyYyA9IHVybAogICAgICBlbC5sb2FkaW5nID0gImxhenkiCiAgICAgIGVsLm9ubG9hZCA9IG1lZGlhX2xvYWQKICAgICAgZWwub25lcnJvciA9ICgpID0+IG1lZGlhX2Vycm9yKGVsLCB1cmwsIHByb3h5KQogICAgICAKICAgICAgbGlua19lbC5hcHBlbmQoZWwpCiAgICAgIGNvbnRhaW5lci5hcHBlbmQobGlua19lbCwgdGFnc19lbCwgY2xvc2UpCiAgICAgIGFkZF9lbGVtZW50KHBhcmVudF9lbCwgY29udGFpbmVyLCBldmVudCwgdHJ1ZSwgaW5kZXgpCiAgICAgIAogICAgICBjb250YWluZXIub25jbGljayA9IGNsb3NlLm9uY2xpY2sgPSBmdW5jdGlvbihlKXsKICAgICAgICBpZihlLnRhcmdldC5wYXJlbnRFbGVtZW50LmNsYXNzTGlzdC5jb250YWlucygidGFncyIpKXsKICAgICAgICAgIHJldHVybgogICAgICAgIH0KICAgICAgICAKICAgICAgICBlLnByZXZlbnREZWZhdWx0KCkKICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpCiAgICAgICAgY29udGFpbmVyLmNsYXNzTGlzdC50b2dnbGUoIm1heGltaXplIikKICAgICAgICBjb250YWluZXIucXVlcnlTZWxlY3RvcigidmlkZW8iKT8ucGF1c2UoKQogICAgICB9CgogICAgICByZXR1cm4gW2xpbmtfZWwsIGVsXQogICAgfQogICAgCiAgICBmdW5jdGlvbiB0b19oZXgoYnVmZmVyKSB7CiAgICAgIHJldHVybiBBcnJheS5wcm90b3R5cGUubWFwLmNhbGwoYnVmZmVyLCB4ID0+ICgnMDAnICsgeC50b1N0cmluZygxNikpLnNsaWNlKC0yKSkuam9pbignJyk7CiAgICB9CiAgICAKICAgIGFzeW5jIGZ1bmN0aW9uIG1lZGlhX2hlYWRlcnNfcmVxKGxpbmtzLCBwYXJlbnRfZWwsIGJlY2gzMmlkLCBldmVudCwgaW5kZXgpewogICAgICB0cnl7CiAgICAgICAgbGV0IGxpbmsgPSBsaW5rcy5zaGlmdCgpCiAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGZldGNoKGxpbmssIHttZXRob2Q6ICdIRUFEJywgc2lnbmFsOiBBYm9ydFNpZ25hbC50aW1lb3V0KDIwMDApfSkKICAgICAgICAKICAgICAgICBpZihoYXNoX3BhcnRzWzFdICE9ICJ2MSIgJiYgcmVzLmhlYWRlcnMuZ2V0KCJjb250ZW50LXR5cGUiKS5pbmRleE9mKCJpbWFnZSIpID09IDAgJiYgY2FuX2FkZF9tZWRpYShldmVudCwgaW5kZXgpKXsKICAgICAgICAgIGxldCBlbCA9IG1ha2VfZWxlbWVudChwYXJlbnRfZWwsIGJlY2gzMmlkLCAiaW1nIiwgbGluaywgZXZlbnQsIHRydWUsIGluZGV4KQogICAgICAgICAgZWxbMV0uY3Jvc3NPcmlnaW4gPSAiYW5vbnltb3VzIgogICAgICAgIH0KICAgICAgICBpZihbInYiLCAidjEiXS5pbmNsdWRlcyhoYX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tZWRpYSIpLCBiZWNoMzJpZCwgZXZlbnQsIGkpCiAgICAgICAgICAgIH1dKQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSkKICAgICAgCiAgICAgIGlmKGV2ZW50LnRhZ3MuZmluZCh0ID0+IHRbMF0gPT0gImUiICYmIHRbMV0gPT0gY2hhdF9pZCkgJiYgIWRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJyNjaGF0X21zZyBbZGF0YS1pZD0iJyArIGV2ZW50LmlkICsnIl0nKSl7CiAgICAgICAgbGV0IHJvb3RfZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJwIikKICAgICAgICBsZXQgbmFtZV90YWcgPSBldmVudC50YWdzLmZpbmQodCA9PiB0WzBdID09ICJuYW1lIikKICAgICAgICByb290X2VsLmlubmVyVGV4dCA9IChuYW1lX3RhZyAmJiBuYW1lX3RhZ1sxXSB8fCBldmVudC5wdWJrZXkuc3Vic3RyKC01LCA1KSkgKyAiOiAiICsgZXZlbnQuY29udGVudC5yZXBsYWNlQWxsKC9cbi9nLCAiICIpCiAgICAgICAgCiAgICAgICAgZm9yKGxldCBsaW5rIG9mIGFsbF9saW5rcyl7CiAgICAgICAgICBsZXQgbCA9IGxpbmtbMF0udHJpbSgpCiAgICAgICAgICBsZXQgbGlua19lbCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImEiKQogICAgICAgICAgbGlua19lbC5ocmVmID0gbGlua1sxXS50cmltKCkKICAgICAgICAgIGxpbmtfZWwuaW5uZXJUZXh0ID0gbAogICAgICAgICAgcm9vdF9lbC5pbm5lckhUTUwgPSByb290X2VsLmlubmVySFRNTC5yZXBsYWNlKGwucmVwbGFjZUFsbCgiJiIsICImYW1wOyIpLCBsaW5rX2VsLm91dGVySFRNTCkKICAgICAgICB9CgogICAgICAgIGFkZF9lbGVtZW50KGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoIiNtc2dfbGlzdCIpLCByb290X2VsLCBldmVudCwgZmFs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IpLnZhbHVlKQogICAgICB0aGlzLnJlc2V0KCkKICAgIH0KICAgIAogICAgYWRkRXZlbnRMaXN0ZW5lcigiaGFzaGNoYW5nZSIsICgpID0+IGxvY2F0aW9uLnJlbG9hZCgpKQogICAgCiAgICBzb2NrZXRzLmZvckVhY2gocyA9PiB7CiAgICAgIHNbMF0ub25vcGVuID0gKCkgPT4gc29ja2V0X29wZW4ocykKICAgICAgc1swXS5vbmVycm9yID0gc29ja2V0X2Vycm9yCiAgICAgIHNbMF0ub25jbG9zZSA9IHNvY2tldF9jbG9zZQogICAgICBzWzBdLm9ubWVzc2FnZSA9IGUgPT4gdGFza19xdWV1ZS5wdXNoKFtudWxsLCAoKSA9PiBzb2NrZXRfbWVzc2FnZShlKV0pCiAgICB9KQogICAgCiAgICBydW5fdGFza19xdWV1ZSgpCiAgICA8L3NjcmlwdD4KICA8L2JvZHk+CjwvaHRtbD4=
Published at
2023-12-31 02:08:41Event JSON
{
"id": "b77de7bf30fd8c07db7d8f592152d22a0e098f2555ad25012684b5792f7fc799",
"pubkey": "ae8942b6dd585d633e7881791ab2fbde9edcb76dff5f0388872394a08132adf8",
"created_at": 1703988521,
"kind": 1,
"tags": [
[
"e",
"38aa13bcf5df8755288a32bfdd84409b5b57a25bd758bcc6b92de7901c586940",
"wss://feeds.nostr.band/popular",
"root"
],
[
"t",
"mediagallery"
]
],
"content": "#mediagallery\ndata:text/html;base64,PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPm1lZGlhPC90aXRsZT4KICAgIDxzdHlsZT4KICAgIGJvZHkgewogICAgICBtYXJnaW46IDA7CiAgICAgIHBhZGRpbmc6IDIuMmVtOwogICAgICBiYWNrZ3JvdW5kOiBibGFjazsgCiAgICAgIGNvbG9yOiAjZmZmOwogICAgICBmb250LWZhbWlseTogTm90byBTZXJpZjsKICAgICAgbWluLWhlaWdodDogY2FsYyggMTAwdmggLSA1ZW0gKTsKICAgIH0KICAgICNtZWRpYSA+IGRpdiB7CiAgICAgIGRpc3BsYXk6IGlubGluZS1ibG9jazsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgfQogICAgI2NvdW50ZXJzIHsKICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICBib3R0b206IDA7CiAgICAgIGxlZnQ6IDA7CiAgICAgIHotaW5kZXg6IDE7CiAgICB9CiAgICAuY291bnRlciwgCiAgICAuY291bnRlciAudGl0bGUsCiAgICAjY2hhdF9tc2csCiAgICBib2R5Om5vdCgubWF4aW1pemUtY2hhdCkgI2NoYXRfbXNnIGgyLAogICAgYm9keSAuY2xvc2UgewogICAgICBiYWNrZ3JvdW5kOiAjMjIyOwogICAgfQogICAgLmNvdW50ZXIgewogICAgICBjb2xvcjogcmdiKDkwLCAyNTUsIDkwKTsKICAgICAgd2lkdGg6IDEuOWVtOwogICAgICBoZWlnaHQ6IDIuMmVtOwogICAgICBwYWRkaW5nLXJpZ2h0OiAuM2VtOwogICAgfQogICAgLmNvdW50ZXIgLnRpdGxlLAogICAgI3RpdGxlLAogICAgI21lZGlhIC50YWdzLCAKICAgICNtc2dfZm9ybSwKICAgICNtc2dfbGlzdCB7CiAgICAgIHBvc2l0aW9uOiBhYnNvbHV0ZTsKICAgIH0KICAgIC5jb3VudGVyIC50aXRsZSB7CiAgICAgIGxlZnQ6IDIuMmVtOwogICAgICBtYXgtd2lkdGg6IDUwdnc7CiAgICAgIHRleHQtb3ZlcmZsb3c6IGVsbGlwc2lzOwogICAgICBvdmVyZmxvdzogaGlkZGVuOwogICAgICB3aGl0ZS1zcGFjZTogbm93cmFwOwogICAgICBwYWRkaW5nOiAwIC4zZW07CiAgICAgIGRpc3BsYXk6IG5vbmU7CiAgICB9CiAgICAuY291bnRlcjpob3ZlciAudGl0bGUgewogICAgICBkaXNwbGF5OiBibG9jazsKICAgIH0KICAgIC5jb3VudGVyIHNwYW4gewogICAgICBmbG9hdDogbGVmdDsKICAgICAgbGluZS1oZWlnaHQ6IDIuMmVtOwogICAgfQogICAgLmNvdW50ZXIgc3Bhbi5jb3VudCB7CiAgICAgIHRleHQtYWxpZ246IGNlbnRlcjsKICAgICAgd2lkdGg6IDIuMmVtOwogICAgfQogICAgI3RpdGxlIHsKICAgICAgcGFkZGluZzogLjJlbTsKICAgICAgbGVmdDogMDsKICAgICAgdG9wOiAwOwogICAgICB0ZXh0LW92ZXJmbG93OiBlbGxpcHNpczsKICAgICAgd2hpdGUtc3BhY2U6IG5vd3JhcDsKICAgICAgb3ZlcmZsb3c6IGhpZGRlbjsKICAgICAgcmlnaHQ6IDRlbTsKICAgIH0KICAgICNtZWRpYSAudGFncyB7CiAgICAgIHJpZ2h0OiAwOwogICAgICBib3R0b206IDA7CiAgICAgIHdoaXRlLXNwYWNlOiBub3dyYXA7CiAgICAgIGJhY2tncm91bmQ6ICMwMDA7CiAgICAgIG92ZXJmbG93OiBoaWRkZW47CiAgICAgIG1heC13aWR0aDogMTAwJTsKICAgICAgdGV4dC1hbGlnbjogcmlnaHQ7CiAgICB9CiAgICAudGFncyA+IGE6bm90KDpmaXJzdC1jaGlsZCkgewogICAgICBtYXJnaW4tbGVmdDogLjVlbTsKICAgIH0KICAgIGJvZHkubWF4aW1pemUtY2hhdCB7CiAgICAgIHBhZGRpbmctcmlnaHQ6IGNhbGMoIDMwdncgKyAyZW0gKTsKICAgIH0KICAgIGEgewogICAgICBjb2xvcjogaW5oZXJpdDsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgfQogICAgaDIgewogICAgICBmb250LXNpemU6IDFlbTsKICAgIH0KICAgICNtc2dfZm9ybSB7CiAgICAgIGJvdHRvbTogMDsKICAgICAgbWFyZ2luOiAxZW07CiAgICB9CiAgICAjbXNnX2Zvcm0gLnN1Ym1pdCB7CiAgICAgIHdpZHRoOiAzZW07CiAgICB9CiAgICAjbXNnX2lucHV0IHsKICAgICAgd2lkdGg6IGNhbGMoIDMwdncgLSA3ZW0gKTsKICAgIH0KICAgICNjaGF0X21zZyB7CiAgICAgIHdpZHRoOiAzMHZ3OwogICAgICB3b3JkLXdyYXA6IGJyZWFrLXdvcmQ7CiAgICAgIHJpZ2h0OiBjYWxjKCAtMzB2dyArIDRlbSApOwogICAgICBwb3NpdGlvbjogZml4ZWQ7CiAgICAgIHRvcDogMDsKICAgICAgYm90dG9tOiAwOwogICAgfQogICAgI21zZ19saXN0IHsKICAgICAgb3ZlcmZsb3c6IGF1dG87CiAgICAgIHRvcDogM2VtOwogICAgICBib3R0b206IDNlbTsKICAgICAgcmlnaHQ6IDA7CiAgICAgIHdpZHRoOiAzMHZ3OwogICAgfQogICAgLm1heGltaXplLWNoYXQgI2NoYXRfbXNnIHsKICAgICAgcmlnaHQ6IDA7CiAgICAgIG9wYWNpdHk6IDE7CiAgICB9CiAgICBib2R5Om5vdCgubWF4aW1pemUtY2hhdCkgI2NoYXRfbXNnIGgyIHsKICAgICAgZm9udC1zaXplOiAxLjZlbTsKICAgICAgcm90YXRlOiA5MGRlZzsKICAgICAgd2lkdGg6IDEwMHZoOwogICAgICB0ZXh0LWFsaWduOiBjZW50ZXI7CiAgICAgIG1hcmdpbjogMDsKICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICB0b3A6IGNhbGMoIDUwdmggLSAxZW0gKTsKICAgICAgbWFyZ2luLWxlZnQ6IGNhbGMoIC01MHZoICsgMS4xZW0gKTsKICAgICAgei1pbmRleDogMTsKICAgICAgcGFkZGluZzogLjVlbTsKICAgICAgY29sb3I6ICNhYWE7CiAgICB9CiAgICAjY2hhdF9tc2cgcCwKICAgICNjaGF0X21zZyBoMiB7CiAgICAgIG1hcmdpbjogMWVtOwogICAgfQogICAgaW1nLCB2aWRlbyB7CiAgICAgIGhlaWdodDogMzN2aDsKICAgICAgbWF4LXdpZHRoOiA1MHZ3OwogICAgfQogICAgI21lZGlhIGRpdi5tYXhpbWl6ZSB7CiAgICAgIHBvc2l0aW9uOiBmaXhlZDsKICAgICAgei1pbmRleDogMTsKICAgICAgd2lkdGg6IDEwMCU7CiAgICAgIGhlaWdodDogMTAwJTsKICAgICAgYmFja2dyb3VuZDogcmdiYSgwLCAwLCAwLCAuOCk7CiAgICAgIHRleHQtYWxpZ246IGNlbnRlcjsKICAgICAgbGVmdDogMDsKICAgICAgdG9wOiAwOwogICAgfSAKICAgIC5tYXhpbWl6ZSA+IGEgewogICAgICB3aWR0aDogMTAwJTsKICAgICAgaGVpZ2h0OiAxMDAlOwogICAgfQogICAgLm1heGltaXplID4gYSBpbWcsIAogICAgLm1heGltaXplID4gYSB2aWRlbyB7CiAgICAgIG1heC13aWR0aDogMTAwdnc7CiAgICAgIG1heC1oZWlnaHQ6IDEwMHZoOyAKICAgICAgZGlzcGxheTogaW5saW5lOwogICAgfQogICAgLm1heGltaXplID4gYSBpbWcgewogICAgICBoZWlnaHQ6IGF1dG87CiAgICB9CiAgICAubWF4aW1pemUgPiBhIHZpZGVvIHsKICAgICAgaGVpZ2h0OiAxMDB2aDsgCiAgICB9CiAgICBib2R5IC5jbG9zZSB7IAogICAgICBkaXNwbGF5OiBub25lOwogICAgICBwb3NpdGlvbjogZml4ZWQ7CiAgICAgIHRvcDogMDsKICAgICAgbGVmdDogMDsKICAgICAgd2lkdGg6IDJlbTsKICAgICAgaGVpZ2h0OiAyZW07CiAgICAgIHotaW5kZXg6IDI7CiAgICAgIGxpbmUtaGVpZ2h0OiAxLjhlbTsKICAgICAgdGV4dC1kZWNvcmF0aW9uOiBub25lOwogICAgICBmb250LXNpemU6IDJlbTsKICAgIH0KICAgIC5tYXhpbWl6ZSAuY2xvc2UgewogICAgICBkaXNwbGF5OiBibG9jazsKICAgIH0KICAgIDwvc3R5bGU+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPGRpdiBpZD0idGl0bGUiPjwvZGl2PgogICAgPGEgaHJlZj0iIyIgY2xhc3M9ImNsb3NlIj54PC9hPgogICAgPGRpdiBpZD0iY291bnRlcnMiPgogICAgICA8c2NyaXB0PgogICAgICBbImVycm9ycyIsICJsb2FkX2Vycm9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wgW10KICAgICAgbGV0IGVsID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpCiAgICAgIGVsLmNsYXNzTGlzdC5hZGQoInRhZ3MiKQogICAgICAKICAgICAgdGFncyA9IHRhZ3MuZmlsdGVyKCh0LCBpKSA9PiB7CiAgICAgICAgcmV0dXJuIHRhZ3MuaW5kZXhPZih0KSA9PSBpICYmIGV4Y2x1ZGVfdGFncy5pbmRleE9mKHQudG9Mb3dlckNhc2UoKSkgPT0gLTEKICAgICAgfSkuc2xpY2UoMCwgbGltaXQgfHwgMWUzKQoKICAgICAgdGFncy5mb3JFYWNoKHQgPT4gewogICAgICAgIGxldCB0YWdfbGluayA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImEiKQogICAgICAgIHRhZ19saW5rLmlubmVyVGV4dCA9ICIjIiArIHQKICAgICAgICB0YWdfbGluay5ocmVmID0gIiMiICsgZW5jb2RlVVJJQ29tcG9uZW50KHQpICsgKGhhc2hfcGFydHNbMV0gJiYgKCI7IiArIGhhc2hfcGFydHNbMV0pIHx8ICIiKQogICAgICAgIGVsLmFwcGVuZCh0YWdfbGluaykKICAgICAgfSkKICAgICAgCiAgICAgIHJldHVybiBlbAogICAgfQogICAgCiAgICBmdW5jdGlvbiBtZWRpYV9sb2FkKCl7CiAgICAgIGNvbnN0IHR5cGUgPSB0aGlzLmRhdGFzZXQub3JpZ2luYWxfdXJsICYmICJwcm94aWVkX21lZGlhX2NvdW50IiB8fCAibWVkaWFfY291bnQiCiAgICAgIGNvbnN0IG1lZGlhX2NvdW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiIyIgKyB0eXBlICsiIHNwYW4iKQogICAgICBtZWRpYV9jb3VudC5pbm5lclRleHQgPSBwYXJzZUludChtZWRpYV9jb3VudC5pbm5lclRleHQsIDEwKSArIDEKICAgIH0KICAgIAogICAgZnVuY3Rpb24gbWVkaWFfZXJyb3IoZWwsIHVybCwgcHJveHkpewogICAgICBpZihlbC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ICAgbGV0IGVsID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCh0eXBlKQogICAgICBsZXQgdGFnc19lbCA9IGNyZWF0ZV90YWdzX2VsKGV2ZW50LnRhZ3MuZmlsdGVyKHQgPT4gdFswXSA9PSAidCIpLm1hcCh0ID0+IHRbMV0pLCB0YWdzX2xjLCAyKQogICAgICBlbC5kYXRhc2V0LnNyYyA9IHVybAogICAgICBlbC5sb2FkaW5nID0gImxhenkiCiAgICAgIGVsLm9ubG9hZCA9IG1lZGlhX2xvYWQKICAgICAgZWwub25lcnJvciA9ICgpID0+IG1lZGlhX2Vycm9yKGVsLCB1cmwsIHByb3h5KQogICAgICAKICAgICAgbGlua19lbC5hcHBlbmQoZWwpCiAgICAgIGNvbnRhaW5lci5hcHBlbmQobGlua19lbCwgdGFnc19lbCwgY2xvc2UpCiAgICAgIGFkZF9lbGVtZW50KHBhcmVudF9lbCwgY29udGFpbmVyLCBldmVudCwgdHJ1ZSwgaW5kZXgpCiAgICAgIAogICAgICBjb250YWluZXIub25jbGljayA9IGNsb3NlLm9uY2xpY2sgPSBmdW5jdGlvbihlKXsKICAgICAgICBpZihlLnRhcmdldC5wYXJlbnRFbGVtZW50LmNsYXNzTGlzdC5jb250YWlucygidGFncyIpKXsKICAgICAgICAgIHJldHVybgogICAgICAgIH0KICAgICAgICAKICAgICAgICBlLnByZXZlbnREZWZhdWx0KCkKICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpCiAgICAgICAgY29udGFpbmVyLmNsYXNzTGlzdC50b2dnbGUoIm1heGltaXplIikKICAgICAgICBjb250YWluZXIucXVlcnlTZWxlY3RvcigidmlkZW8iKT8ucGF1c2UoKQogICAgICB9CgogICAgICByZXR1cm4gW2xpbmtfZWwsIGVsXQogICAgfQogICAgCiAgICBmdW5jdGlvbiB0b19oZXgoYnVmZmVyKSB7CiAgICAgIHJldHVybiBBcnJheS5wcm90b3R5cGUubWFwLmNhbGwoYnVmZmVyLCB4ID0+ICgnMDAnIC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AgICAgICBsZXQgbmFtZV90YWcgPSBldmVudC50YWdzLmZpbmQodCA9PiB0WzBdID09ICJuYW1lIikKICAgICAgICByb290X2VsLmlubmVyVGV4dCA9IChuYW1lX3RhZyAmJiBuYW1lX3RhZ1sxXSB8fCBldmVudC5wdWJrZXkuc3Vic3RyKC01LCA1KSkgKyAiOiAiICsgZXZlbnQuY29udGVudC5yZXBsYWNlQWxsKC9cbi9nLCAiICIpCiAgICAgICAgCiAgICAgICAgZm9yKGxldCBsaW5rIG9mIGFsbF9saW5rcyl7CiAgICAgICAgICBsZXQgbCA9IGxpbmtbMF0udHJpbSgpCiAgICAgICAgICBsZXQgbGlua19lbCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImEiKQogICAgICAgICAgbGlua19lbC5ocmVmID0gbGlua1sxXS50cmltKCkKICAgICAgICAgIGxpbmtfZWwuaW5uZXJUZXh0ID0gbAogICAgICAgICAgcm9vdF9lbC5pbm5lckhUTUwgPSByb290X2VsLmlubmVySFRNTC5yZXBsYWNlKGwucmVwbGFjZUFsbCgiJiIsICImYW1wOyIpLCBsaW5rX2VsLm91dGVySFRNTCkKICAgICAgICB9CgogICAgICAgIGFkZF9lbGVtZW50KGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoIiNtc2dfbGlzdCIpLCByb290X2VsLCBldmVudCwgZmFsc2UpCiAgICAgIH0KICAgIH0KCiAgICBhc3luYyBmdW5jdGlvbiBydW5fdGFza19xdWV1ZSgpewogICAgICBhd2FpdCB0YXNrX3F1ZXVlLnNoaWZ0KCk/LnBvcCgpKCkKICAgICAgbGV0IGVsID0gWy4uLmRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIltkYXRhLXNyY106bm90KFtzcmNdIildLnNoaWZ0KCkgfHwge30KICAgICAgZWwuc3JjID0gZWwuZGF0YXNldD8uc3JjCgogICAgICBpZih0YXNrX3F1ZXVlLmxlbmd0aCAlIDUgPT0gMCl7CiAgICAgICAgZG9jdW1lbnQuc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19xdWV1ZS5wdXNoKFtudWxsLCAoKSA9PiBzb2NrZXRfbWVzc2FnZShlKV0pCiAgICB9KQogICAgCiAgICBydW5fdGFza19xdWV1ZSgpCiAgICA8L3NjcmlwdD4KICA8L2JvZHk+CjwvaHRtbD4=",
"sig": "fd417c864b5a0c1fe489b09193bca218d1060b9a229e34a834990d53e5499324bd78a8a1ec70288bc8960a1e36594b56621bf134e6db8bebcf890bd1f98bb682"
}