from enum import Enum
import os
APPDATA_PATH = os.environ.get("LOCALAPPDATA")
# APPDATA_PATH = "/Users/mason/Developer/Kneron-Academy/test_images"
# 取得專案根目錄的絕對路徑並設定 UXUI_ASSETS 為絕對路徑
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
UXUI_ASSETS = os.path.join(PROJECT_ROOT, "uxui", "")
# 新版路徑結構 (不需要獨立的 models 和 scripts 資料夾)
UTILS_DIR = os.path.join(APPDATA_PATH, "Kneron_Academy", "utils")
SCRIPT_CONFIG = os.path.join(UTILS_DIR, "config.json")
UPLOAD_DIR = os.path.join(APPDATA_PATH, "Kneron_Academy", "uploads")
FW_DIR = os.path.join(APPDATA_PATH, "Kneron_Academy", "firmware")
# Global Constants
APP_NAME = "Innovedus AI Playground"
WINDOW_SIZE = (1200, 900)
BACKGROUND_COLOR = "#143058"
SECONDARY_COLOR = "#005ED7"
MASK_STYLE = f"background-color: rgba(0, 0, 0, 128);"
DEVICE_BOX_STYLE = f"background-color: {BACKGROUND_COLOR}; padding: 20px; border-radius: 20px; padding: 10px 20px;"

BUTTON_STYLE = """
    QPushButton {
        background: transparent;
        color: white;
        border: 2px solid white;
        border-radius: 15px;
        padding: 5px 10px;
    }
    QPushButton:hover {
        background-color: rgba(255, 255, 255, 50);
    }
    QPushButton:pressed {
        background-color: rgba(255, 255, 255, 100);
    }
"""

SQUARE_BUTTON_STYLE = "background: transparent; color: white; border: 1px transparent; border-radius: 10px; "
POPUP_SIZE_RATIO = 0.67
NO_DEVICE_GIF = UXUI_ASSETS + "no_device_temp.gif"


# Firmware Path Relatives
FIRMWARE_PATHS = {
    "scpu": "../../res/firmware/fw_scpu.bin",
    "ncpu": "../../res/firmware/fw_ncpu.bin",
}

# MODEL_BUTTON = [
#     ('Face Detection', self.run_face_detection),
#     ('Gender/Age Detection', self.run_gender_age_detection),
#     ('Object Detection', self.run_object_detection),
#     ('Mask Detection', self.run_mask_detection),
#     ('Image Project', self.start_image_project),
#     ('Upload Model', self.upload_model)
# ]

# Model Inference Parameter
MODEL_TIMEOUT = 5000

# TODO: Mapping of the values
class DeviceType(Enum):
    KL520 = 256
    # KL720 = 720
    KL720 = 1824
    KL720_L = 512
    KL530 = 530
    KL832 = 832
    KL730 = 732
    KL630 = 630
    KL540 = 540

DongleModelMap = {
    "0x100": "KL520",  # product_id "0x100" 對應到 520 系列
    "0x720": "KL720",  # product_id "0x720" 對應到 720 系列
}

DongleIconMap = {
    "0x100": "ic_dongle_520.png",
    "0x720": "ic_dongle_720.png"
}