package q;

import p0.AbstractC2686D;

/* JADX INFO: renamed from: q.u, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2802u implements InterfaceC2807y {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final float f23451a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final float f23452b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final float f23453c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final float f23454d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final float f23455e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final float f23456f;

    public C2802u(float f6, float f7, float f8, float f9) {
        int iP;
        this.f23451a = f6;
        this.f23452b = f7;
        this.f23453c = f8;
        this.f23454d = f9;
        if (!((Float.isNaN(f6) || Float.isNaN(f7) || Float.isNaN(f8) || Float.isNaN(f9)) ? false : true)) {
            W.a("Parameters to CubicBezierEasing cannot be NaN. Actual parameters are: " + f6 + ", " + f7 + ", " + f8 + ", " + f9 + '.');
        }
        float[] fArr = new float[5];
        float f10 = (f7 - 0.0f) * 3.0f;
        float f11 = (f9 - f7) * 3.0f;
        float f12 = (1.0f - f9) * 3.0f;
        double d6 = f10;
        double d7 = f11;
        double d8 = f12;
        double d9 = d7 * 2.0d;
        double d10 = (d6 - d9) + d8;
        if (d10 == 0.0d) {
            iP = d7 == d8 ? 0 : AbstractC2686D.P((float) ((d9 - d8) / (d9 - (d8 * 2.0d))), fArr, 0);
        } else {
            double d11 = -Math.sqrt((d7 * d7) - (d8 * d6));
            double d12 = (-d6) + d7;
            int iP2 = AbstractC2686D.P((float) ((-(d11 + d12)) / d10), fArr, 0);
            int iP3 = AbstractC2686D.P((float) ((d11 - d12) / d10), fArr, iP2) + iP2;
            if (iP3 > 1) {
                float f13 = fArr[0];
                float f14 = fArr[1];
                if (f13 > f14) {
                    fArr[0] = f14;
                    fArr[1] = f13;
                } else if (f13 == f14) {
                    iP = iP3 - 1;
                }
                iP = iP3;
            } else {
                iP = iP3;
            }
        }
        float f15 = (f11 - f10) * 2.0f;
        int iP4 = AbstractC2686D.P((-f15) / (((f12 - f11) * 2.0f) - f15), fArr, iP) + iP;
        float fMin = Math.min(0.0f, 1.0f);
        float fMax = Math.max(0.0f, 1.0f);
        for (int i6 = 0; i6 < iP4; i6++) {
            float f16 = fArr[i6];
            float f17 = (((((((((f7 - f9) * 3.0f) + 1.0f) - 0.0f) * f16) + (((f9 - (f7 * 2.0f)) + 0.0f) * 3.0f)) * f16) + f10) * f16) + 0.0f;
            fMin = Math.min(fMin, f17);
            fMax = Math.max(fMax, f17);
        }
        long jFloatToRawIntBits = (((long) Float.floatToRawIntBits(fMin)) << 32) | (((long) Float.floatToRawIntBits(fMax)) & 4294967295L);
        this.f23455e = Float.intBitsToFloat((int) (jFloatToRawIntBits >> 32));
        this.f23456f = Float.intBitsToFloat((int) (jFloatToRawIntBits & 4294967295L));
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x0092 A[PHI: r3
      0x0092: PHI (r3v28 float) = (r3v5 float), (r3v16 float), (r3v21 float), (r3v32 float), (r3v37 float) binds: [B:128:0x0236, B:117:0x0206, B:92:0x01bb, B:47:0x00e5, B:22:0x008e] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:69:0x0162 A[PHI: r12
      0x0162: PHI (r12v41 float) = (r12v25 float), (r12v36 float) binds: [B:68:0x0160, B:81:0x0191] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // q.InterfaceC2807y
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final float a(float f6) {
        float f7;
        if (f6 <= 0.0f || f6 >= 1.0f) {
            return f6;
        }
        float fMax = Math.max(f6, 1.1920929E-7f);
        float f8 = 0.0f - fMax;
        float f9 = this.f23451a;
        float f10 = f9 - fMax;
        float f11 = this.f23453c;
        float f12 = f11 - fMax;
        double d6 = f8;
        float f13 = 0.0f;
        double d7 = ((d6 - (((double) f10) * 2.0d)) + ((double) f12)) * 3.0d;
        double d8 = ((double) (f10 - f8)) * 3.0d;
        double d9 = (((double) (f10 - f12)) * 3.0d) + ((double) (-f8)) + ((double) (1.0f - fMax));
        float f14 = Float.NaN;
        if (Math.abs(d9 - 0.0d) >= 1.0E-7d) {
            double d10 = d7 / d9;
            double d11 = d8 / d9;
            double d12 = d6 / d9;
            double d13 = ((d11 * 3.0d) - (d10 * d10)) / 9.0d;
            double d14 = ((d12 * 27.0d) + ((((2.0d * d10) * d10) * d10) - ((9.0d * d10) * d11))) / 54.0d;
            double d15 = d13 * d13 * d13;
            double d16 = (d14 * d14) + d15;
            double d17 = d10 / 3.0d;
            if (d16 < 0.0d) {
                double dSqrt = Math.sqrt(-d15);
                double d18 = (-d14) / dSqrt;
                if (d18 < -1.0d) {
                    d18 = -1.0d;
                }
                if (d18 > 1.0d) {
                    d18 = 1.0d;
                }
                double dAcos = Math.acos(d18);
                double dA0 = W.b.a0((float) dSqrt) * 2.0f;
                float fCos = (float) ((Math.cos(dAcos / 3.0d) * dA0) - d17);
                float f15 = fCos < 0.0f ? 0.0f : fCos;
                if (f15 > 1.0f) {
                    f15 = 1.0f;
                }
                if (Math.abs(f15 - fCos) > 1.05E-6f) {
                    f15 = Float.NaN;
                }
                if (Float.isNaN(f15)) {
                    float fCos2 = (float) ((Math.cos((6.283185307179586d + dAcos) / 3.0d) * dA0) - d17);
                    f15 = fCos2 < 0.0f ? 0.0f : fCos2;
                    if (f15 > 1.0f) {
                        f15 = 1.0f;
                    }
                    if (Math.abs(f15 - fCos2) > 1.05E-6f) {
                        f15 = Float.NaN;
                    }
                    if (Float.isNaN(f15)) {
                        float fCos3 = (float) ((Math.cos((dAcos + 12.566370614359172d) / 3.0d) * dA0) - d17);
                        if (fCos3 >= 0.0f) {
                            f13 = fCos3;
                        }
                        f7 = f13 > 1.0f ? 1.0f : f13;
                        if (Math.abs(f7 - fCos3) <= 1.05E-6f) {
                        }
                    }
                } else {
                    f14 = f15;
                }
            } else if (d16 == 0.0d) {
                float f16 = -W.b.a0((float) d14);
                float f17 = (float) d17;
                float f18 = (f16 * 2.0f) - f17;
                float f19 = f18 < 0.0f ? 0.0f : f18;
                if (f19 > 1.0f) {
                    f19 = 1.0f;
                }
                if (Math.abs(f19 - f18) > 1.05E-6f) {
                    f19 = Float.NaN;
                }
                if (Float.isNaN(f19)) {
                    float f20 = (-f16) - f17;
                    if (f20 >= 0.0f) {
                        f13 = f20;
                    }
                    f7 = f13 > 1.0f ? 1.0f : f13;
                    if (Math.abs(f7 - f20) <= 1.05E-6f) {
                    }
                } else {
                    f14 = f19;
                }
            } else {
                double dSqrt2 = Math.sqrt(d16);
                float fA0 = (float) (((double) (W.b.a0((float) ((-d14) + dSqrt2)) - W.b.a0((float) (d14 + dSqrt2)))) - d17);
                if (fA0 >= 0.0f) {
                    f13 = fA0;
                }
                f7 = f13 > 1.0f ? 1.0f : f13;
                if (Math.abs(f7 - fA0) <= 1.05E-6f) {
                }
            }
        } else if (Math.abs(d7 - 0.0d) >= 1.0E-7d) {
            double dSqrt3 = Math.sqrt((d8 * d8) - ((4.0d * d7) * d6));
            double d19 = d7 * 2.0d;
            float f21 = (float) ((dSqrt3 - d8) / d19);
            float f22 = f21 < 0.0f ? 0.0f : f21;
            if (f22 > 1.0f) {
                f22 = 1.0f;
            }
            if (Math.abs(f22 - f21) > 1.05E-6f) {
                f22 = Float.NaN;
            }
            if (Float.isNaN(f22)) {
                float f23 = (float) (((-d8) - dSqrt3) / d19);
                if (f23 >= 0.0f) {
                    f13 = f23;
                }
                f7 = f13 > 1.0f ? 1.0f : f13;
                if (Math.abs(f7 - f23) <= 1.05E-6f) {
                }
            } else {
                f14 = f22;
            }
        } else if (Math.abs(d8 - 0.0d) >= 1.0E-7d) {
            float f24 = (float) ((-d6) / d8);
            if (f24 >= 0.0f) {
                f13 = f24;
            }
            f7 = f13 > 1.0f ? 1.0f : f13;
            if (Math.abs(f7 - f24) <= 1.05E-6f) {
                f14 = f7;
            }
        }
        boolean zIsNaN = Float.isNaN(f14);
        float f25 = this.f23454d;
        float f26 = this.f23452b;
        if (!zIsNaN) {
            float f27 = ((((((f26 - f25) + 0.33333334f) * f14) + (f25 - (2.0f * f26))) * f14) + f26) * 3.0f * f14;
            float f28 = this.f23455e;
            if (f27 < f28) {
                f27 = f28;
            }
            float f29 = this.f23456f;
            return f27 > f29 ? f29 : f27;
        }
        throw new IllegalArgumentException("The cubic curve with parameters (" + f9 + ", " + f26 + ", " + f11 + ", " + f25 + ") has no solution at " + f6);
    }

    public final boolean equals(Object obj) {
        if (!(obj instanceof C2802u)) {
            return false;
        }
        C2802u c2802u = (C2802u) obj;
        return this.f23451a == c2802u.f23451a && this.f23452b == c2802u.f23452b && this.f23453c == c2802u.f23453c && this.f23454d == c2802u.f23454d;
    }

    public final int hashCode() {
        return Float.hashCode(this.f23454d) + com.google.android.recaptcha.internal.a.b(this.f23453c, com.google.android.recaptcha.internal.a.b(this.f23452b, Float.hashCode(this.f23451a) * 31, 31), 31);
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("CubicBezierEasing(a=");
        sb.append(this.f23451a);
        sb.append(", b=");
        sb.append(this.f23452b);
        sb.append(", c=");
        sb.append(this.f23453c);
        sb.append(", d=");
        return com.google.android.recaptcha.internal.a.l(sb, this.f23454d, ')');
    }
}
