import os
from pathlib import Path

cur_dir = str(Path(__file__).parents[0])
from sdsvkvu.utils.utils import read_txt
from sdsvkvu.utils.post_processing import preprocessing


header_dict = {
    "productname": [
        "description",
        "productdescription",
        "articledescription",
        "descriptionofgood",
        "itemdescription",
        "brandmodel",
        "itemdepartment",
        "departmentbrand",
        "department",
        "certificateno",
        "product",
        "modelname",
        "paticulars",
        "device",
        "items",
        "itemno",
    ],
    "modelnumber": [
        "serialno",
        "serial",
        "articles",
        "simimeiserial",
        "article",
        "articlenumber",
        "articleidmaterialcode",
        "itemcode",
        "code",
        "mcode",
        "productcode",
        "model",
        "product",
        "imeiccid",
        "transaction",
    ],
    "qty": ["quantity", "invoicequantity"],
}

date_dict = {
    "purchase_date": [
        "date",
        "purchasedate",
        "datetime",
        "orderdate",
        "orderdatetime",
        "invoicedate",
        "dateredeemed",
        "issuedate",
        "billingdocdate",
        "placedon",
        "transactiondatetime",
        "creationdate",
        "ordertime",
        "dateofissue",
    ]
}

imei_dict = {
    "serial_number": ["serialnumber", "serialno"],
    "imei_number": ["imeiesim", "imeislot1", "imeislot2", "imei", "imei1", "imei2"],
}

sold_dict = {
    "sold_by_party": ["soldtoparty"],
    "sold_by": ["soldby"]
}

extra_dict = {
    "serial_number": ["sn"],
    "imei_number": ["imel", "imed"],
    "modelnumber": ["sku", "sn", "imei"],
    "qty": ["qty"],
}

seller_mapping = {
    "Samsung Experience Store": ["G-FORCE NETWORK PTE LTD", "eSmart Mobile", "eSmart Mobile Pte Ltd"],
    "Samsung Online Store": ["SAMSUNG ELECTRONICS SINGAPORE PTE LTD"],
    "Samsung Brand Store": ["SAMSUNG OFFICIAL STORE"],
    "Harvey Norman": ["PERTAMA MERCHANDISING PTE LTD"],
    "Shopee": ["shopee mall"],
    "Lazada": ["laz mall", "lazmall"],
    "LTD": ["limited"],
    "PTE": ["private"],
}


seller_list = read_txt(os.path.join(cur_dir, "list_retailers.txt"))
seller_dict = {seller.upper(): [preprocessing(seller)] for seller in seller_list}


def get_dict(type: str):
    if type == "date":
        return date_dict
    elif type == "imei":
        return imei_dict
    elif type == "sold_by":
        return sold_dict
    elif type == "header":
        return header_dict
    elif type == "extra":
        return extra_dict
    elif type == "seller":
        return seller_dict
    elif type == "seller_mapping":
        return seller_mapping
    else:
        raise ValueError(f"[ERROR] Dictionary type of {type} is not supported")
