import sys

with open('tmp_home_current.html', 'r', encoding='utf-8') as f:
    html = f.read()

img_block_str = """<!-- wp:group {"layout":{"type":"constrained","contentSize":"1100px"},"style":{"spacing":{"padding":{"top":"40px","bottom":"20px","left":"24px","right":"24px"}}}}} -->
<div class="wp-block-group" style="padding-top:40px;padding-right:24px;padding-bottom:20px;padding-left:24px">
<!-- wp:image {"align":"center"} -->
<figure class="wp-block-image aligncenter"><img src="/wp-content/uploads/2026/03/pasted-20260312-192203-5bf6a392.png" alt="Kevin McKeand" style="border-radius:16px;max-width:100%;height:auto;"/></figure>
<!-- /wp:image -->
</div>
<!-- /wp:group -->"""

if img_block_str in html:
    html = html.replace(img_block_str + '\n\n', '')
    html = html.replace(img_block_str + '\n', '')
    html = html.replace(img_block_str, '')
else:
    print("Error: Could not find exact image block string.")
    sys.exit(1)

new_img_block_str = img_block_str.replace('<!-- wp:image {"align":"center"} -->', '<!-- wp:image {"align":"center","width":"275px","className":"is-resized"} -->')
new_img_block_str = new_img_block_str.replace('<figure class="wp-block-image aligncenter">', '<figure class="wp-block-image aligncenter is-resized">')
new_img_block_str = new_img_block_str.replace('max-width:100%', 'width:275px;max-width:100%')

# Add the new block at the very top of the html
html = new_img_block_str + '\n\n' + html

old_saying = """<!-- wp:group {"style":{"spacing":{"padding":{"top":"60px","bottom":"60px","left":"24px","right":"24px"},"blockGap":"24px"}},"layout":{"type":"constrained","contentSize":"1400px"}} -->
<div class="wp-block-group" style="padding-top:60px;padding-right:24px;padding-bottom:60px;padding-left:24px"><!-- wp:heading {"level":2} -->
<h2>What they're Saying</h2>"""

new_saying = """<!-- wp:group {"style":{"spacing":{"padding":{"top":"60px","bottom":"0px","left":"24px","right":"24px"},"blockGap":"24px"}},"layout":{"type":"constrained","contentSize":"1400px"}} -->
<div class="wp-block-group" style="padding-top:60px;padding-right:24px;padding-bottom:0px;padding-left:24px"><!-- wp:heading {"level":2} -->
<h2>What they're Saying</h2>"""

if old_saying in html:
    html = html.replace(old_saying, new_saying)
else:
    print("Error: Could not find exact saying block string.")
    sys.exit(1)

with open('tmp_home_current.html', 'w', encoding='utf-8') as f:
    f.write(html)
print("Success.")
