# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""
Service Center Registry.
Service definitions, dependency graph, and RBAC object keys.
"""

from typing import Dict, List, Any

# Core services: internal building blocks, no RBAC, never requested by features
CORE_SERVICES: Dict[str, Dict[str, Any]] = {
    "utils": {
        "module": "modules.serviceCenter.core.serviceUtils.mainServiceUtils",
        "class": "UtilsService",
        "dependencies": [],
    },
    "security": {
        "module": "modules.serviceCenter.core.serviceSecurity.mainServiceSecurity",
        "class": "SecurityService",
        "dependencies": [],
    },
    "streaming": {
        "module": "modules.serviceCenter.core.serviceStreaming.mainServiceStreaming",
        "class": "StreamingService",
        "dependencies": [],
    },
}

# Importable services: feature-facing, RBAC-protected
IMPORTABLE_SERVICES: Dict[str, Dict[str, Any]] = {
    "ticket": {
        "module": "modules.serviceCenter.services.serviceTicket.mainServiceTicket",
        "class": "TicketService",
        "dependencies": [],
        "objectKey": "service.ticket",
        "label": {"en": "Ticket System", "de": "Ticket-System", "fr": "Système de tickets"},
    },
    "messaging": {
        "module": "modules.serviceCenter.services.serviceMessaging.mainServiceMessaging",
        "class": "MessagingService",
        "dependencies": [],
        "objectKey": "service.messaging",
        "label": {"en": "Messaging", "de": "Nachrichten", "fr": "Messagerie"},
    },
    "billing": {
        "module": "modules.serviceCenter.services.serviceBilling.mainServiceBilling",
        "class": "BillingService",
        "dependencies": ["subscription"],
        "objectKey": "service.billing",
        "label": {"en": "Billing", "de": "Abrechnung", "fr": "Facturation"},
    },
    "subscription": {
        "module": "modules.serviceCenter.services.serviceSubscription.mainServiceSubscription",
        "class": "SubscriptionService",
        "dependencies": [],
        "objectKey": "service.subscription",
        "label": {"en": "Subscription", "de": "Abonnement", "fr": "Abonnement"},
    },
    "sharepoint": {
        "module": "modules.serviceCenter.services.serviceSharepoint.mainServiceSharepoint",
        "class": "SharepointService",
        "dependencies": ["security"],
        "objectKey": "service.sharepoint",
        "label": {"en": "SharePoint", "de": "SharePoint", "fr": "SharePoint"},
    },
    "chat": {
        "module": "modules.serviceCenter.services.serviceChat.mainServiceChat",
        "class": "ChatService",
        "dependencies": ["utils"],
        "objectKey": "service.chat",
        "label": {"en": "Chat", "de": "Chat", "fr": "Chat"},
    },
    "extraction": {
        "module": "modules.serviceCenter.services.serviceExtraction.mainServiceExtraction",
        "class": "ExtractionService",
        "dependencies": ["chat", "utils"],
        "objectKey": "service.extraction",
        "label": {"en": "Extraction", "de": "Extraktion", "fr": "Extraction"},
    },
    "generation": {
        "module": "modules.serviceCenter.services.serviceGeneration.mainServiceGeneration",
        "class": "GenerationService",
        "dependencies": ["utils", "chat"],
        "objectKey": "service.generation",
        "label": {"en": "Generation", "de": "Generierung", "fr": "Génération"},
    },
    "ai": {
        "module": "modules.serviceCenter.services.serviceAi.mainServiceAi",
        "class": "AiService",
        "dependencies": ["chat", "utils", "extraction", "billing"],
        "objectKey": "service.ai",
        "label": {"en": "AI", "de": "KI", "fr": "IA"},
    },
    "web": {
        "module": "modules.serviceCenter.services.serviceWeb.mainServiceWeb",
        "class": "WebService",
        "dependencies": ["ai", "chat", "utils"],
        "objectKey": "service.web",
        "label": {"en": "Web Research", "de": "Web-Recherche", "fr": "Recherche Web"},
    },
    "neutralization": {
        "module": "modules.features.neutralization.serviceNeutralization.mainServiceNeutralization",
        "class": "NeutralizationService",
        "dependencies": ["extraction", "generation"],
        "objectKey": "service.neutralization",
        "label": {"en": "Neutralization", "de": "Neutralisierung", "fr": "Neutralisation"},
    },
    "agent": {
        "module": "modules.serviceCenter.services.serviceAgent.mainServiceAgent",
        "class": "AgentService",
        "dependencies": ["ai", "chat", "utils", "extraction", "billing", "streaming", "knowledge"],
        "objectKey": "service.agent",
        "label": {"en": "Agent", "de": "Agent", "fr": "Agent"},
    },
    "knowledge": {
        "module": "modules.serviceCenter.services.serviceKnowledge.mainServiceKnowledge",
        "class": "KnowledgeService",
        "dependencies": ["ai"],
        "objectKey": "service.knowledge",
        "label": {"en": "Knowledge Store", "de": "Wissensspeicher", "fr": "Base de connaissances"},
    },
}

# RBAC objects for service-level access control (for catalog registration)
SERVICE_RBAC_OBJECTS: List[Dict[str, Any]] = [
    {"objectKey": s["objectKey"], "label": s["label"]}
    for s in IMPORTABLE_SERVICES.values()
    if "objectKey" in s
]
