package dev.crucifixbeta.mod.modules.impl.client;

import dev.crucifixbeta.api.utils.math.Animation;
import dev.crucifixbeta.api.utils.math.Easing;
import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.BooleanSetting;
import dev.crucifixbeta.mod.modules.settings.impl.ColorSetting;
import dev.crucifixbeta.mod.modules.settings.impl.EnumSetting;
import dev.crucifixbeta.mod.modules.settings.impl.SliderSetting;
import dev.crucifixbeta.mod.modules.settings.impl.StringSetting;
import java.awt.Color;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class ClientSetting extends Module {
   public static final Animation animation;
   public static ClientSetting INSTANCE;
   public final EnumSetting<ClientSetting.Page> page = this.add(new EnumSetting<>("Page", ClientSetting.Page.Game));
   public final BooleanSetting lowVersion = this.add(new BooleanSetting("1.12", false, () -> this.page.is(ClientSetting.Page.Game)));
   public final BooleanSetting crawl = this.add(new BooleanSetting("Crawl", true, () -> this.page.is(ClientSetting.Page.Game)));
   public final BooleanSetting rotations = this.add(
      new BooleanSetting("ShowRotations", false, () -> this.page.is(ClientSetting.Page.Game)).setParent()
   );
   public final BooleanSetting sync = this.add(
      new BooleanSetting("Sync", false, () -> this.page.is(ClientSetting.Page.Game) && this.rotations.isOpen())
   );
   public final BooleanSetting titleFix = this.add(new BooleanSetting("TitleFix", true, () -> this.page.is(ClientSetting.Page.Game)));
   public final BooleanSetting fuckFPSLimit = this.add(new BooleanSetting("FuckFPSLimit", false, () -> this.page.is(ClientSetting.Page.Game)));
   private final BooleanSetting portalGui = this.add(new BooleanSetting("BlockTickNausea", false, () -> this.page.is(ClientSetting.Page.Game)));
   public final BooleanSetting optimizedCalc = this.add(new BooleanSetting("OptimizedCalc", true, () -> this.page.is(ClientSetting.Page.Game)));
   public final BooleanSetting mioCompatible = this.add(new BooleanSetting("MioCompatible", true, () -> this.page.is(ClientSetting.Page.Game)));
   public final StringSetting prefix = this.add(
      new StringSetting("Prefix", ";", () -> this.page.is(ClientSetting.Page.Misc))
   );
   public final BooleanSetting chinese = new BooleanSetting("Chinese", false, () -> false);
   public final BooleanSetting titleOverride = this.add(
      new BooleanSetting("TitleOverride", true, () -> this.page.is(ClientSetting.Page.Misc)).setParent()
   );
   public final StringSetting windowTitle = this.add(
      new StringSetting("WindowTitle", "CrucifiX Beta", () -> this.page.is(ClientSetting.Page.Misc) && this.titleOverride.isOpen())
   );
   public final BooleanSetting debug = this.add(new BooleanSetting("DebugException", true, () -> this.page.is(ClientSetting.Page.Misc)));
   public final BooleanSetting caughtException = this.add(
      new BooleanSetting("CaughtException", false, () -> this.page.is(ClientSetting.Page.Misc)).setParent()
   );
   public final BooleanSetting log = this.add(
      new BooleanSetting("Log", true, () -> this.page.is(ClientSetting.Page.Misc) && this.caughtException.isOpen())
   );
   private final BooleanSetting hotbar = this.add(new BooleanSetting("HotbarAnim", true, () -> false));
   public final SliderSetting hotbarTime = this.add(new SliderSetting("HotbarTime", 100, 0, 1000, () -> false));
   public final EnumSetting<Easing> animEase = this.add(new EnumSetting<>("AnimEase", Easing.Bounce, () -> false));
   public final BooleanSetting darkening = this.add(new BooleanSetting("Darkening", true, () -> false));
   public final SliderSetting cornerRadius = this.add(new SliderSetting("CornerRadius", 0.5, 0.0, 10.0, 0.5, () -> false));
   public final SliderSetting hudCorner = this.add(new SliderSetting("HudCorner", 4.0, 0.0, 20.0, 1.0, () -> false));
   public final SliderSetting moduleCorner = this.add(new SliderSetting("ModuleCorner", 0.0, 0.0, 10.0, 0.5, () -> false));
   public final SliderSetting panelWidth = this.add(new SliderSetting("PanelWidth", 90.0, 60.0, 140.0, 1.0, () -> false));
   public final SliderSetting titleBarWidth = this.add(new SliderSetting("TitleBarWidth", 90.0, 60.0, 180.0, 1.0, () -> false));
   public final SliderSetting searchCorner = this.add(new SliderSetting("SearchCorner", 0.0, 0.0, 12.0, 0.5, () -> false));
   public final SliderSetting moduleHeight = this.add(new SliderSetting("ModuleHeight", 15.0, 14.0, 30.0, 1.0, () -> false));
   public final SliderSetting guiScale = this.add(new SliderSetting("GuiScale", 1.0, 0.5, 2.0, 0.05, () -> false));
   public final SliderSetting headerH = this.add(new SliderSetting("HeaderHeight", 27.0, 18.0, 40.0, 1.0, () -> false));
   public final BooleanSetting panelBorder = this.add(new BooleanSetting("PanelBorder", false, () -> false));
   public final BooleanSetting panelBlur = this.add(new BooleanSetting("PanelBlur", false, () -> false));
   public final SliderSetting panelBlurRadius = this.add(new SliderSetting("PanelBlurRadius", 10.0, 1.0, 30.0, 1.0, () -> false));
   public final BooleanSetting guiGlass = this.add(
      new BooleanSetting("GuiGlass", false, () -> this.page.getValue() == ClientSetting.Page.Animation).setParent()
   );
   public final SliderSetting guiGlassBlur = this.add(
      new SliderSetting("GuiGlassBlur", 38.0, 12.0, 60.0, 1.0, () -> this.page.getValue() == ClientSetting.Page.Animation && this.guiGlass.isOpen())
   );
   public final BooleanSetting clickGuiAnim = this.add(new BooleanSetting("ClickGuiAnim", true, () -> false));
   public final SliderSetting clickGuiAnimTime = this.add(new SliderSetting("ClickGuiAnimTime", 200.0, 50.0, 600.0, 10.0, () -> false));
   public final EnumSetting<Easing> clickGuiAnimEase = this.add(new EnumSetting<>("ClickGuiAnimEase", Easing.CubicOut, () -> false));
   public final ColorSetting uiAccent = this.add(new ColorSetting("UIAccent", new Color(-9728257, true), () -> false));
   public final ColorSetting uiBg = this.add(new ColorSetting("UIBg", new Color(-871230950, true), () -> false));
   public final StringSetting hackName = this.add(
      new StringSetting("Notification", "[\u00a7fCrucifi \u00a7l\u00a7kX\u00a7r]", () -> this.page.getValue() == ClientSetting.Page.Notification)
   );
   public final ColorSetting color = this.add(
      new ColorSetting("Color", new Color(9014520, true), () -> this.page.getValue() == ClientSetting.Page.Notification)
   );
   public final EnumSetting<ClientSetting.Style> messageStyle = this.add(
      new EnumSetting<>("Style", ClientSetting.Style.Normal, () -> this.page.getValue() == ClientSetting.Page.Notification)
   );
   public final BooleanSetting toggle = this.add(
      new BooleanSetting("ModuleToggle", true, () -> this.page.getValue() == ClientSetting.Page.Notification).setParent()
   );
   public final BooleanSetting onlyOne = this.add(
      new BooleanSetting("OnlyOne", false, () -> this.page.getValue() == ClientSetting.Page.Notification && this.toggle.isOpen())
   );
   public final BooleanSetting banner = this.add(
      new BooleanSetting("ToggleBanner", true, () -> this.page.getValue() == ClientSetting.Page.Notification).setParent()
   );
   public final EnumSetting<ClientSetting.BannerStyle> bannerStyle = this.add(
      new EnumSetting<>(
         "BannerStyle", ClientSetting.BannerStyle.iOS, () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen()
      )
   );
   public final EnumSetting<ClientSetting.StackDir> bannerStack = this.add(
      new EnumSetting<>(
         "BannerStack", ClientSetting.StackDir.Down, () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen()
      )
   );
   public final SliderSetting bannerFade = this.add(
      new SliderSetting("BannerFade", 160, 0, 1000, () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen())
   );
   public final SliderSetting bannerHold = this.add(
      new SliderSetting("BannerHold", 1000, 0, 3000, () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen())
   );
   public final BooleanSetting bannerSound = this.add(
      new BooleanSetting("BannerSound", true, () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen()).setParent()
   );
   public final SliderSetting bannerSoundPitch = this.add(
      new SliderSetting(
         "BannerPitch",
         1.0,
         0.5,
         2.0,
         0.05,
         () -> this.page.getValue() == ClientSetting.Page.Notification && this.banner.isOpen() && this.bannerSound.getValue()
      )
   );
   public final BooleanSetting keepHistory = this.add(
      new BooleanSetting("KeepHistory", true, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final BooleanSetting infiniteChat = this.add(
      new BooleanSetting("InfiniteChat", true, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final BooleanSetting hideIndicator = this.add(
      new BooleanSetting("HideIndicator", true, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final SliderSetting animationTime = this.add(
      new SliderSetting("AnimationTime", 300, 0, 1000, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final EnumSetting<Easing> ease = this.add(
      new EnumSetting<>("Ease", Easing.Bounce, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final SliderSetting animateOffset = this.add(
      new SliderSetting("Offset", -40, -200, 100, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final BooleanSetting fade = this.add(new BooleanSetting("Fade", true, () -> this.page.getValue() == ClientSetting.Page.ChatHud));
   public final ColorSetting chatBackgroundColor = this.add(
      new ColorSetting("ChatBgColor", new Color(0, 0, 0, 120), () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final BooleanSetting chatBackgroundBlur = this.add(
      new BooleanSetting("ChatBgBlur", false, () -> this.page.getValue() == ClientSetting.Page.ChatHud).setParent()
   );
   public final SliderSetting chatBackgroundBlurRadius = this.add(
      new SliderSetting(
         "ChatBlurRadius", 12.0, 1.0, 60.0, 1.0, () -> this.page.getValue() == ClientSetting.Page.ChatHud && this.chatBackgroundBlur.isOpen()
      )
   );
   public final SliderSetting chatBackgroundRadius = this.add(
      new SliderSetting("ChatBgRadius", 0.0, 0.0, 16.0, 0.5, () -> this.page.getValue() == ClientSetting.Page.ChatHud)
   );
   public final EnumSetting<ClientSetting.GuiAnimation> clickGuiOpenCloseAnimation = this.add(
      new EnumSetting<>("ClickGuiOpenClose", ClientSetting.GuiAnimation.Default, () -> this.page.getValue() == ClientSetting.Page.Animation)
   );
   public final EnumSetting<ClientSetting.GuiAnimation> functionBarAnimation = this.add(
      new EnumSetting<>("FunctionBarExpand", ClientSetting.GuiAnimation.Default, () -> this.page.getValue() == ClientSetting.Page.Animation)
   );
   public final EnumSetting<ClientSetting.GuiAnimation> parameterPanelAnimation = this.add(
      new EnumSetting<>("ParameterExpand", ClientSetting.GuiAnimation.Default, () -> this.page.getValue() == ClientSetting.Page.Animation)
   );
   public final EnumSetting<ClientSetting.GuiAnimation> pageSwitchAnimation = this.add(
      new EnumSetting<>("PageSwitch", ClientSetting.GuiAnimation.Default, () -> this.page.getValue() == ClientSetting.Page.Animation)
   );
   public final SliderSetting sliderFollowSpeed = this.add(
         new SliderSetting("SliderFollowSpeed", 10.0, 1.0, 30.0, 0.5, () -> this.page.getValue() == ClientSetting.Page.Animation)
      )
      .setSuffix("x");
   public final SliderSetting titleScrollSpeed = this.add(
         new SliderSetting("TitleScrollSpeed", 10.0, 1.0, 30.0, 0.5, () -> this.page.getValue() == ClientSetting.Page.Misc)
      )
      .setSuffix("x");

   public ClientSetting() {
      super("ClientSetting", Module.Category.Client);
      this.setChinese("\u5ba2\u6237\u7aef\u8bbe\u7f6e");
      this.clickGuiOpenCloseAnimation.setChinese("ClickGUI\u6253\u5f00\u5173\u95ed");
      this.functionBarAnimation.setChinese("\u529f\u80fd\u680f\u5c55\u5f00\u6536\u7f29");
      this.parameterPanelAnimation.setChinese("\u53c2\u6570\u680f\u5c55\u5f00\u6536\u7f29");
      this.pageSwitchAnimation.setChinese("\u53f3\u4e0b\u89d2\u5206\u9875\u5207\u6362");
      this.sliderFollowSpeed.setChinese("\u62c9\u6761\u8ddf\u624b\u901f\u5ea6");
      this.titleScrollSpeed.setChinese("\u6807\u9898\u6eda\u52a8\u901f\u5ea6");
      this.chatBackgroundColor.setChinese("\u804a\u5929\u80cc\u666f\u989c\u8272");
      this.chatBackgroundBlur.setChinese("\u804a\u5929\u80cc\u666f\u6a21\u7cca");
      this.chatBackgroundBlurRadius.setChinese("\u804a\u5929\u6a21\u7cca\u5f3a\u5ea6");
      this.chatBackgroundRadius.setChinese("\u804a\u5929\u80cc\u666f\u5706\u89d2");
      INSTANCE = this;
   }

   public static long sliderFollowDuration(long defaultDuration) {
      return scaledDuration(defaultDuration, INSTANCE == null ? 10.0 : INSTANCE.sliderFollowSpeed.getValue());
   }

   public static long titleScrollDelay(long defaultDelay) {
      return scaledDuration(defaultDelay, INSTANCE == null ? 10.0 : INSTANCE.titleScrollSpeed.getValue());
   }

   private static long scaledDuration(long defaultDuration, double speed) {
      double var4 = Math.max(1.0, speed);
      return Math.max(1L, Math.round((double)defaultDuration * 10.0 / var4));
   }

   public boolean portalGui() {
      return this.isOn() && this.portalGui.getValue();
   }

   public boolean hotbar() {
      return this.isOn() && this.hotbar.getValue();
   }

   @Override
   public void enable() {
      this.state = true;
   }

   @Override
   public void disable() {
      this.state = true;
   }

   @Override
   public boolean isOn() {
      return true;
   }

   static {

      animation = new Animation();
   }
@Environment(EnvType.CLIENT)
   public static enum BannerStyle {
      iOS,
      Classic;

}

   @Environment(EnvType.CLIENT)
   public static enum GuiAnimation {
      Default,
      Off,
      Linear,
      Smooth,
      Fast,
      Slow,
      Elastic;

}

   @Environment(EnvType.CLIENT)
   public static enum Page {
      Game,
      Misc,
      Notification,
      ChatHud,
      Animation;

}

   @Environment(EnvType.CLIENT)
   public static enum StackDir {
      Down,
      Up;

}

   @Environment(EnvType.CLIENT)
   public static enum Style {
      Mio,
      Debug,
      Lowercase,
      Normal,
      Future,
      Earth,
      Moon,
      Melon,
      Chinese,
      None;

}
}
