import logging

from from_root import from_root

from src.ezgg_lan_manager.services import *
from src.ezgg_lan_manager.services.AccountingService import AccountingService
from src.ezgg_lan_manager.services.CateringService import CateringService
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService
from src.ezgg_lan_manager.services.DatabaseService import DatabaseService
from src.ezgg_lan_manager.services.LocalDataService import LocalDataService
from src.ezgg_lan_manager.services.MailingService import MailingService
from src.ezgg_lan_manager.services.NewsService import NewsService
from src.ezgg_lan_manager.services.RefreshService import RefreshService
from src.ezgg_lan_manager.services.ReceiptPrintingService import ReceiptPrintingService
from src.ezgg_lan_manager.services.SeatingService import SeatingService
from src.ezgg_lan_manager.services.TeamService import TeamService
from src.ezgg_lan_manager.services.TicketingService import TicketingService
from src.ezgg_lan_manager.services.TournamentService import TournamentService
from src.ezgg_lan_manager.services.UserService import UserService
from src.ezgg_lan_manager.types import *

# Inits services in the correct order
def init_services() -> tuple[AccountingService, CateringService, ConfigurationService, DatabaseService, MailingService, NewsService, SeatingService, TicketingService, UserService, LocalDataService, ReceiptPrintingService, TournamentService, TeamService]:
    logging.basicConfig(level=logging.DEBUG)
    configuration_service = ConfigurationService(from_root("config.toml"))
    db_service = DatabaseService(configuration_service.get_database_configuration())
    user_service = UserService(db_service)
    accounting_service = AccountingService(db_service)
    news_service = NewsService(db_service)
    mailing_service = MailingService(configuration_service)
    ticketing_service = TicketingService(configuration_service.get_ticket_info(), db_service, accounting_service)
    seating_service = SeatingService(configuration_service.get_lan_info(), db_service, ticketing_service)
    receipt_printing_service = ReceiptPrintingService(seating_service, configuration_service.get_receipt_printing_configuration(), configuration_service.DEV_MODE_ACTIVE)
    catering_service = CateringService(db_service, accounting_service, user_service, receipt_printing_service)
    local_data_service = LocalDataService()
    tournament_service = TournamentService(db_service, user_service)
    team_service = TeamService(db_service)
    refresh_service = RefreshService()

    return accounting_service, catering_service, configuration_service, db_service, mailing_service, news_service, seating_service, ticketing_service, user_service, local_data_service, receipt_printing_service, tournament_service, team_service
