import os

filepath = 'src/app/map/MapUI.tsx'
with open(filepath, 'r') as f:
    content = f.read()

calendar_html = """
        {/* Google Calendar Integration */}
        <div className="p-4 border-b border-slate-100">
          <h3 className="font-bold text-slate-900 mb-3 text-sm uppercase tracking-wider flex items-center gap-2">
            <svg className="w-4 h-4 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
            Schedule a Site Visit
          </h3>
          <p className="text-xs text-slate-500 mb-4">Pick an available time slot to schedule a guided tour of this property.</p>
          <div className="w-full h-[350px] rounded-xl overflow-hidden border border-slate-200">
            <iframe src="https://calendar.google.com/calendar/embed?src=en.indian%23holiday%40group.v.calendar.google.com&ctz=Asia%2FKolkata&showTitle=0&showNav=1&showDate=1&showPrint=0&showTabs=0&showCalendars=0&showTz=0&mode=WEEK" style={{border: 0}} width="100%" height="100%" frameBorder="0" scrolling="no"></iframe>
          </div>
        </div>
"""

# Insert before "Nearby Properties"
content = content.replace(
    'Nearby Properties</h3>',
    'Nearby Properties</h3>'
)

# Wait, let's just find the exact string for Nearby Properties
if "Nearby Properties" in content:
    content = content.replace(
        '<h3 className="font-black text-base mb-4 text-slate-900 px-1">Nearby Properties</h3>',
        calendar_html + '\n        <h3 className="font-black text-base mb-4 text-slate-900 px-1">Nearby Properties</h3>'
    )

with open(filepath, 'w') as f:
    f.write(content)
print("Calendar injected to MapUI.")
