from pathlib import Path
import sys,re
s=Path(sys.argv[1]);f=s/'frontend';rp=s/'relay_server_clean.py';r=rp.read_text(encoding='utf-8')
r=re.sub(r'(?m)^VERSION\s*=\s*["\'][^"\']+["\']','VERSION  = "2.4.9.420-feed-first-paint-classic-security-menu"',r,count=1)
block=(Path(__file__).with_name('v249420_server_routes.txt')).read_text(encoding='utf-8')
if 'BEGIN V249420_FEED_FIRST_PAINT_CLASSIC_SECURITY' not in r:r+=block
rp.write_text(r,encoding='utf-8')
h=(f/'index.html').read_text(encoding='utf-8');g=(f/'js/final_guard_v249420.js').read_text(encoding='utf-8')
assert h.count('final_guard_v249420.js')==1
assert not re.search(r'final_guard_v24941[2-9]\.js',h)
assert 'OK-ITHAKI V249420 ·' in h
assert 'feed-first-paint-ready' in g and 'classic-security-menu-open' in g and 'ithOnlyEncryptionLockV249420' in g
print('PATCH_SERVER_V249420=OK')
