from typing import Any, Type

from aiohttp import BasicAuth

from ..internal.gateway import Gateway
from ..internal.http import HTTPClient
from .cache import CacheStore, Store

_BASE_MODELS: dict[Any, Any] = {}


class State:
    """The central bot cache."""

    def __init__(
        self,
        token: str,
        # cache-options
        max_messages: int,
        max_members: int,
        intents: int,
        # "advanced" options
        base_url: str = "https://discord.com/api/v10",
        proxy: str | None = None,
        proxy_auth: BasicAuth | None = None,
        # classes
        store_class: Type[Store] = Store,
        model_classes: dict[Any, Any] = _BASE_MODELS,
    ) -> None:
        self._token = token
        self.cache = CacheStore(store_class)
        self.cache["messages"] = max_messages
        self.cache["members"] = max_members
        self.max_members = max_members
        self.intents = intents
        self.http = HTTPClient(token)
        self.gateway = Gateway(self)
