with open('/tmp/inquiry.html','r',encoding='utf-8') as f:
    h = f.read()

# 1. Remove the mindmap JS from inside the D3 script tag (wrong location)
#    The D3 tag should be: <script src="...d3.min.js"></script>
#    But currently it has the whole mindmap JS in it.
#    Find the bad injection:
import re
bad_start = h.find('<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js">')
bad_end = h.find('</script>', bad_start) + len('</script>')
bad_section = h[bad_start:bad_end]
print(f"Bad section length: {len(bad_section)}")
print(f"Bad section first 100: {bad_section[:100]}")
print(f"Bad section last 100: {bad_section[-100:]}")

# Replace with clean D3 tag
correct_d3_tag = '<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script>'
h = h[:bad_start] + correct_d3_tag + h[bad_end:]
print(f"After fix: {len(h)} bytes")

# 2. Verify the mindmap function is NOT in the file anymore
print("renderSellerMindmap in file:", 'function renderSellerMindmap' in h)
