# Path: src/instawow/common.py
# class Flavour(StrEnum):
#     # The latest Classic version is always aliased to "classic".
#     # The logic here is that should Classic not be discontinued
#     # it will continue to be updated in place so that new Classic versions
#     # will inherit the "_classic_" folder.  This means we won't have to
#     # migrate Classic profiles either automatically or by requiring user
#     # intervention for new Classic releases.
#     retail = 'retail'
#     vanilla_classic = 'vanilla_classic'
#     burning_crusade_classic = 'classic'
# 
#     @classmethod
#     def from_flavour_keyed_enum(cls, enum: Enum) -> Flavour:
#         return cls[enum.name]
# 
#     @classmethod
#     def to_flavour_keyed_enum(cls, enum: _FlavourKeyedEnum[_TEnum], flavour: Flavour) -> _TEnum:
#         return enum[flavour.name]
# 
# Path: src/instawow/utils.py
# def trash(paths: Sequence[PurePath], *, dest: PurePath, missing_ok: bool = False) -> None:
#     if not paths:
#         return
# 
#     parent_folder = mkdtemp(dir=dest, prefix=f'deleted-{paths[0].name}-')
#     for path in paths:
#         try:
#             move(path, dest=parent_folder)
#         except (FileNotFoundError if missing_ok else ()):
#             pass


from collections.abc import Iterable, Set
from pathlib import Path, PurePath
from tempfile import gettempdir
from typing import Any
from loguru import logger
from pydantic import BaseModel, BaseSettings, Field, PydanticValueError, SecretStr, validator
from pydantic.env_settings import SettingsSourceCallable
from .common import Flavour
from .utils import trash
    from types import SimpleNamespace
import json
import os
import sys
import typing
import click
    import queue
    import threading
    import loguru._handler
    import logging
            return Flavour.retail
        elif tail[0] in {'_classic_era_', '_classic_era_ptr_'}:
            return Flavour.vanilla_classic
        elif tail[0] in {'_classic_', '_classic_beta_', '_classic_ptr_'}:
            return Flavour.burning_crusade_classic
        else:
            return Flavour.retail

    @classmethod
    def read(cls, global_config: GlobalConfig, profile: str) -> Config:
        dummy_config = cls.construct(global_config=global_config, profile=profile)
        config = cls(global_config=global_config, **_read_config(dummy_config))
        return config

    def ensure_dirs(self) -> Config:
        _ensure_dirs(
            [
                self.profile_dir,
                self.logging_dir,
                self.plugin_dir,
            ]
        )
        return self

    def write(self) -> Config:
        self.ensure_dirs()
        _write_config(self, {'addon_dir', 'game_flavour', 'profile'})
        return self

    def delete(self) -> None:

# Path: src/instawow/common.py
# class Flavour(StrEnum):
#     # The latest Classic version is always aliased to "classic".
#     # The logic here is that should Classic not be discontinued
#     # it will continue to be updated in place so that new Classic versions
#     # will inherit the "_classic_" folder.  This means we won't have to
#     # migrate Classic profiles either automatically or by requiring user
#     # intervention for new Classic releases.
#     retail = 'retail'
#     vanilla_classic = 'vanilla_classic'
#     burning_crusade_classic = 'classic'
# 
#     @classmethod
#     def from_flavour_keyed_enum(cls, enum: Enum) -> Flavour:
#         return cls[enum.name]
# 
#     @classmethod
#     def to_flavour_keyed_enum(cls, enum: _FlavourKeyedEnum[_TEnum], flavour: Flavour) -> _TEnum:
#         return enum[flavour.name]
# 
# Path: src/instawow/utils.py
# def trash(paths: Sequence[PurePath], *, dest: PurePath, missing_ok: bool = False) -> None:
#     if not paths:
#         return
# 
#     parent_folder = mkdtemp(dir=dest, prefix=f'deleted-{paths[0].name}-')
#     for path in paths:
#         try:
#             move(path, dest=parent_folder)
#         except (FileNotFoundError if missing_ok else ()):
#             pass


# Path: src/instawow/config.py
from collections.abc import Iterable, Set
from pathlib import Path, PurePath
from tempfile import gettempdir
from typing import Any
from loguru import logger
from pydantic import BaseModel, BaseSettings, Field, PydanticValueError, SecretStr, validator
from pydantic.env_settings import SettingsSourceCallable
from .common import Flavour
from .utils import trash
    from types import SimpleNamespace
import json
import os
import sys
import typing
import click
    import queue
    import threading
    import loguru._handler
    import logging

            return Flavour.retail
        elif tail[0] in {'_classic_era_', '_classic_era_ptr_'}:
            return Flavour.vanilla_classic
        elif tail[0] in {'_classic_', '_classic_beta_', '_classic_ptr_'}:
            return Flavour.burning_crusade_classic
        else:
            return Flavour.retail

    @classmethod
    def read(cls, global_config: GlobalConfig, profile: str) -> Config:
        dummy_config = cls.construct(global_config=global_config, profile=profile)
        config = cls(global_config=global_config, **_read_config(dummy_config))
        return config

    def ensure_dirs(self) -> Config:
        _ensure_dirs(
            [
                self.profile_dir,
                self.logging_dir,
                self.plugin_dir,
            ]
        )
        return self

    def write(self) -> Config:
        self.ensure_dirs()
        _write_config(self, {'addon_dir', 'game_flavour', 'profile'})
        return self

    def delete(self) -> None:

        trash((self.profile_dir,), dest=self.global_config.temp_dir, missing_ok=True)