import functools

from snek.service.channel import ChannelService
from snek.service.channel_attachment import ChannelAttachmentService
from snek.service.channel_member import ChannelMemberService
from snek.service.channel_message import ChannelMessageService
from snek.service.chat import ChatService
from snek.service.container import ContainerService
from snek.service.db import DBService
from snek.service.drive import DriveService
from snek.service.drive_item import DriveItemService
from snek.service.notification import NotificationService
from snek.service.push import PushService
from snek.service.repository import RepositoryService
from snek.service.socket import SocketService
from snek.service.user import UserService
from snek.service.user_property import UserPropertyService
from snek.service.util import UtilService
from snek.system.object import Object
from snek.service.statistics import StatisticsService 

@functools.cache
def get_services(app):
    return Object(
        **{
            "user": UserService(app=app),
            "channel_member": ChannelMemberService(app=app),
            "channel": ChannelService(app=app),
            "channel_message": ChannelMessageService(app=app),
            "chat": ChatService(app=app),
            "socket": SocketService(app=app),
            "notification": NotificationService(app=app),
            "util": UtilService(app=app),
            "drive": DriveService(app=app),
            "drive_item": DriveItemService(app=app),
            "user_property": UserPropertyService(app=app),
            "repository": RepositoryService(app=app),
            "db": DBService(app=app),
            "channel_attachment": ChannelAttachmentService(app=app),
            "container": ContainerService(app=app),
            "push": PushService(app=app),
            "statistics": StatisticsService(app=app),
        }
    )


def get_service(name, app=None):
    return get_services(app=app)[name]
