import { ActionFormData } from "@minecraft/server-ui";
import { ChangeLog, SpongeRecipes, StarterBook, StarterBookIcons } from "../data/formEnums";
export function openStarterBookMain(player) {
    const form = new ActionFormData();
    form.title(StarterBook.MainTitle);
    form.body(StarterBook.MainBody);
    form.button(StarterBook.SpongesButton, StarterBookIcons.Sponges);
    form.button(StarterBook.AdditionalInfoButton, StarterBookIcons.AdditionalInfo);
    form.button(StarterBook.ChangeLogButton, StarterBookIcons.ChangeLog);
    form.button(StarterBook.SupportButton, StarterBookIcons.Support);
    form.button(StarterBook.ExitButton, StarterBookIcons.Exit);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        switch (response.selection) {
            case 0:
                openSpongesInfo(player);
                break;
            case 1:
                openAdditionalInfo(player);
                break;
            case 2:
                openChangeLogInfo(player);
                break;
            case 3:
                openSupportInfo(player);
                break;
            default: return;
        }
    });
}
function openSpongesInfo(player) {
    const form = new ActionFormData();
    form.title(StarterBook.SpongeInfoTitle);
    form.body(StarterBook.SpongeInfoBody);
    form.button(StarterBook.AntiEnderSponge, StarterBookIcons.AntiEnderSponge);
    form.button(StarterBook.ClearWeatherSponge, StarterBookIcons.ClearWeatherSponge);
    form.button(StarterBook.DecaySponge, StarterBookIcons.DecaySponge);
    form.button(StarterBook.EffectsSponge, StarterBookIcons.EffectsSponge);
    form.button(StarterBook.ExplosionSponge, StarterBookIcons.ExplosionSponge);
    form.button(StarterBook.FeedingSponge, StarterBookIcons.FeedingSponge);
    form.button(StarterBook.FireSponge, StarterBookIcons.FireSponge);
    form.button(StarterBook.FrostSponge, StarterBookIcons.FrostSponge);
    form.button(StarterBook.GravitySponge, StarterBookIcons.GravitySponge);
    form.button(StarterBook.GrowthSponge, StarterBookIcons.GrowthSponge);
    form.button(StarterBook.HealingSponge, StarterBookIcons.HealingSponge);
    form.button(StarterBook.JumpSponge, StarterBookIcons.JumpSponge);
    form.button(StarterBook.LavaSponge, StarterBookIcons.LavaSponge);
    form.button(StarterBook.LightSponge, StarterBookIcons.LightSponge);
    form.button(StarterBook.MagnetSponge, StarterBookIcons.MagnetSponge);
    form.button(StarterBook.NightSponge, StarterBookIcons.NightSponge);
    form.button(StarterBook.NightVisionSponge, StarterBookIcons.NightVisionSponge);
    form.button(StarterBook.PoisonSponge, StarterBookIcons.PoisonSponge);
    form.button(StarterBook.RedstoneSponge, StarterBookIcons.RedstoneSponge);
    form.button(StarterBook.ShadowSponge, StarterBookIcons.ShadowSponge);
    form.button(StarterBook.SilkSponge, StarterBookIcons.SilkSponge);
    form.button(StarterBook.SmokeSponge, StarterBookIcons.SmokeSponge);
    form.button(StarterBook.SpeedSponge, StarterBookIcons.SpeedSponge);
    form.button(StarterBook.StickySponge, StarterBookIcons.StickySponge);
    form.button(StarterBook.TeleportSponge, StarterBookIcons.TeleportSponge);
    form.button(StarterBook.ThornSponge, StarterBookIcons.ThornSponge);
    form.button(StarterBook.TntSponge, StarterBookIcons.TntSponge);
    form.button(StarterBook.VoidSponge, StarterBookIcons.VoidSponge);
    form.button(StarterBook.WitherSponge, StarterBookIcons.WitherSponge);
    form.button(StarterBook.XpSponge, StarterBookIcons.XpSponge);
    form.button(StarterBook.BackButton, StarterBookIcons.Back);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        switch (response.selection) {
            case 0:
                showSpongeInfo(player, StarterBook.AntiEnderSponge, StarterBook.AntiEnderSpongeBody, SpongeRecipes.AntiEnderSponge);
                break;
            case 1:
                showSpongeInfo(player, StarterBook.ClearWeatherSponge, StarterBook.ClearWeatherSpongeBody, SpongeRecipes.ClearWeatherSponge);
                break;
            case 2:
                showSpongeInfo(player, StarterBook.DecaySponge, StarterBook.DecaySpongeBody, SpongeRecipes.DecaySponge);
                break;
            case 3:
                showSpongeInfo(player, StarterBook.EffectsSponge, StarterBook.EffectsSpongeBody, SpongeRecipes.EffectsSponge);
                break;
            case 4:
                showSpongeInfo(player, StarterBook.ExplosionSponge, StarterBook.ExplosionSpongeBody, SpongeRecipes.ExplosionSponge);
                break;
            case 5:
                showSpongeInfo(player, StarterBook.FeedingSponge, StarterBook.FeedingSpongeBody, SpongeRecipes.FeedingSponge);
                break;
            case 6:
                showSpongeInfo(player, StarterBook.FireSponge, StarterBook.FireSpongeBody, SpongeRecipes.FireSponge);
                break;
            case 7:
                showSpongeInfo(player, StarterBook.FrostSponge, StarterBook.FrostSpongeBody, SpongeRecipes.FrostSponge);
                break;
            case 8:
                showSpongeInfo(player, StarterBook.GravitySponge, StarterBook.GravitySpongeBody, SpongeRecipes.GravitySponge);
                break;
            case 9:
                showSpongeInfo(player, StarterBook.GrowthSponge, StarterBook.GrowthSpongeBody, SpongeRecipes.GrowthSponge);
                break;
            case 10:
                showSpongeInfo(player, StarterBook.HealingSponge, StarterBook.HealingSpongeBody, SpongeRecipes.HealingSponge);
                break;
            case 11:
                showSpongeInfo(player, StarterBook.JumpSponge, StarterBook.JumpSpongeBody, SpongeRecipes.JumpSponge);
                break;
            case 12:
                showSpongeInfo(player, StarterBook.LavaSponge, StarterBook.LavaSpongeBody, SpongeRecipes.LavaSponge);
                break;
            case 13:
                showSpongeInfo(player, StarterBook.LightSponge, StarterBook.LightSpongeBody, SpongeRecipes.LightSponge);
                break;
            case 14:
                showSpongeInfo(player, StarterBook.MagnetSponge, StarterBook.MagnetSpongeBody, SpongeRecipes.MagnetSponge);
                break;
            case 15:
                showSpongeInfo(player, StarterBook.NightSponge, StarterBook.NightSpongeBody, SpongeRecipes.NightSponge);
                break;
            case 16:
                showSpongeInfo(player, StarterBook.NightVisionSponge, StarterBook.NightVisionSpongeBody, SpongeRecipes.NightVisionSponge);
                break;
            case 17:
                showSpongeInfo(player, StarterBook.PoisonSponge, StarterBook.PoisonSpongeBody, SpongeRecipes.PoisonSponge);
                break;
            case 18:
                showSpongeInfo(player, StarterBook.RedstoneSponge, StarterBook.RedstoneSpongeBody, SpongeRecipes.RedstoneSponge);
                break;
            case 19:
                showSpongeInfo(player, StarterBook.ShadowSponge, StarterBook.ShadowSpongeBody, SpongeRecipes.ShadowSponge);
                break;
            case 20:
                showSpongeInfo(player, StarterBook.SilkSponge, StarterBook.SilkSpongeBody, SpongeRecipes.SilkSponge);
                break;
            case 21:
                showSpongeInfo(player, StarterBook.SmokeSponge, StarterBook.SmokeSpongeBody, SpongeRecipes.SmokeSponge);
                break;
            case 22:
                showSpongeInfo(player, StarterBook.SpeedSponge, StarterBook.SpeedSpongeBody, SpongeRecipes.SpeedSponge);
                break;
            case 23:
                showSpongeInfo(player, StarterBook.StickySponge, StarterBook.StickySpongeBody, SpongeRecipes.StickySponge);
                break;
            case 24:
                showSpongeInfo(player, StarterBook.TeleportSponge, StarterBook.TeleportSpongeBody, SpongeRecipes.TeleportSponge);
                break;
            case 25:
                showSpongeInfo(player, StarterBook.ThornSponge, StarterBook.ThornSpongeBody, SpongeRecipes.ThornSponge);
                break;
            case 26:
                showSpongeInfo(player, StarterBook.TntSponge, StarterBook.TntSpongeBody, SpongeRecipes.TntSponge);
                break;
            case 27:
                showSpongeInfo(player, StarterBook.VoidSponge, StarterBook.VoidSpongeBody, SpongeRecipes.VoidSponge);
                break;
            case 28:
                showSpongeInfo(player, StarterBook.WitherSponge, StarterBook.WitherSpongeBody, SpongeRecipes.WitherSponge);
                break;
            case 29:
                showSpongeInfo(player, StarterBook.XpSponge, StarterBook.XpSpongeBody, SpongeRecipes.XpSponge);
                break;
            case 30:
                openStarterBookMain(player);
                break;
            default: return;
        }
    });
}
function showSpongeInfo(player, spongeName, body, recipe) {
    const form = new ActionFormData();
    form.title(spongeName);
    form.button(StarterBook.BackButton, StarterBookIcons.Back);
    form.body(`${body}${recipe ? `\n\n${recipe}` : ""}`);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        if (response.selection === 0 && recipe)
            openSpongesInfo(player);
    });
}
function openAdditionalInfo(player) {
    const form = new ActionFormData();
    form.title(StarterBook.AdditionalInfoTitle);
    form.body(StarterBook.AdditionalInfoBody);
    form.button(StarterBook.BackButton, StarterBookIcons.Back);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        if (response.selection === 0)
            openStarterBookMain(player);
    });
}
function openChangeLogInfo(player) {
    const form = new ActionFormData();
    form.title(ChangeLog.Title);
    form.body(ChangeLog.Body);
    form.button(StarterBook.BackButton, StarterBookIcons.Back);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        if (response.selection === 0)
            openStarterBookMain(player);
    });
}
function openSupportInfo(player) {
    const form = new ActionFormData();
    form.title(StarterBook.SupportTitle);
    form.body(StarterBook.SupportBody);
    form.button(StarterBook.BackButton, StarterBookIcons.Back);
    form.show(player).then((response) => {
        if (response.canceled || response.selection === undefined)
            return;
        if (response.selection === 0)
            openStarterBookMain(player);
    });
}
