package androidx.core.content.res;

/* JADX INFO: compiled from: CamColor.java */
/* JADX INFO: loaded from: classes.dex */
class a {

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

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

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

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

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

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

    a(float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11) {
        this.f1630a = f3;
        this.f1631b = f4;
        this.f1632c = f5;
        this.f1633d = f9;
        this.f1634e = f10;
        this.f1635f = f11;
    }

    private static a b(float f3, float f4, float f5) {
        float f6 = 1000.0f;
        float f7 = 0.0f;
        a aVar = null;
        float f8 = 100.0f;
        float f9 = 1000.0f;
        while (Math.abs(f7 - f8) > 0.01f) {
            float f10 = ((f8 - f7) / 2.0f) + f7;
            int iP = e(f10, f4, f3).p();
            float fB = b.b(iP);
            float fAbs = Math.abs(f5 - fB);
            if (fAbs < 0.2f) {
                a aVarC = c(iP);
                float fA = aVarC.a(e(aVarC.k(), aVarC.i(), f3));
                if (fA <= 1.0f) {
                    aVar = aVarC;
                    f6 = fAbs;
                    f9 = fA;
                }
            }
            if (f6 == 0.0f && f9 == 0.0f) {
                break;
            }
            if (fB < f5) {
                f7 = f10;
            } else {
                f8 = f10;
            }
        }
        return aVar;
    }

    static a c(int i3) {
        return d(i3, l.f1672k);
    }

    static a d(int i3, l lVar) {
        float[] fArrF = b.f(i3);
        float[][] fArr = b.f1636a;
        float f3 = (fArrF[0] * fArr[0][0]) + (fArrF[1] * fArr[0][1]) + (fArrF[2] * fArr[0][2]);
        float f4 = (fArrF[0] * fArr[1][0]) + (fArrF[1] * fArr[1][1]) + (fArrF[2] * fArr[1][2]);
        float f5 = (fArrF[0] * fArr[2][0]) + (fArrF[1] * fArr[2][1]) + (fArrF[2] * fArr[2][2]);
        float f6 = lVar.i()[0] * f3;
        float f7 = lVar.i()[1] * f4;
        float f8 = lVar.i()[2] * f5;
        float fPow = (float) Math.pow(((double) (lVar.c() * Math.abs(f6))) / 100.0d, 0.42d);
        float fPow2 = (float) Math.pow(((double) (lVar.c() * Math.abs(f7))) / 100.0d, 0.42d);
        float fPow3 = (float) Math.pow(((double) (lVar.c() * Math.abs(f8))) / 100.0d, 0.42d);
        float fSignum = ((Math.signum(f6) * 400.0f) * fPow) / (fPow + 27.13f);
        float fSignum2 = ((Math.signum(f7) * 400.0f) * fPow2) / (fPow2 + 27.13f);
        float fSignum3 = ((Math.signum(f8) * 400.0f) * fPow3) / (fPow3 + 27.13f);
        double d3 = fSignum3;
        float f9 = ((float) (((((double) fSignum) * 11.0d) + (((double) fSignum2) * (-12.0d))) + d3)) / 11.0f;
        float f10 = ((float) (((double) (fSignum + fSignum2)) - (d3 * 2.0d))) / 9.0f;
        float f11 = fSignum2 * 20.0f;
        float f12 = (((fSignum * 20.0f) + f11) + (21.0f * fSignum3)) / 20.0f;
        float f13 = (((fSignum * 40.0f) + f11) + fSignum3) / 20.0f;
        float fAtan2 = (((float) Math.atan2(f10, f9)) * 180.0f) / 3.1415927f;
        if (fAtan2 < 0.0f) {
            fAtan2 += 360.0f;
        } else if (fAtan2 >= 360.0f) {
            fAtan2 -= 360.0f;
        }
        float f14 = fAtan2;
        float f15 = (3.1415927f * f14) / 180.0f;
        float fPow4 = ((float) Math.pow((f13 * lVar.f()) / lVar.a(), lVar.b() * lVar.j())) * 100.0f;
        float fD = lVar.d() * (4.0f / lVar.b()) * ((float) Math.sqrt(fPow4 / 100.0f)) * (lVar.a() + 4.0f);
        float fPow5 = ((float) Math.pow(1.64d - Math.pow(0.29d, lVar.e()), 0.73d)) * ((float) Math.pow((((((((float) (Math.cos(((((double) (((double) f14) < 20.14d ? 360.0f + f14 : f14)) * 3.141592653589793d) / 180.0d) + 2.0d) + 3.8d)) * 0.25f) * 3846.1538f) * lVar.g()) * lVar.h()) * ((float) Math.sqrt((f9 * f9) + (f10 * f10)))) / (f12 + 0.305f), 0.9d)) * ((float) Math.sqrt(((double) fPow4) / 100.0d));
        float fD2 = fPow5 * lVar.d();
        float fSqrt = ((float) Math.sqrt((r2 * lVar.b()) / (lVar.a() + 4.0f))) * 50.0f;
        float f16 = (1.7f * fPow4) / ((0.007f * fPow4) + 1.0f);
        float fLog = ((float) Math.log((0.0228f * fD2) + 1.0f)) * 43.85965f;
        double d4 = f15;
        return new a(f14, fPow5, fPow4, fD, fD2, fSqrt, f16, fLog * ((float) Math.cos(d4)), fLog * ((float) Math.sin(d4)));
    }

    private static a e(float f3, float f4, float f5) {
        return f(f3, f4, f5, l.f1672k);
    }

    private static a f(float f3, float f4, float f5, l lVar) {
        float fB = (4.0f / lVar.b()) * ((float) Math.sqrt(((double) f3) / 100.0d)) * (lVar.a() + 4.0f) * lVar.d();
        float fD = f4 * lVar.d();
        float fSqrt = ((float) Math.sqrt(((f4 / ((float) Math.sqrt(r4))) * lVar.b()) / (lVar.a() + 4.0f))) * 50.0f;
        float f6 = (1.7f * f3) / ((0.007f * f3) + 1.0f);
        float fLog = ((float) Math.log((((double) fD) * 0.0228d) + 1.0d)) * 43.85965f;
        double d3 = (3.1415927f * f5) / 180.0f;
        return new a(f5, f4, f3, fB, fD, fSqrt, f6, fLog * ((float) Math.cos(d3)), fLog * ((float) Math.sin(d3)));
    }

    static int m(float f3, float f4, float f5) {
        return n(f3, f4, f5, l.f1672k);
    }

    static int n(float f3, float f4, float f5, l lVar) {
        if (f4 < 1.0d || Math.round(f5) <= 0.0d || Math.round(f5) >= 100.0d) {
            return b.a(f5);
        }
        float fMin = f3 < 0.0f ? 0.0f : Math.min(360.0f, f3);
        a aVar = null;
        boolean z2 = true;
        float f6 = 0.0f;
        float f7 = f4;
        while (Math.abs(f6 - f4) >= 0.4f) {
            a aVarB = b(fMin, f7, f5);
            if (z2) {
                if (aVarB != null) {
                    return aVarB.o(lVar);
                }
                z2 = false;
            } else if (aVarB == null) {
                f4 = f7;
            } else {
                f6 = f7;
                aVar = aVarB;
            }
            f7 = ((f4 - f6) / 2.0f) + f6;
        }
        return aVar == null ? b.a(f5) : aVar.o(lVar);
    }

    float a(a aVar) {
        float fL = l() - aVar.l();
        float fG = g() - aVar.g();
        float fH = h() - aVar.h();
        return (float) (Math.pow(Math.sqrt((fL * fL) + (fG * fG) + (fH * fH)), 0.63d) * 1.41d);
    }

    float g() {
        return this.f1634e;
    }

    float h() {
        return this.f1635f;
    }

    float i() {
        return this.f1631b;
    }

    float j() {
        return this.f1630a;
    }

    float k() {
        return this.f1632c;
    }

    float l() {
        return this.f1633d;
    }

    int o(l lVar) {
        float fPow = (float) Math.pow(((double) ((((double) i()) == 0.0d || ((double) k()) == 0.0d) ? 0.0f : i() / ((float) Math.sqrt(((double) k()) / 100.0d)))) / Math.pow(1.64d - Math.pow(0.29d, lVar.e()), 0.73d), 1.1111111111111112d);
        double dJ = (j() * 3.1415927f) / 180.0f;
        float fCos = ((float) (Math.cos(2.0d + dJ) + 3.8d)) * 0.25f;
        float fA = lVar.a() * ((float) Math.pow(((double) k()) / 100.0d, (1.0d / ((double) lVar.b())) / ((double) lVar.j())));
        float fG = fCos * 3846.1538f * lVar.g() * lVar.h();
        float f3 = fA / lVar.f();
        float fSin = (float) Math.sin(dJ);
        float fCos2 = (float) Math.cos(dJ);
        float f4 = (((0.305f + f3) * 23.0f) * fPow) / (((fG * 23.0f) + ((11.0f * fPow) * fCos2)) + ((fPow * 108.0f) * fSin));
        float f5 = fCos2 * f4;
        float f6 = f4 * fSin;
        float f7 = f3 * 460.0f;
        float f8 = (((451.0f * f5) + f7) + (288.0f * f6)) / 1403.0f;
        float f9 = ((f7 - (891.0f * f5)) - (261.0f * f6)) / 1403.0f;
        float fSignum = Math.signum(f8) * (100.0f / lVar.c()) * ((float) Math.pow((float) Math.max(0.0d, (((double) Math.abs(f8)) * 27.13d) / (400.0d - ((double) Math.abs(f8)))), 2.380952380952381d));
        float fSignum2 = Math.signum(f9) * (100.0f / lVar.c()) * ((float) Math.pow((float) Math.max(0.0d, (((double) Math.abs(f9)) * 27.13d) / (400.0d - ((double) Math.abs(f9)))), 2.380952380952381d));
        float fSignum3 = Math.signum(((f7 - (f5 * 220.0f)) - (f6 * 6300.0f)) / 1403.0f) * (100.0f / lVar.c()) * ((float) Math.pow((float) Math.max(0.0d, (((double) Math.abs(r6)) * 27.13d) / (400.0d - ((double) Math.abs(r6)))), 2.380952380952381d));
        float f10 = fSignum / lVar.i()[0];
        float f11 = fSignum2 / lVar.i()[1];
        float f12 = fSignum3 / lVar.i()[2];
        float[][] fArr = b.f1637b;
        return androidx.core.graphics.a.b((fArr[0][0] * f10) + (fArr[0][1] * f11) + (fArr[0][2] * f12), (fArr[1][0] * f10) + (fArr[1][1] * f11) + (fArr[1][2] * f12), (f10 * fArr[2][0]) + (f11 * fArr[2][1]) + (f12 * fArr[2][2]));
    }

    int p() {
        return o(l.f1672k);
    }
}
