// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java
// public class MathUtils {
// 
//     public static double lerp(double a, double b, double f) {
//         return a + f * (b - a);
//     }
// 
//     /**
//      * Linearly interpolates between two {@link UIColor}s
//      *
//      * @param a The starting {@link UIColor}
//      * @param b The ending {@link UIColor}
//      * @param f The percentage between the two {@link UIColor}
//      * @return The {@link UIColor} which if f% between a and b
//      */
//     public static UIColor lerpUIColor(UIColor a, UIColor b, float f) {
//         return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255),
//                 a.g * 255 + f * (b.g * 255 - a.g * 255),
//                 a.b * 255 + f * (b.b * 255 - a.b * 255),
//                 a.a * 255 + f * (b.a * 255 - a.a * 255));
//     }
// 
//     public static double clamp(double val, double min, double max) {
//         return Math.max(min, Math.min(max, val));
//     }
// 
//     public static PosXYZ normalizeRotation(PosXYZ rot) {
//         while (rot.x >= 360) {
//             rot.x -= 360;
//         }
// 
//         while (rot.y >= 360) {
//             rot.y -= 360;
//         }
// 
//         while (rot.z >= 360) {
//             rot.z -= 360;
//         }
// 
//         while (rot.x < 0) {
//             rot.x += 360;
//         }
// 
//         while (rot.y < 0) {
//             rot.y += 360;
//         }
// 
//         while (rot.z < 0) {
//             rot.z += 360;
//         }
// 
//         return rot;
//     }
// 
//     public static boolean isInRange(double val, double min, double max) {
//         return val >= min && val <= max;
//     }
// 
//     public static float snapTo(float val, float snapTo) {
//         float roundMultiplier = 1.0f / snapTo;
//         return Math.round(val * roundMultiplier) / roundMultiplier;
//     }
// 
//     /**
//      * @param t A value from 0 to 1
//      * @return Quadratic interpolated value between 0 and 1
//      */
//     public static float cubicEaseInOut(float t) {
//         return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f;
//     }
// 
// }


import craftedcart.smblevelworkshop.util.MathUtils;
import io.github.craftedcart.fluidui.component.Label;
import io.github.craftedcart.fluidui.component.ListBox;
import io.github.craftedcart.fluidui.component.Panel;
import io.github.craftedcart.fluidui.theme.UITheme;
import io.github.craftedcart.fluidui.util.EnumHAlignment;
import io.github.craftedcart.fluidui.util.EnumVAlignment;
import io.github.craftedcart.fluidui.util.UIColor;
import io.github.craftedcart.fluidui.util.UIUtils;
import org.jetbrains.annotations.NotNull;

        if (flashTimerPercent > 0) {
            flashTimerPercent -= UIUtils.getDelta() * 4; //Lasts for 0.25 seconds
            flashTimerPercent = Math.max(flashTimerPercent, 0);

            label.setTextColor(MathUtils.lerpUIColor(UIColor.matWhite(), UIColor.matBlue(), flashTimerPercent).alpha(timerPercent == -1 ? 1 : timerPercent));
        }

        if (timerPercent != -1) {
            timerPercent -= UIUtils.getDelta(); //Last for 1 second
            label.setTextColor(label.textColor.alpha(timerPercent));

            if (timerPercent <= 0.0f) { //Self destruct!
                assert parentComponent instanceof ListBox;
                ((ListBox) parentComponent).removeChildComponent(name);
            }
        }
    }

    @Override
    public void setTheme(@NotNull UITheme theme) {
        super.setTheme(theme);

        backgroundColor = theme.panelBackgroundColor.alpha(0.25);
    }

    public void startTimer() {
        timerPercent = 1;
    }

// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java
// public class MathUtils {
// 
//     public static double lerp(double a, double b, double f) {
//         return a + f * (b - a);
//     }
// 
//     /**
//      * Linearly interpolates between two {@link UIColor}s
//      *
//      * @param a The starting {@link UIColor}
//      * @param b The ending {@link UIColor}
//      * @param f The percentage between the two {@link UIColor}
//      * @return The {@link UIColor} which if f% between a and b
//      */
//     public static UIColor lerpUIColor(UIColor a, UIColor b, float f) {
//         return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255),
//                 a.g * 255 + f * (b.g * 255 - a.g * 255),
//                 a.b * 255 + f * (b.b * 255 - a.b * 255),
//                 a.a * 255 + f * (b.a * 255 - a.a * 255));
//     }
// 
//     public static double clamp(double val, double min, double max) {
//         return Math.max(min, Math.min(max, val));
//     }
// 
//     public static PosXYZ normalizeRotation(PosXYZ rot) {
//         while (rot.x >= 360) {
//             rot.x -= 360;
//         }
// 
//         while (rot.y >= 360) {
//             rot.y -= 360;
//         }
// 
//         while (rot.z >= 360) {
//             rot.z -= 360;
//         }
// 
//         while (rot.x < 0) {
//             rot.x += 360;
//         }
// 
//         while (rot.y < 0) {
//             rot.y += 360;
//         }
// 
//         while (rot.z < 0) {
//             rot.z += 360;
//         }
// 
//         return rot;
//     }
// 
//     public static boolean isInRange(double val, double min, double max) {
//         return val >= min && val <= max;
//     }
// 
//     public static float snapTo(float val, float snapTo) {
//         float roundMultiplier = 1.0f / snapTo;
//         return Math.round(val * roundMultiplier) / roundMultiplier;
//     }
// 
//     /**
//      * @param t A value from 0 to 1
//      * @return Quadratic interpolated value between 0 and 1
//      */
//     public static float cubicEaseInOut(float t) {
//         return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f;
//     }
// 
// }


// Path: src/main/java/craftedcart/smblevelworkshop/ui/component/KeyDisplay.java
import craftedcart.smblevelworkshop.util.MathUtils;
import io.github.craftedcart.fluidui.component.Label;
import io.github.craftedcart.fluidui.component.ListBox;
import io.github.craftedcart.fluidui.component.Panel;
import io.github.craftedcart.fluidui.theme.UITheme;
import io.github.craftedcart.fluidui.util.EnumHAlignment;
import io.github.craftedcart.fluidui.util.EnumVAlignment;
import io.github.craftedcart.fluidui.util.UIColor;
import io.github.craftedcart.fluidui.util.UIUtils;
import org.jetbrains.annotations.NotNull;


        if (flashTimerPercent > 0) {
            flashTimerPercent -= UIUtils.getDelta() * 4; //Lasts for 0.25 seconds
            flashTimerPercent = Math.max(flashTimerPercent, 0);

            label.setTextColor(MathUtils.lerpUIColor(UIColor.matWhite(), UIColor.matBlue(), flashTimerPercent).alpha(timerPercent == -1 ? 1 : timerPercent));
        }

        if (timerPercent != -1) {
            timerPercent -= UIUtils.getDelta(); //Last for 1 second
            label.setTextColor(label.textColor.alpha(timerPercent));

            if (timerPercent <= 0.0f) { //Self destruct!
                assert parentComponent instanceof ListBox;
                ((ListBox) parentComponent).removeChildComponent(name);
            }
        }
    }

    @Override
    public void setTheme(@NotNull UITheme theme) {
        super.setTheme(theme);

        backgroundColor = theme.panelBackgroundColor.alpha(0.25);
    }

    public void startTimer() {
        timerPercent = 1;
    }

    public void stopTimer() {