import lzma
import pickle
from functools import cached_property

from mower import __rootdir__
from mower.utils import typealias as tp
from mower.utils.image import load_static_dir
from mower.utils.singleton import singleton

with lzma.open(f"{__rootdir__}/static/avatar.pkl", "rb") as f:
    avatar = pickle.load(f)

with lzma.open(f"{__rootdir__}/static/portrait.pkl", "rb") as f:
    portrait = pickle.load(f)

with lzma.open(f"{__rootdir__}/static/shop.pkl", "rb") as f:
    shop = pickle.load(f)


@singleton
class Digital:
    @cached_property
    def secret_front(self) -> dict[str, tp.GrayImage]:
        return load_static_dir("digital/secret_front")

    @cached_property
    def riic_base_digits(self) -> dict[str, tp.GrayImage]:
        return load_static_dir("digital/riic_base_digits")

    @cached_property
    def noto_sans(self) -> dict[str, tp.GrayImage]:
        return load_static_dir("digital/noto_sans")
