"""
URL patterns for the library app.

Provides both custom admin views (HTML CRUD) and DRF API endpoints.
"""

from django.urls import include, path

from . import views

app_name = "library"

urlpatterns = [
    # Embedding Pipeline Dashboard
    path("embedding/", views.embedding_dashboard, name="embedding-dashboard"),
    path("embedding/embed-all/", views.embed_all_pending, name="embed-all-pending"),
    # Library CRUD
    path("", views.library_list, name="library-list"),
    path("create/", views.library_create, name="library-create"),
    # Static-prefix routes must come before <str:uid>/ or it will swallow them.
    # Search (Phase 3)
    path("search/", views.search_page, name="search"),
    # Concepts (Phase 3)
    path("concepts/", views.concept_list_page, name="concept-list"),
    path("concepts/<str:uid>/", views.concept_detail_page, name="concept-detail"),
    path("<str:uid>/", views.library_detail, name="library-detail"),
    path("<str:uid>/search/", views.library_search, name="library-search"),
    path("<str:uid>/edit/", views.library_edit, name="library-edit"),
    path("<str:uid>/delete/", views.library_delete, name="library-delete"),
    # Collection CRUD
    path(
        "<str:library_uid>/collections/create/",
        views.collection_create,
        name="collection-create",
    ),
    path(
        "collections/<str:uid>/",
        views.collection_detail,
        name="collection-detail",
    ),
    path(
        "collections/<str:uid>/edit/",
        views.collection_edit,
        name="collection-edit",
    ),
    path(
        "collections/<str:uid>/delete/",
        views.collection_delete,
        name="collection-delete",
    ),
    # Item CRUD
    path(
        "collections/<str:collection_uid>/items/create/",
        views.item_create,
        name="item-create",
    ),
    path("items/<str:uid>/", views.item_detail, name="item-detail"),
    path("items/<str:uid>/edit/", views.item_edit, name="item-edit"),
    path("items/<str:uid>/reembed/", views.item_reembed, name="item-reembed"),
    path("items/<str:uid>/download/", views.item_download, name="item-download"),
    path("items/<str:uid>/delete/", views.item_delete, name="item-delete"),
    # Image views
    path("images/<str:uid>/view/", views.image_serve, name="image-serve"),
    # DRF API
    path("api/", include("library.api.urls")),
]
