"""URL map: API (Ninja), health, SSO handoff, signed downloads, SPA catch-all, Django admin."""

from django.contrib import admin
from django.http import HttpResponseRedirect
from django.urls import path, re_path

from snapfile.api import api
from snapfile.core import views

urlpatterns = [
    path("health/live", views.health_live),
    path("health/ready", views.health_ready),
    path("health/details", views.health_details),
    path("health/warm", views.health_warm),
    path("files/<str:file_id>", views.signed_file, name="signed-file"),
    path("editor/handoff", views.editor_handoff, name="editor-handoff"),
    path("editor", lambda r: HttpResponseRedirect("/editor/")),
    re_path(r"^editor/(?P<path>.*)$", views.spa, {"base": "/editor/"}, name="spa-editor"),
    path("app", lambda r: HttpResponseRedirect("/app/")),
    re_path(r"^app/(?P<path>.*)$", views.spa, {"base": "/app/"}, name="spa-app"),
    path("admin/ui/", admin.site.urls),
    path("", lambda r: HttpResponseRedirect("/editor/")),
    path("", api.urls),
]
