"""
Router principal de API v1
Agrega todos los módulos de la aplicación
"""

from fastapi import APIRouter

from .customs_brokers.routes import router as customs_broker_router

# Importar routers de módulos
from .general_catalogs.router import router as general_catalogs_router
from .invoices.routes import router as invoices_router
from .invoices.imports.process.routes import router as invoice_process_router
from .invoices.imports.revert.routes import router as invoice_revert_router
from .items.routes import router as items_router
from .classes.routes import router as classes_router

from .clients_and_providers import router as client_and_provider_router
from .layouts_csv.facturas.routes import router as imports_router
from .layouts_csv.exportacion.routes import router as exportacion_imports_router
from .layouts_csv.cambio_regimen_regularizacion.routes import router as cambio_regimen_regularizacion_imports_router
from .csv_templates.routes import router as csv_templates_router
from .invoice_settings.routes import router as invoice_settings_router
from .item_presets.routes import router as item_presets_router
from .transportation.drivers.routes import router as drivers_router
from .doc_types_dig.routes import router as doc_types_dig_router
from .rule_octave.fractions.routes import router as fraction_rule_octave_router
from .rule_octave.country.routes import router as country_rule_oct_router
from .parts import router as parts_router
from .boms import router as boms_router
from .pedmientos.router import router as pedimentos_router
from .permission_rule_oct.routes import router as permission_rule_oct_router
from .transportation.trailers.routes import router as trailers_router
from .transportation.transporters.routes import router as transporters_router
from .transportation.vehicles.routes import router as vehicles_router
from api.v1.modules.public.reference_data.material_types.routes import router as material_types_router
from .factura_cove.routes import router as factura_cove_router

# --- NUEVO IMPORT PARA REPORTES DE FACTURAS ---
from .reports.importacion.facturas.routes import router as invoices_reports_router
from .reports.importacion.consolidados.routes import router as consolidated_reports_router
from .reports.importacion.packing_list.routes import router as packing_list_router
from .reports.exportacion.aviso_consolidado.routes import router as aviso_consolidado_export_router
from .reports.exportacion.partes_descargadas.routes import router as downloaded_parts_reports_router
from .reports.movements.invoices.routes import router as movement_invoices_router
from .reports.movements.saldos.routes import router as movement_saldos_router
from .reports.movements.vencimiento.routes import router as movement_vencimiento_router
from .reports.exportacion.descargo.routes import router as discharge_reports_router
from .reports.exportacion.transmission.MAINX30.routes import router as transmission_router
from .reports.importacion.transmission.temporal.MAINX30.routes import router as transmission_temporal_router
from .reports.importacion.transmission.definitive.MAINX30.routes import router as transmission_definitive_router
from .reports.importacion.winsaai.router import router as winsaai_router
from .app_settings.routes import router as app_settings_router

from .manifests.manifest.routes import router as manifests_router
from .manifests.driver.routes import router as manifest_drivers_router
from .manifests.manifiesto_anexo.routes import router as manifest_anexos_router
from .expediente_archivos.routes import router as expediente_archivos_router


# Router principal
router = APIRouter()

# Registrar módulos
router.include_router(general_catalogs_router, prefix="/a76", tags=["a76 / general_catalogs"])
router.include_router(invoices_router, prefix="/a76", tags=["a76 / invoices"])
router.include_router(invoice_process_router, prefix="/a76", tags=["a76 / invoices"])
router.include_router(invoice_revert_router, prefix="/a76", tags=["a76 / invoices"])
router.include_router(items_router, prefix="/a76", tags=["a76 / items"])
router.include_router(imports_router, prefix="/a76/imports", tags=["a76 / imports"])
router.include_router(exportacion_imports_router, prefix="/a76/imports/exportacion", tags=["a76 / imports / exportacion"])
router.include_router(cambio_regimen_regularizacion_imports_router, prefix="/a76/imports/cambio-regimen-regularizacion", tags=["a76 / imports / cambio_regimen_regularizacion"])
router.include_router(csv_templates_router, prefix="/a76/csv-templates", tags=["a76 / csv_templates"])
router.include_router(invoice_settings_router)
router.include_router(item_presets_router, prefix="/a76/item-presets", tags=["a76 / item_presets"])
router.include_router(pedimentos_router, prefix="/a76")
router.include_router(client_and_provider_router, prefix="/a76", tags=["a76 / clients_and_providers"])
router.include_router(classes_router, prefix="/a76/classes", tags=["a76 / classes"])
router.include_router(parts_router, prefix="/a76", tags=["a76 / parts"])
router.include_router(boms_router, prefix="/a76/boms", tags=["a76 / boms"])
router.include_router(permission_rule_oct_router, prefix="/a76", tags=["a76 / permission_rule_oct"])
router.include_router(fraction_rule_octave_router, prefix="/a76", tags=["a76 / fraction_rule_octave"])
router.include_router(country_rule_oct_router, prefix="/a76", tags=["a76 / country_rule_oct"])
router.include_router(trailers_router, prefix="/a76/transportation", tags=["a76 / trailers"])
router.include_router(customs_broker_router, prefix="/a76", tags=["a76 / customs_broker"])
router.include_router(doc_types_dig_router, prefix="/a76", tags=["a76 / document_types_digitization"])
router.include_router(drivers_router, prefix="/a76", tags=["a76 / drivers"])
router.include_router(transporters_router, prefix="/a76", tags=["a76 / transporters"])
router.include_router(vehicles_router, prefix="/a76/transportation", tags=["a76 / vehicles"])
router.include_router(factura_cove_router, prefix="/a76/factura-cove", tags=["a76 / factura_cove"])
router.include_router(expediente_archivos_router, prefix="/a76", tags=["a76 / expediente-archivos"])

# Registrar router de tipos de material públicos
router.include_router(
    material_types_router,
    prefix="/public/reference-data", 
    tags=["Reference Data"]
)

# --- REGISTRO DE RUTAS DE REPORTES ---
router.include_router(
    invoices_reports_router, 
    prefix="/a76/reports/importacion/facturas", 
    tags=["a76 / reports"]
)

router.include_router(
    consolidated_reports_router, 
    prefix="/a76/reports/importacion/consolidados", 
    tags=["a76 / reports"]
)

router.include_router(
    packing_list_router,
    prefix="/a76/reports/importacion/packing-lists",
    tags=["a76 / reports"]
)

router.include_router(
    aviso_consolidado_export_router, 
    prefix="/a76/reports/exportacion/aviso_consolidado", 
    tags=["a76 / reports"]
)

router.include_router(
    downloaded_parts_reports_router,
    prefix="/a76/reports/exportacion/partes-descargadas",
    tags=["a76 / reports"]
)

router.include_router(

    movement_invoices_router, 
    prefix="/a76/reports/movements/invoices", 
    tags=["a76 / reports"]
)

router.include_router(
    movement_saldos_router,
    prefix="/a76/reports/movements/saldos",
    tags=["a76 / reports"]
)

router.include_router(
    movement_vencimiento_router,
    prefix="/a76/reports/movements/vencimiento",
    tags=["a76 / reports"]
)

router.include_router(
    discharge_reports_router,
    prefix="/a76/reports/exportacion/descargo",
    tags=["a76 / reports"]
)

router.include_router(
    manifests_router,
    prefix="/a76",
    tags=["a76 / manifests"]
)

router.include_router(
    manifest_drivers_router,
    prefix="/a76",
    tags=["a76 / manifests"]
)

router.include_router(
    manifest_anexos_router,
    prefix="/a76",
    tags=["a76 / manifests"]
)

router.include_router(
    transmission_router,
    prefix="/a76/reports/exportacion/transmission",
    tags=["a76 / reports"]
)

router.include_router(
    transmission_temporal_router,
    prefix="/a76/reports/importacion/transmission/temporal",
    tags=["a76 / reports"]
)

router.include_router(
    transmission_definitive_router,
    prefix="/a76/reports/importacion/transmission/definitive",
    tags=["a76 / reports"]
)

router.include_router(
    winsaai_router,
    prefix="/a76/reports/importacion/winsaai",
    tags=["a76 / reports"]
)

router.include_router(app_settings_router)

# Registrar router de bitácora
from .audit_log.router import router as audit_log_router
router.include_router(audit_log_router, prefix="/a76/audit-log", tags=["Audit Log"])
