import re

with open("resources/js/components/AdminDashboard.tsx", "r") as f:
    content = f.read()

# Find the start of the dashboard tab
start_str = "{activeTab === 'dashboard' && canAccess('dashboard') && ("
start_idx = content.find(start_str)

if start_idx == -1:
    print("Could not find start of dashboard tab")
    exit(1)

# Find the end of the dashboard tab (right before the orders tab)
end_str = "{activeTab === 'orders' && canAccess('orders') && ("
end_idx = content.find(end_str, start_idx)

if end_idx == -1:
    print("Could not find end of dashboard tab")
    exit(1)

# Extract the old dashboard content
old_dashboard = content[start_idx:end_idx]

# We want to preserve the Analytics logic. Let's find where it starts and ends.
analytics_start_str = "{/* ── Analytics Report"
analytics_start_idx = old_dashboard.find(analytics_start_str)

last_orders_start_str = "{/* ── Last 5 Orders"
last_orders_start_idx = old_dashboard.find(last_orders_start_str)

needs_action_start_str = "{/* ── Needs Action Tabs"
needs_action_start_idx = old_dashboard.find(needs_action_start_str)

if analytics_start_idx != -1:
    analytics_logic = old_dashboard[analytics_start_idx:]
else:
    analytics_logic = ""

# Since parsing JSX with regex is hard, I will just supply the fully reconstructed new layout.
