import sys
sys.stdout = open(1, 'w', encoding='utf-8', closefd=False)

with open('C:/Users/YZKJ/.openclaw/workspace/course-poster-noqr.html','r',encoding='utf-8') as f:
    content = f.read()

# Replace the drink section inline - find the text between "<!-- 赠饮 -->" and the closing </body>
start_marker = '    <!-- 赠饮 -->'
end_marker = '</div>\n</div>\n</body>'

start_idx = content.find(start_marker)
end_idx = content.rfind(end_marker)

if start_idx > 0 and end_idx > start_idx:
    # Extract everything before and after
    before = content[:start_idx]
    after = content[end_idx:]
    
    new_section = '''    <!-- 赠饮 -->
    <div class="section-label" style="margin-top:24px">\u2728 报名赠饮</div>
    <div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:14px;padding:16px">
      <div style="display:flex;gap:14px;align-items:center;margin-bottom:12px">
        <div style="width:80px;height:80px;min-width:80px;border-radius:12px;overflow:hidden">
          <img src="drink-photo.jpg" alt="原点" style="width:100%;height:100%;object-fit:cover">
        </div>
        <div>
          <div style="display:flex;gap:8px;align-items:baseline;margin-bottom:2px">
            <span style="font-size:14px;font-weight:600">\U0001f378 鸡尾酒 · 原点</span>
            <span style="font-size:11px;color:#818cf8">\uffe558</span>
          </div>
          <div style="font-size:12px;color:#94a3b8;line-height:1.5">自制红茶金酒、柠檬汁、蜂蜜、苏打水</div>
        </div>
      </div>
      <div style="display:flex;gap:12px;align-items:flex-start">
        <div style="width:32px;height:32px;min-width:32px;border-radius:50%;background:linear-gradient(135deg,rgba(52,211,153,0.2),rgba(16,185,129,0.2));border:1px solid rgba(52,211,153,0.3);display:flex;align-items:center;justify-content:center;font-size:16px">\U0001f379</div>
        <div>
          <div style="font-size:14px;font-weight:600;margin-bottom:2px">无酒精饮品 · 夜夏</div>
          <div style="font-size:12px;color:#94a3b8;line-height:1.5">菠萝汁、芒果汁、柠檬汁、椰子糖</div>
        </div>
      </div>
      <div style="font-size:12px;color:#818cf8;text-align:center;padding-top:12px;margin-top:10px;border-top:1px solid rgba(255,255,255,0.04)">\U0001f381 报名即赠，二选一</div>
    </div>
'''
    
    content = before + new_section + after
    
    with open('C:/Users/YZKJ/.openclaw/workspace/course-poster-noqr.html','w',encoding='utf-8') as f:
        f.write(content)
    print('Done! Replaced drink section with photo')
else:
    print(f'Start marker found: {start_idx > 0}')
    print(f'End marker found: {end_idx > start_idx}')
