import os
import pandas
import smtplib
import pickle
from email.mime.text import MIMEText
import brightway2 as bw
from bw2data.parameters import DatabaseParameter, ActivityParameter

project_name = "3rd_notepad"
bw.projects.set_current(project_name)

bdb_name = "battery_cell_db_v"+ "10"
bdb = bw.Database(bdb_name)

parameter_sheet_names = ['Ni_sulfate_CO2_intensity', 'Co_sulfate_CO2_intensity', 'Gr_CO2_intensity', 'Li_carbonate_CO2_intensity']

eidb_name = 'ecoinvent 3.9.1_cutoff_ecoSpold02'
eidb    = bw.Database(eidb_name)
bio     = bw.Database('biosphere3')
dummy_db = bw.Database("dummy_db")

CC_method = [m for m in bw.methods if 'IPCC 2021 no LT' in str(m) and "climate change no LT" in str(
    m) and 'global warming potential (GWP100)' in str(m)][0]

act_NMC_battery_cell = [act for act in bdb if 'NMC_battery_cell_code' in act['code']][0]
act_NMC_battery_pack = [act for act in bdb if 'NMC_battery_pack_code' in act['code']][0]
act_LFP_battery_cell = [act for act in bdb if 'LFP_battery_cell_code' in act['code']][0]

path_project = os.path.dirname(os.path.dirname(os.getcwd())) # equivalent to path to "EitR_repo"
path_results = os.path.join(path_project, "results")
path_figures = os.path.join(path_results, "figures")

#bw.bw2setup() # run this only when new project is created

# colours for deposit types
dict_deposit_types_color = {
    ('Brine',   'covered')   : "#0DA2A9",
    ('Brine', 'no data')   : "#0DA2A9",
    ('Spodumene',   'covered')   : "#0E8416",
    ('Spodumene', 'no data')   : "#0E8416",
    ('Ni laterite', 'covered')   : "#B81010",
    ('Ni laterite', 'no data') : "#B81010",
    ('Ni sulphide',   'covered') : "#070C90",
    ('Ni sulphide', 'no data') : "#070C90",
    ('SSH',   'covered') : "#FFB520",
    ('SSH', 'no data') : "#FFB520",
    ('Synthetic',   'covered') : "#7219A9",
    ('Synthetic', 'no data') : "#7219A9",
    ('Natural',   'covered') : "#7F4F0B",
    ('Natural', 'no data') : "#7F4F0B",
    ('Other', 'no data') : "#D0D0D0",
}

dict_commodities_colours = {
    "Lithium Carbonate": "#af58a2",
    "Lithium": "#af58a2",
    "Nickel Sulfate": "#3f2263",
    "Nickel": "#3f2263",
    "Cobalt Sulfate": "#8d278c",
    "Cobalt": "#8d278c",
    "Graphite": "#8F722C",
    "Production Location (Electricity)": "grey"
}

dict_regions_synonyms = {
    "CN": "China",
    "China": "CN",
    "US": "US",
    "EU": "Europe",
    "Europe": "EU",
    "KR/JP": "KRJP",
    "KRJP": "KRJP",
}