import { ActionFormData } from "@minecraft/server-ui";
import { guideMainView } from "./guideMainView";
import { guideViewComponet } from "./components";

export const guideItemView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item")//Items
    actionForm.body("view.description.guide.item")//Categorías de items
    actionForm.button("view.title.guide.item.containers", "textures/nps/ec/items/plasma_capsule_unloaded")//Contenedores
    actionForm.button("view.title.guide.item.plasma_weapons", "textures/nps/ec/items/fast_plasma_weapon")//Armas de plasma
    actionForm.button("view.title.guide.item.plasma_tools", "textures/nps/ec/items/plasma_drill")//Herramientas de plasma
    actionForm.button("view.title.guide.item.dna_capsules", "textures/nps/ec/items/digital_dna_damage")//Cápsulas de DNA
    actionForm.button("view.title.guide.item.digital_mobs_eggs", "textures/nps/ec/items/egg_digital_empty")//Huevos de mobs digitales
    actionForm.button("view.guide.uncategory", "textures/nps/ec/items/teleport_point")//Sin categoría
    actionForm.button("view.button_return");//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideItemContainersView(player);
        } else if (data.selection == 1) {
            guideItemPlasmaWeaponsView(player);
        } else if (data.selection == 2) {
            guideItemPlasmaToolsView(player);
        } else if (data.selection == 3) {
            guideItemDNACapsulesView(player);
        } else if (data.selection == 4) {
            guideItemDigitalMobsEggsView(player);
        } else if (data.selection == 5) {
            guideItemNoCategoryView(player);
        } else {
            guideMainView(player);
        }
    })
}


const guideItemContainersView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item.containers")//Contenedores
    actionForm.body("view.description.guide.item.containers")//Contenedores de items
    actionForm.button("item.nps_ec:plasma_capsule")//Plasma Capsule
    actionForm.button("item.nps_ec:plasma_capsule_unloaded")//Plasma Capsule Unloaded
    actionForm.button("item.nps_ec:battery_cell")//Battery Cell
    actionForm.button("item.nps_ec:battery_cell_unloaded")//Battery Cell Unloaded
    actionForm.button("view.button_return");//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:plasma_capsule", {
                rawtext: [
                    {
                        translate: "view.containers.plasma_capsule.1"
                    },
                    {
                        translate: "view.make.plasma_reloader"
                    }
                ]
            }, guideItemContainersView, "textures/nps/ec/recipes/plasma_capsule")//Plasma Capsule
        } else if (data.selection == 1) {
            guideViewComponet(player, "item.nps_ec:plasma_capsule_unloaded", {
                rawtext: [
                    {
                        translate: "view.containers.plasma_capsule_unloaded.1"
                    },
                    {
                        translate: "view.containers.plasma_capsule_unloaded.2"
                    }
                ]
            }, guideItemContainersView, "textures/nps/ec/recipes/plasma_capsule_unloaded")//Plasma Capsule Unloaded
        } else if (data.selection == 2) {
            guideViewComponet(player, "item.nps_ec:battery_cell", {
                rawtext: [
                    {
                        translate: "view.containers.battery_cell.1"
                    },
                    {
                        translate: "view.make.battery_charger"
                    }
                ]
            }, guideItemContainersView, "textures/nps/ec/recipes/battery_cell")//Battery Cell
        } else if (data.selection == 3) {
            guideViewComponet(player, "item.nps_ec:battery_cell_unloaded", {
                rawtext: [
                    {
                        translate: "view.containers.battery_cell_unloaded.1"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemContainersView, "textures/nps/ec/recipes/battery_cell_unloaded")//Battery Cell Unloaded
        } else {
            guideItemView(player);
        }
    })
}

const guideItemPlasmaWeaponsView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item.plasma_weapons")//Armas de plasma
    actionForm.body("view.description.guide.item.plasma_weapons")//Armas de plasma
    actionForm.button("item.nps_ec:fast_plasma_weapon")//Plasma SMG
    actionForm.button("view.button_return")//Regresar
    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:fast_plasma_weapon", {
                rawtext: [
                    {
                        translate: "view.plasma_weapons.fast_plasma_weapon.1"
                    },
                    {
                        translate: "view.plasma_weapons.fast_plasma_weapon.2"
                    },
                    {
                        translate: "view.plasma_weapons.fast_plasma_weapon.3"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemPlasmaWeaponsView, "textures/nps/ec/recipes/plasma_weapon")//Plasma SMG
        } else {
            guideItemView(player);
        }
    })
}

const guideItemPlasmaToolsView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item.plasma_tools")//Herramientas de plasma
    actionForm.body("view.description.guide.item.plasma_tools")//Herramientas de plasma
    actionForm.button("item.nps_ec:plasma_drill")//Plasma Drill
    actionForm.button("item.nps_ec:plasma_drill_unloaded")//Plasma Drill Unloaded
    actionForm.button("item.nps_ec:plasma_lighter")//Plasma Lighter
    actionForm.button("item.nps_ec:plasma_lighter_unloaded")//Plasma Lighter Unloaded
    actionForm.button("view.button_return")//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:plasma_drill", {
                rawtext: [
                    {
                        translate: "view.plasma_tools.plasma_drill.1"
                    },
                    {
                        translate: "view.plasma_tools.plasma_drill.2"
                    },
                    {
                        translate: "view.plasma_tools.plasma_drill.3"
                    },
                    {
                        translate: "view.plasma_tools.plasma_drill.4"
                    },
                    {
                        translate: "view.reload_in.plasma_reloader"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemPlasmaToolsView, "textures/nps/ec/recipes/plasma_drill")//Plasma Drill
        } else if (data.selection == 1) {
            guideViewComponet(player, "item.nps_ec:plasma_drill_unloaded", {
                rawtext: [
                    {
                        translate: "view.plasma_tools.plasma_drill_unloaded.1"
                    },
                    {
                        translate: "view.reload_in.plasma_reloader"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemPlasmaToolsView, "textures/nps/ec/recipes/plasma_drill_unloaded")//Plasma Drill Unloaded
        } else if (data.selection == 2) {
            guideViewComponet(player, "item.nps_ec:plasma_lighter", {
                rawtext: [
                    {
                        translate: "view.plasma_tools.plasma_lighter.1"
                    },
                    {
                        translate: "view.reload_in.plasma_reloader"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemPlasmaToolsView, "textures/nps/ec/recipes/plasma_lighter")//Plasma Lighter
        }
        else if (data.selection == 3) {
            guideViewComponet(player, "item.nps_ec:plasma_lighter_unloaded", {
                rawtext: [
                    {
                        translate: "view.plasma_tools.plasma_lighter_unloaded.1"
                    },
                    {
                        translate: "view.reload_in.plasma_reloader"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemPlasmaToolsView, "textures/nps/ec/recipes/plasma_lighter_unloaded")//Plasma Lighter Unloaded
        } else {
            guideItemView(player);
        }
    })
}

const guideItemDNACapsulesView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item.dna_capsules")//Cápsulas de DNA
    actionForm.body("view.description.guide.item.dna_capsules")//Cápsulas de DNA
    actionForm.button("item.nps_ec:digital_dna_capsule")//DNA Capsule
    actionForm.button("view.dna_capsule_mob")//Digital DNA Capsule Mob
    actionForm.button("view.button_return")//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:digital_dna_capsule", {
                rawtext: [
                    {
                        translate: "view.dna_capsules.digital_dna_capsule.1"
                    },
                    {
                        translate: "view.dna_capsules.digital_dna_capsule.2"
                    }
                ]
            }, guideItemDNACapsulesView)//DNA Capsule
        } else if (data.selection == 1) {
            guideViewComponet(player, "view.dna_capsule_mob", {
                rawtext: [
                    {
                        translate: "view.dna_capsules.dna_capsule_mob.1"
                    },
                    {
                        translate: "view.dna_capsules.digital_dna_capsule.2"
                    }
                ]
            }, guideItemDNACapsulesView)//Digital DNA Capsule Mob
        } else {
            guideItemView(player);
        }
    })
}

const guideItemDigitalMobsEggsView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.title.guide.item.digital_mobs_eggs")//Huevos de mobs digitales
    actionForm.body("view.description.guide.item.digital_mobs_eggs")//Huevos de mobs digitales
    actionForm.button("item.nps_ec:egg_digital_empty")//Digital Egg Empty
    actionForm.button("view.digital_spawn_mob")//Digital Spawn Mob
    actionForm.button("view.button_return")//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:egg_digital_empty", {
                rawtext: [
                    {
                        translate: "view.digital_mob_eggs.egg_digital_empty.1",
                        with: {
                            rawtext: [
                                {
                                    translate: "view.digital_spawn_mob"
                                }
                            ]
                        }
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemDigitalMobsEggsView, "textures/nps/ec/recipes/egg_digital_empty")//Digital Egg Empty
        } else if (data.selection == 1) {
            guideViewComponet(player, "view.digital_spawn_mob", {
                rawtext: [
                    {
                        translate: "view.digital_mob_eggs.digital_spawn_mob.1"
                    },
                    {
                        translate: "view.make.digital_table"
                    }
                ]
            }, guideItemDigitalMobsEggsView, "textures/nps/ec/recipes/digital_spawn_mob")//Digital Spawn Mob
        } else {
            guideItemView(player);
        }
    })
}

const guideItemNoCategoryView = (player) => {
    const actionForm = new ActionFormData();
    actionForm.title("view.guide.uncategory")//Sin categoría
    actionForm.body("view.description.guide.no_category")//Descripción de sin categoría
    actionForm.button("item.nps_ec:broken_tool_switcher")//Broken Tool Switcher
    actionForm.button("item.nps_ec:chest_sorter")//Chest Sorter
    actionForm.button("item.nps_ec:plasma_scrap")//Plasma Scrap
    actionForm.button("item.nps_ec:plasma_refined")//Plasma Refined
    actionForm.button("item.nps_ec:charged_amethyst")//Charged Amethyst
    actionForm.button("item.nps_ec:teleport_point")//Teleport Point
    actionForm.button("item.nps_ec:plasma_boots")//Plasma Boots
    actionForm.button("view.button_return")//Regresar

    actionForm.show(player).then((data) => {
        if (data.canceled) return;
        if (data.selection == 0) {
            guideViewComponet(player, "item.nps_ec:broken_tool_switcher", {
                rawtext: [
                    {
                        translate: "view.not_category.broken_tool_switcher.1"
                    },
                    {
                        translate: "view.not_category.broken_tool_switcher.2"
                    },
                    {
                        translate: "view.not_category.broken_tool_switcher.3"
                    },
                    {
                        translate: "view.not_category.broken_tool_switcher.4"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemNoCategoryView, "textures/nps/ec/recipes/broken_tool_switcher")//Broken Tool Switcher
        } else if (data.selection == 1) {
            guideViewComponet(player, "item.nps_ec:chest_sorter", {
                rawtext: [
                    {
                        translate: "view.not_category.chest_sorter.1"
                    },
                    {
                        translate: "view.not_category.chest_sorter.2"
                    },
                    {
                        translate: "view.not_category.chest_sorter.3"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemNoCategoryView, "textures/nps/ec/recipes/chest_sorter")//Chest Sorter
        } else if (data.selection == 2) {
            guideViewComponet(player, "item.nps_ec:plasma_scrap", {
                rawtext: [
                    {
                        translate: "view.not_category.plasma_scrap.1"
                    },
                    {
                        translate: "view.not_category.plasma_scrap.2"
                    }
                ]
            }, guideItemNoCategoryView)//Plasma Scrap
        } else if (data.selection == 3) {
            guideViewComponet(player, "item.nps_ec:plasma_refined", {
                rawtext: [
                    {
                        translate: "view.not_category.plasma_refined.1"
                    },
                    {
                        translate: "view.not_category.plasma_refined.2"
                    }
                ]
            }, guideItemNoCategoryView, "textures/nps/ec/recipes/plasma_refined")//Plasma Refined
        } else if (data.selection == 4) {
            guideViewComponet(player, "item.nps_ec:charged_amethyst", {
                rawtext: [
                    {
                        translate: "view.not_category.charged_amethyst.1"
                    }
                ]
            }, guideItemNoCategoryView)//Charged Amethyst
        } else if (data.selection ==
            5) {
            guideViewComponet(player, "item.nps_ec:teleport_point", {
                rawtext: [
                    {
                        translate: "view.not_category.teleport_point.1"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemNoCategoryView, "textures/nps/ec/recipes/teleport_point")//Teleport Point
        } else if (data.selection == 6) {
            guideViewComponet(player, "item.nps_ec:plasma_boots", {
                rawtext: [
                    {
                        translate: "view.not_category.plasma_boots.1"
                    },
                    {
                        translate: "view.not_category.plasma_boots.2"
                    },
                    {
                        translate: "view.not_category.plasma_boots.3"
                    },
                    {
                        translate: "view.not_category.plasma_boots.4"
                    },
                    {
                        translate: "view.make.crafting_table"
                    }
                ]
            }, guideItemNoCategoryView, "textures/nps/ec/recipes/plasma_boots")//Plasma Boots
        } else {
            guideItemView(player);
        }
    })
}