"""
URL configuration for wagtailcms project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/6.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.contrib import admin
from django.urls import include, path
from wagtail.admin import urls as wagtailadmin_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

from apps.api.urls import api_router
from apps.core.views import healthz, readyz

urlpatterns = [
    path('django-admin/', admin.site.urls),
    path('admin/', include(wagtailadmin_urls)),
    path('documents/', include(wagtaildocs_urls)),
    path('api/v2/', api_router.urls),
    # 自定义业务接口（非 Wagtail 页面路由），如线索表单提交
    path('api/v1/custom/', include('apps.forms.urls')),
    # 全局 Snippet 只读接口：团队/证言/合作伙伴/导航菜单/站点设置
    path('api/v1/custom/core/', include('apps.core.urls')),
    path('healthz', healthz, name='healthz'),
    path('readyz', readyz, name='readyz'),
]

if settings.DEBUG:
    from django.conf.urls.static import static

    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += [
    # 兜底：交由 Wagtail 页面树渲染（Headless 场景下主要用于预览/管理，
    # 对外内容展示由 Next.js 前端通过 /api/v2/ 消费）
    path('', include(wagtail_urls)),
]
