from django.contrib.auth import views as auth_views
from django.urls import include, path
from .custom_views import CustomLoginView
from . import views
from .services import payment_service

urlpatterns = [
    path('reset/<uidb64>/<token>/', views.CustomPasswordResetConfirmView.as_view(), name='password_reset_confirm'),
    path("", views.index, name="index"),
    path("tournaments/", views.tournaments, name="tournaments"),
    path("clubs/", views.clubs, name="clubs"),
    path("clubs/<str:club_id>/", views.club, name="club"),
    path("c/<str:broadcast_code>", views.club_broadcast, name="club-broadcast"),
    path("c/<str:broadcast_code>/go", views.club_broadcast_auto, name="club-broadcast-auto"),
    path('tournaments/webhook/stripe/', payment_service.PaymentService.stripe_webhook, name='stripe_webhook'),
    path('tournament/<str:tournament_id>/confirm-call/', views.confirm_call, name='confirm_call'),
    path('tournaments/<str:tournament_id>/payment/success/', views.tournament_payment_success, name='tournament-payment-success'),
    path('tournaments/<str:tournament_id>/proceed-to-payment/', views.proceed_to_payment, name='proceed_to_payment'),
    path("tournament/<str:tournament_id>/",
        include([
            path('', views.tournament, name='tournament'),
            path('teams/', views.tournament_teams, name='tournament-teams'),
            path('info/', views.tournament_info, name='tournament-info'),
            path('bracket/', views.tournament_bracket, name='tournament-bracket'),
            path('round/<str:round_id>/bracket/', views.round_bracket, name='round-bracket'),
            path('prog/', views.tournament_prog, name='tournament-prog'),
            path('summons/', views.tournament_summons, name='tournament-summons'),
            path('broadcast/summons/', views.tournament_broadcasted_summons, name='broadcasted-summons'),
            path('summons/json/', views.tournament_summons_json, name='tournament-summons-json'),
            path('broadcast/matches/', views.tournament_matches, name='broadcasted-matches'),
            path('broadcast/', views.tournament_broadcast_home, name='broadcast'),
            path('broadcast/auto/', views.automatic_broadcast, name='automatic-broadcast'),
            path('matches/json/', views.tournament_matches_json, name='tournament-matches-json'),
            path('prog/json/', views.tournament_prog_json, name='tournament-prog-json'),
            path('planning/json/', views.tournament_planning_json, name='tournament-planning-json'),
            path('broadcast/json/', views.broadcast_json, name='broadcast-json'),
            path('broadcast/group-stages/', views.tournament_broadcasted_group_stages, name='broadcasted-group-stages'),
            path('broadcast/prog/', views.tournament_broadcasted_prog, name='broadcasted-prog'),
            path('broadcast/planning/', views.tournament_broadcasted_planning, name='broadcasted-planning'),
            path('broadcast/bracket/', views.tournament_broadcasted_bracket, name='broadcasted-bracket'),
            path('bracket/json/', views.tournament_bracket_json, name='tournament-bracket-json'),
            path('group-stages/', views.tournament_group_stages, name='group-stages'),
            path('group-stages/json/', views.tournament_live_group_stage_json, name='group-stages-json'),
            path('rankings/', views.tournament_rankings, name='tournament-rankings'),
            path('rankings/json/', views.tournament_rankings_json, name='tournament-rankings-json'),
            path('broadcast/rankings/', views.tournament_broadcast_rankings, name='broadcasted-rankings'),
            path('team/<str:team_id>/', views.team_details, name='team-details'),
            path('live/', views.tournament_live_matches, name='tournament-live'),
        ])
    ),
    path("event/<str:event_id>/", views.event, name='event'),
    path("event/<str:event_id>/broadcast/auto/", views.automatic_broadcast_event, name='automatic-broadcast-event'),
    path('players/', views.players, name='players'),
    path('activate/<uidb64>/<token>/', views.activate, name='activate'),
    path('download/', views.download, name='download'),
    path('apns/', views.test_apns, name='test-apns'),
    path('terms-of-use/', views.terms_of_use, name='terms-of-use'),
    path('mail-test/', views.simple_form_view, name='mail-test'),
    path('login/', CustomLoginView.as_view(), name='custom-login'),
    path('custom_password_change/', views.custom_password_change, name='custom_password_change'),
    path('logout/', views.custom_logout, name='custom_logout'),
    path('utils/xls-to-csv/', views.xls_to_csv, name='xls-to-csv'),
    path('signup/', views.signup, name='signup'),  # URL pattern for signup
    path('resend-activation/', views.resend_activation_email, name='resend-activation'),
    path('my-tournaments/', views.my_tournaments, name='my-tournaments'),  # URL pattern for signup
    path('all_my_ended_tournaments/', views.all_my_ended_tournaments, name='all-my-ended-tournaments'),  # URL pattern for signup
    path('tournaments/<str:tournament_id>/cancel-registration/', views.cancel_registration, name='cancel_registration'),
    path('tournaments/<str:tournament_id>/register/', views.register_tournament, name='register_tournament'),
    path('tournaments/<str:tournament_id>/unregister/', views.unregister_tournament, name='unregister_tournament'),
    path('password_reset/', auth_views.PasswordResetView.as_view(), name='password_reset'),
    path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
    path('reset/done/',
         views.CustomPasswordResetCompleteView.as_view(),
         name='password_reset_complete'),
    path('profile/', views.ProfileUpdateView.as_view(), name='profile'),
    path('admin/tournament-import/', views.tournament_import_view, name='tournament_import'),
    path('admin/status/', views.status_page, name='status_page'),
    path('admin/users-export/', views.UserListExportView.as_view(), name='users_export'),
    path('activation-success/', views.activation_success, name='activation_success'),
    path('activation-failed/', views.activation_failed, name='activation_failed'),
    path('tournaments/<str:tournament_id>/confirm/', views.confirm_tournament_registration, name='confirm_tournament_registration'),
    path('stripe-onboarding-complete/', views.stripe_onboarding_complete, name='stripe-onboarding-complete'),
    path('stripe-refresh-account-link/', views.stripe_refresh_account_link, name='stripe-refresh-account-link'),
    path('tournaments/<str:tournament_id>/toggle-private/', views.toggle_tournament_private, name='toggle_tournament_private'),
    path("private-tournaments/", views.private_tournaments, name="private-tournaments"),

]
