from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from oauth2_provider import urls as oauth2_urls
from rest_framework import routers

import vrobbler.apps.scrobbles.views as scrobbles_views
from vrobbler.apps.agents import urls as agents_urls
from vrobbler.apps.birds import urls as birds_urls
from vrobbler.apps.birds.api.views import BirdingLocationViewSet, BirdViewSet
from vrobbler.apps.boardgames import urls as boardgame_urls
from vrobbler.apps.boardgames.api.views import (
    BoardGameDesignerViewSet,
    BoardGameLocationViewSet,
    BoardGamePublisherViewSet,
    BoardGameVariantViewSet,
    BoardGameViewSet,
)
from vrobbler.apps.books import urls as book_urls
from vrobbler.apps.books.api.views import AuthorViewSet, BookViewSet, PaperViewSet
from vrobbler.apps.bricksets import urls as bricksets_urls
from vrobbler.apps.bricksets.api.views import BrickSetViewSet
from vrobbler.apps.charts import urls as charts_urls
from vrobbler.apps.discgolf import urls as discgolf_urls
from vrobbler.apps.discgolf.api.views import DiscGolfCourseViewSet
from vrobbler.apps.drinks import urls as drinks_urls
from vrobbler.apps.drinks.api.views import (
    BeerProducerViewSet,
    BeerStyleViewSet,
    BeerViewSet,
    CoffeeRoasterViewSet,
    CoffeeViewSet,
    DrinkViewSet,
    WineGrapeViewSet,
    WineProducerViewSet,
    WineRegionViewSet,
    WineViewSet,
)
from vrobbler.apps.foods import urls as foods_urls
from vrobbler.apps.foods.api.views import FoodCategoryViewSet, FoodViewSet
from vrobbler.apps.lifeevents import urls as lifeevents_urls
from vrobbler.apps.lifeevents.api.views import LifeEventViewSet
from vrobbler.apps.locations import urls as locations_urls
from vrobbler.apps.locations.api.views import GeoLocationViewSet
from vrobbler.apps.moods import urls as moods_urls
from vrobbler.apps.moods.api.views import MoodViewSet
from vrobbler.apps.nature import urls as nature_urls
from vrobbler.apps.nature.api.views import SpeciesObservationViewSet
from vrobbler.apps.music import urls as music_urls
from vrobbler.apps.music.api.views import (
    AlbumViewSet,
    ArtistViewSet,
    TrackViewSet,
)
from vrobbler.apps.people import urls as people_urls
from vrobbler.apps.podcasts import urls as podcast_urls
from vrobbler.apps.podcasts.api.views import (
    PodcastEpisodeViewSet,
    PodcastViewSet,
    ProducerViewSet,
)
from vrobbler.apps.profiles import urls as profiles_urls
from vrobbler.apps.profiles.api.views import UserProfileViewSet, UserViewSet
from vrobbler.apps.puzzles import urls as puzzles_urls
from vrobbler.apps.puzzles.api.views import (
    PuzzleManufacturerViewSet,
    PuzzleViewSet,
)
from vrobbler.apps.scrobbles import urls as scrobble_urls
from vrobbler.apps.scrobbles.api.views import (
    AudioScrobblerTSVImportViewSet,
    KoReaderImportViewSet,
    LastFmImportViewSet,
    ScrobbleViewSet,
)
from vrobbler.apps.sports import urls as sports_urls
from vrobbler.apps.sports.api.views import (
    LeagueViewSet,
    PlayerViewSet,
    SeasonViewSet,
    SportEventViewSet,
    SportViewSet,
    TeamViewSet,
)
from vrobbler.apps.tasks import urls as tasks_urls
from vrobbler.apps.tasks.api.views import TaskViewSet
from vrobbler.apps.trails import urls as trails_urls
from vrobbler.apps.trails.api.views import TrailViewSet
from vrobbler.apps.trends import urls as trends_urls
from vrobbler.apps.videogames import urls as videogame_urls
from vrobbler.apps.videogames.api.views import (
    VideoGameCollectionViewSet,
    VideoGamePlatformViewSet,
    VideoGameViewSet,
)
from vrobbler.apps.videos import urls as video_urls
from vrobbler.apps.videos.api.views import (
    ChannelViewSet,
    SeriesViewSet,
    VideoViewSet,
)
from vrobbler.apps.webpages import urls as webpages_urls
from vrobbler.apps.webpages.api.views import DomainViewSet, WebPageViewSet
from vrobbler.apps.workouts import urls as workouts_urls
from vrobbler.apps.workouts.api.views import (
    ExerciseViewSet,
    WorkoutImportViewSet,
    WorkoutRoutineViewSet,
)

# from vrobbler.apps.modern_ui import urls as modern_ui_urls

router = routers.DefaultRouter()
router.register(r"scrobbles", ScrobbleViewSet)
router.register(r"lastfm-imports", LastFmImportViewSet)
router.register(r"tsv-imports", AudioScrobblerTSVImportViewSet)
router.register(r"koreader-imports", KoReaderImportViewSet)
router.register(r"artist", ArtistViewSet)
router.register(r"album", AlbumViewSet)
router.register(r"tracks", TrackViewSet)
router.register(r"series", SeriesViewSet)
router.register(r"channels", ChannelViewSet)
router.register(r"videos", VideoViewSet)
router.register(r"authors", AuthorViewSet)
router.register(r"books", BookViewSet)
router.register(r"papers", PaperViewSet)
router.register(r"leagues", LeagueViewSet)
router.register(r"sports", SportViewSet)
router.register(r"seasons", SeasonViewSet)
router.register(r"players", PlayerViewSet)
router.register(r"sport-events", SportEventViewSet)
router.register(r"teams", TeamViewSet)
router.register(r"users", UserViewSet)
router.register(r"profiles", UserProfileViewSet)
router.register(r"domains", DomainViewSet)
router.register(r"webpages", WebPageViewSet)
router.register(r"foods", FoodViewSet)
router.register(r"food-categories", FoodCategoryViewSet)
router.register(r"moods", MoodViewSet)
router.register(r"tasks", TaskViewSet)
router.register(r"locations", GeoLocationViewSet)
router.register(r"beers", BeerViewSet)
router.register(r"beer-producers", BeerProducerViewSet)
router.register(r"beer-styles", BeerStyleViewSet)
router.register(r"wines", WineViewSet)
router.register(r"wine-producers", WineProducerViewSet)
router.register(r"wine-regions", WineRegionViewSet)
router.register(r"wine-grapes", WineGrapeViewSet)
router.register(r"coffees", CoffeeViewSet)
router.register(r"coffee-roasters", CoffeeRoasterViewSet)
router.register(r"drinks", DrinkViewSet)
router.register(r"boardgames", BoardGameViewSet)
router.register(r"boardgame-designers", BoardGameDesignerViewSet)
router.register(r"boardgame-publishers", BoardGamePublisherViewSet)
router.register(r"boardgame-locations", BoardGameLocationViewSet)
router.register(r"boardgame-variants", BoardGameVariantViewSet)
router.register(r"podcast-producers", ProducerViewSet)
router.register(r"podcast-episodes", PodcastEpisodeViewSet)
router.register(r"podcasts", PodcastViewSet)
router.register(r"puzzle-manufacturers", PuzzleManufacturerViewSet)
router.register(r"puzzles", PuzzleViewSet)
router.register(r"bricksets", BrickSetViewSet)
router.register(r"lifeevents", LifeEventViewSet)
router.register(r"videogames", VideoGameViewSet)
router.register(r"videogame-collections", VideoGameCollectionViewSet)
router.register(r"videogame-platforms", VideoGamePlatformViewSet)

router.register(r"birds", BirdViewSet)
router.register(r"birding-locations", BirdingLocationViewSet)
router.register(r"disc-golf-courses", DiscGolfCourseViewSet)
router.register(r"observations", SpeciesObservationViewSet)
router.register(r"trails", TrailViewSet)
router.register(r"exercises", ExerciseViewSet)
router.register(r"workout-routines", WorkoutRoutineViewSet)
router.register(r"workout-imports", WorkoutImportViewSet)
urlpatterns = [
    path("api/v1/", include(router.urls)),
    path("api/v1/auth", include("rest_framework.urls")),
    path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
    path(
        "api/docs/",
        SpectacularSwaggerView.as_view(url_name="schema"),
        name="swagger-ui",
    ),
    path("admin/", admin.site.urls),
    path("accounts/", include("allauth.urls")),
    path("o/", include(oauth2_urls)),
    # path("modern_ui/", include(modern_ui_urls, namespace="modern_ui")),
    path("", include(music_urls, namespace="music")),
    path("", include(book_urls, namespace="books")),
    path("", include(video_urls, namespace="videos")),
    path("", include(videogame_urls, namespace="videogames")),
    path("", include(boardgame_urls, namespace="boardgames")),
    path("", include(bricksets_urls, namespace="bricksets")),
    path("", include(sports_urls, namespace="sports")),
    path("", include(locations_urls, namespace="locations")),
    path("", include(trails_urls, namespace="trails")),
    path("", include(drinks_urls, namespace="drinks")),
    path("", include(discgolf_urls, namespace="discgolf")),
    path("", include(foods_urls, namespace="foods")),
    path("", include(puzzles_urls, namespace="puzzles")),
    path("", include(tasks_urls, namespace="tasks")),
    path("", include(webpages_urls, namespace="webpages")),
    path("", include(podcast_urls, namespace="podcasts")),
    path("", include(lifeevents_urls, namespace="life-events")),
    path("", include(moods_urls, namespace="moods")),
    path("", include(agents_urls, namespace="agents")),
    path("", include(birds_urls, namespace="birds")),
    path("", include(nature_urls, namespace="nature")),
    path("", include(workouts_urls, namespace="workouts")),
    path("", include(scrobble_urls, namespace="scrobbles")),
    path("", include(profiles_urls, namespace="profiles")),
    path("", include(people_urls, namespace="people")),
    path("", include(charts_urls, namespace="charts")),
    path("", include(trends_urls, namespace="trends")),
    path("", include("mcp_server.urls")),
    path("", scrobbles_views.RecentScrobbleList.as_view(), name="vrobbler-home"),
]
if settings.DEBUG:
    urlpatterns = urlpatterns + static(
        settings.STATIC_URL, document_root=settings.STATIC_ROOT
    )
    urlpatterns = urlpatterns + static(
        settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
    )
