from pathlib import Path
from bs4 import BeautifulSoup, NavigableString
import runpy, re
p=Path('/Users/iggy/.hermes/profiles/ignite_team/outbound/st-catherines-rendered-template-text-only.html')
html=p.read_text(errors='ignore')
# Use the full map from our text-only conversion.
rep=runpy.run_path('/Users/iggy/.hermes/profiles/ignite_team/outbound/st-catherines-copy-map.py')['replacements']
soup=BeautifulSoup(html,'html.parser')
# remove client-side component data noise; static rendered DOM remains
for tag in soup.find_all(['script','noscript']): tag.decompose()
if soup.head and not soup.head.find('base'):
    b=soup.new_tag('base',href='https://www.zeekrlife.com/')
    soup.head.insert(0,b)
# force pre-rendered animated items visible because JS has been removed
for el in soup.find_all(style=True):
    st=el['style']
    st=st.replace('opacity: 0;', 'opacity: 1;')
    st=re.sub(r'transform:\s*translate\(0px, 20px\);?', 'transform: none;', st)
    el['style']=st
# exact text node replacements, including short spec labels
changed=0
for node in soup.find_all(string=True):
    if not isinstance(node,NavigableString): continue
    if node.parent and node.parent.name in {'style','code','pre'}: continue
    text=str(node); s=text.strip()
    if s in rep:
        node.replace_with(text.replace(s, rep[s])); changed+=1
# Replace remaining footer/disclaimer visible blocks
for node in soup.find_all(string=True):
    if not isinstance(node,NavigableString): continue
    text=str(node)
    text=text.replace('Zeekr and/or its affiliates. All rights reserved.','St Catherine’s School example copy. All rights reserved.')
    text=text.replace('Disclaimer: Depending on where you are, information on this page may not be accurate for the models available in your local market. The availability of vehicle models, options, specifications and colours may vary from market to market and Zeekr reserves the right to make changes without notice. Vehicles may be shown with optional equipment that is not available in all markets. Images and videos are for illustrative purposes only. This website is governed by Zeekr’s Terms of use.','Disclaimer: This is concept copy prepared for layout review only. Details should be checked against St Catherine’s School admissions, curriculum and policy information before publication. Existing imagery remains unchanged in this mock-up and is used only to preserve the supplied page structure for discussion.')
    if text != str(node): node.replace_with(text)
if soup.title: soup.title.string='St Catherine’s School | Concept Page'
p.write_text(str(soup), encoding='utf-8')
print('changed',changed,'bytes',p.stat().st_size,'St Catherine',p.read_text(errors='ignore').count('St Catherine'),'Zeekr X',p.read_text(errors='ignore').count('Zeekr X'))
