package q;

import n.C2566A;
import n.C2598z;
import o.AbstractC2628a;

/* JADX INFO: loaded from: classes.dex */
public final class P0 implements K0 {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int[] f23216e = J0.f23188a;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public float[] f23217f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public AbstractC2798s f23218g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public AbstractC2798s f23219h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public AbstractC2798s f23220i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public AbstractC2798s f23221j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public float[] f23222k;
    public float[] l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public l2.c f23223m;

    public P0(C2598z c2598z, C2566A c2566a, int i6, C2808z c2808z) {
        this.f23212a = c2598z;
        this.f23213b = c2566a;
        this.f23214c = i6;
        this.f23215d = c2808z;
        float[] fArr = J0.f23189b;
        this.f23217f = fArr;
        this.f23222k = fArr;
        this.l = fArr;
        this.f23223m = J0.f23190c;
    }

    @Override // q.I0
    public final AbstractC2798s c(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        AbstractC2798s abstractC2798s4;
        AbstractC2798s abstractC2798s5;
        float f6;
        int i6;
        boolean z6;
        AbstractC2798s abstractC2798s6 = abstractC2798s;
        AbstractC2798s abstractC2798s7 = abstractC2798s2;
        boolean z7 = true;
        int[] iArr = J0.f23188a;
        int i7 = 0;
        long j6 = (j4 / 1000000) - ((long) 0);
        int i8 = this.f23214c;
        long j7 = i8;
        if (j6 < 0) {
            j6 = 0;
        }
        if (j6 <= j7) {
            j7 = j6;
        }
        int i9 = (int) j7;
        C2566A c2566a = this.f23213b;
        O0 o02 = (O0) c2566a.b(i9);
        if (o02 != null) {
            return o02.f23208a;
        }
        if (i9 >= i8) {
            return abstractC2798s7;
        }
        if (i9 <= 0) {
            return abstractC2798s6;
        }
        j(abstractC2798s6, abstractC2798s7, abstractC2798s3);
        AbstractC2798s abstractC2798s8 = this.f23218g;
        kotlin.jvm.internal.o.e(abstractC2798s8);
        if (this.f23223m != J0.f23190c) {
            float fI = i(h(i9), i9, false);
            float[] fArr = this.f23222k;
            C2800t[][] c2800tArr = (C2800t[][]) this.f23223m.f20267b;
            int length = c2800tArr.length - 1;
            float f7 = c2800tArr[0][0].f23432a;
            float f8 = c2800tArr[length][0].f23433b;
            int length2 = fArr.length;
            if (fI < f7 || fI > f8) {
                if (fI > f8) {
                    f7 = f8;
                } else {
                    length = 0;
                }
                float f9 = fI - f7;
                int i10 = 0;
                int i11 = 0;
                while (i10 < length2 - 1) {
                    C2800t c2800t = c2800tArr[length][i11];
                    boolean z8 = c2800t.f23446p;
                    float f10 = c2800t.f23448r;
                    float f11 = c2800t.f23447q;
                    if (z8) {
                        float f12 = c2800t.f23432a;
                        float f13 = c2800t.f23442k;
                        f6 = f9;
                        float f14 = c2800t.f23436e;
                        i6 = i10;
                        float f15 = c2800t.f23434c;
                        fArr[i6] = (f6 * f11) + com.google.android.recaptcha.internal.a.a(f14, f15, (f7 - f12) * f13, f15);
                        float f16 = (f7 - f12) * f13;
                        float f17 = c2800t.f23437f;
                        float f18 = c2800t.f23435d;
                        fArr[i6 + 1] = (f6 * f10) + com.google.android.recaptcha.internal.a.a(f17, f18, f16, f18);
                    } else {
                        f6 = f9;
                        i6 = i10;
                        c2800t.c(f7);
                        fArr[i6] = (c2800t.a() * f6) + (c2800t.f23444n * c2800t.f23439h) + f11;
                        fArr[i6 + 1] = (c2800t.b() * f6) + (c2800t.f23445o * c2800t.f23440i) + f10;
                    }
                    i10 = i6 + 2;
                    i11++;
                    f9 = f6;
                }
            } else {
                int length3 = c2800tArr.length;
                int i12 = 0;
                boolean z9 = false;
                while (i12 < length3) {
                    int i13 = i7;
                    int i14 = i13;
                    while (i13 < length2 - 1) {
                        C2800t c2800t2 = c2800tArr[i12][i14];
                        if (fI <= c2800t2.f23433b) {
                            if (c2800t2.f23446p) {
                                float f19 = c2800t2.f23432a;
                                float f20 = c2800t2.f23442k;
                                float f21 = c2800t2.f23436e;
                                z6 = z7;
                                float f22 = c2800t2.f23434c;
                                fArr[i13] = com.google.android.recaptcha.internal.a.a(f21, f22, (fI - f19) * f20, f22);
                                float f23 = (fI - f19) * f20;
                                float f24 = c2800t2.f23437f;
                                float f25 = c2800t2.f23435d;
                                fArr[i13 + 1] = com.google.android.recaptcha.internal.a.a(f24, f25, f23, f25);
                            } else {
                                z6 = z7;
                                c2800t2.c(fI);
                                fArr[i13] = (c2800t2.f23444n * c2800t2.f23439h) + c2800t2.f23447q;
                                fArr[i13 + 1] = (c2800t2.f23445o * c2800t2.f23440i) + c2800t2.f23448r;
                            }
                            z9 = z6;
                        } else {
                            z6 = z7;
                        }
                        i13 += 2;
                        i14++;
                        z7 = z6;
                    }
                    boolean z10 = z7;
                    if (z9) {
                        break;
                    }
                    i12++;
                    z7 = z10;
                    i7 = 0;
                }
            }
            int length4 = fArr.length;
            for (int i15 = 0; i15 < length4; i15++) {
                abstractC2798s8.e(fArr[i15], i15);
            }
        } else {
            int iH = h(i9);
            float fI2 = i(iH, i9, true);
            C2598z c2598z = this.f23212a;
            O0 o03 = (O0) c2566a.b(c2598z.a(iH));
            if (o03 != null && (abstractC2798s5 = o03.f23208a) != null) {
                abstractC2798s6 = abstractC2798s5;
            }
            O0 o04 = (O0) c2566a.b(c2598z.a(iH + 1));
            if (o04 != null && (abstractC2798s4 = o04.f23208a) != null) {
                abstractC2798s7 = abstractC2798s4;
            }
            int iB = abstractC2798s8.b();
            for (int i16 = 0; i16 < iB; i16++) {
                abstractC2798s8.e((abstractC2798s7.a(i16) * fI2) + ((1 - fI2) * abstractC2798s6.a(i16)), i16);
            }
        }
        return abstractC2798s8;
    }

    @Override // q.I0
    public final AbstractC2798s d(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        int[] iArr = J0.f23188a;
        int i6 = 0;
        long j6 = (j4 / 1000000) - ((long) 0);
        long j7 = this.f23214c;
        if (j6 < 0) {
            j6 = 0;
        }
        long j8 = j6 > j7 ? j7 : j6;
        if (j8 < 0) {
            return abstractC2798s3;
        }
        j(abstractC2798s, abstractC2798s2, abstractC2798s3);
        AbstractC2798s abstractC2798s4 = this.f23219h;
        kotlin.jvm.internal.o.e(abstractC2798s4);
        if (this.f23223m != J0.f23190c) {
            int i7 = (int) j8;
            float fI = i(h(i7), i7, false);
            float[] fArr = this.l;
            C2800t[][] c2800tArr = (C2800t[][]) this.f23223m.f20267b;
            float f6 = c2800tArr[0][0].f23432a;
            float f7 = c2800tArr[c2800tArr.length - 1][0].f23433b;
            if (fI < f6) {
                fI = f6;
            }
            if (fI <= f7) {
                f7 = fI;
            }
            int length = fArr.length;
            boolean z6 = false;
            for (C2800t[] c2800tArr2 : c2800tArr) {
                int i8 = 0;
                int i9 = 0;
                while (i8 < length - 1) {
                    C2800t c2800t = c2800tArr2[i9];
                    if (f7 <= c2800t.f23433b) {
                        if (c2800t.f23446p) {
                            fArr[i8] = c2800t.f23447q;
                            fArr[i8 + 1] = c2800t.f23448r;
                        } else {
                            c2800t.c(f7);
                            fArr[i8] = c2800t.a();
                            fArr[i8 + 1] = c2800t.b();
                        }
                        z6 = true;
                    }
                    i8 += 2;
                    i9++;
                }
                if (z6) {
                    break;
                }
            }
            int length2 = fArr.length;
            while (i6 < length2) {
                abstractC2798s4.e(fArr[i6], i6);
                i6++;
            }
        } else {
            AbstractC2798s abstractC2798sC = c((j8 - 1) * 1000000, abstractC2798s, abstractC2798s2, abstractC2798s3);
            AbstractC2798s abstractC2798sC2 = c(j8 * 1000000, abstractC2798s, abstractC2798s2, abstractC2798s3);
            int iB = abstractC2798sC.b();
            while (i6 < iB) {
                abstractC2798s4.e((abstractC2798sC.a(i6) - abstractC2798sC2.a(i6)) * 1000.0f, i6);
                i6++;
            }
        }
        return abstractC2798s4;
    }

    @Override // q.K0
    public final int e() {
        return 0;
    }

    @Override // q.K0
    public final int f() {
        return this.f23214c;
    }

    public final int h(int i6) {
        int i7;
        C2598z c2598z = this.f23212a;
        int i8 = c2598z.f21454b;
        if (i8 <= 0) {
            AbstractC2628a.d("");
            throw null;
        }
        int i9 = i8 - 1;
        int i10 = 0;
        while (true) {
            if (i10 <= i9) {
                i7 = (i10 + i9) >>> 1;
                int i11 = c2598z.f21453a[i7];
                if (i11 >= i6) {
                    if (i11 <= i6) {
                        break;
                    }
                    i9 = i7 - 1;
                } else {
                    i10 = i7 + 1;
                }
            } else {
                i7 = -(i10 + 1);
                break;
            }
        }
        return i7 < -1 ? -(i7 + 2) : i7;
    }

    public final float i(int i6, int i7, boolean z6) {
        InterfaceC2807y interfaceC2807y;
        float f6;
        C2598z c2598z = this.f23212a;
        if (i6 >= c2598z.f21454b - 1) {
            f6 = i7;
        } else {
            int iA = c2598z.a(i6);
            int iA2 = c2598z.a(i6 + 1);
            if (i7 == iA) {
                f6 = iA;
            } else {
                int i8 = iA2 - iA;
                O0 o02 = (O0) this.f23213b.b(iA);
                if (o02 == null || (interfaceC2807y = o02.f23209b) == null) {
                    interfaceC2807y = this.f23215d;
                }
                float f7 = i8;
                float fA = interfaceC2807y.a((i7 - iA) / f7);
                if (z6) {
                    return fA;
                }
                f6 = (f7 * fA) + iA;
            }
        }
        return f6 / 1000;
    }

    public final void j(AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        float[] fArr;
        boolean z6 = this.f23223m != J0.f23190c;
        AbstractC2798s abstractC2798s4 = this.f23218g;
        C2566A c2566a = this.f23213b;
        C2598z c2598z = this.f23212a;
        if (abstractC2798s4 == null) {
            this.f23218g = abstractC2798s.c();
            this.f23219h = abstractC2798s3.c();
            int i6 = c2598z.f21454b;
            float[] fArr2 = new float[i6];
            for (int i7 = 0; i7 < i6; i7++) {
                fArr2[i7] = c2598z.a(i7) / 1000;
            }
            this.f23217f = fArr2;
            int i8 = c2598z.f21454b;
            int[] iArr = new int[i8];
            for (int i9 = 0; i9 < i8; i9++) {
                iArr[i9] = 0;
            }
            this.f23216e = iArr;
        }
        if (z6) {
            if (this.f23223m != J0.f23190c && kotlin.jvm.internal.o.c(this.f23220i, abstractC2798s) && kotlin.jvm.internal.o.c(this.f23221j, abstractC2798s2)) {
                return;
            }
            this.f23220i = abstractC2798s;
            this.f23221j = abstractC2798s2;
            int iB = abstractC2798s.b() + (abstractC2798s.b() % 2);
            this.f23222k = new float[iB];
            this.l = new float[iB];
            int i10 = c2598z.f21454b;
            float[][] fArr3 = new float[i10][];
            for (int i11 = 0; i11 < i10; i11++) {
                int iA = c2598z.a(i11);
                O0 o02 = (O0) c2566a.b(iA);
                if (iA == 0 && o02 == null) {
                    fArr = new float[iB];
                    for (int i12 = 0; i12 < iB; i12++) {
                        fArr[i12] = abstractC2798s.a(i12);
                    }
                } else if (iA == this.f23214c && o02 == null) {
                    fArr = new float[iB];
                    for (int i13 = 0; i13 < iB; i13++) {
                        fArr[i13] = abstractC2798s2.a(i13);
                    }
                } else {
                    kotlin.jvm.internal.o.e(o02);
                    fArr = new float[iB];
                    for (int i14 = 0; i14 < iB; i14++) {
                        fArr[i14] = o02.f23208a.a(i14);
                    }
                }
                fArr3[i11] = fArr;
            }
            this.f23223m = new l2.c(this.f23216e, this.f23217f, fArr3);
        }
    }
}
