package com.google.android.gms.internal.ads;

import android.util.Pair;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class xo2 extends sq2 {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final boolean f18495g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final tj f18496h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final gj f18497i;

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f18499k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f18500l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f18501m;

    @Nullable
    private uo2 zzf;

    public xo2(ep2 ep2Var, boolean z10) {
        boolean z11;
        super(ep2Var);
        if (z10) {
            ep2Var.zzI();
            z11 = true;
        } else {
            z11 = false;
        }
        this.f18495g = z11;
        this.f18496h = new tj();
        this.f18497i = new gj();
        ep2Var.zzH();
        this.f18498j = vo2.o(ep2Var.d());
    }

    @Override // com.google.android.gms.internal.ads.ep2
    public final void b(ap2 ap2Var) {
        uo2 uo2Var = (uo2) ap2Var;
        ap2 ap2Var2 = uo2Var.f17358e;
        if (ap2Var2 != null) {
            ep2 ep2Var = uo2Var.f17357d;
            ep2Var.getClass();
            ep2Var.b(ap2Var2);
        }
        if (ap2Var == this.zzf) {
            this.zzf = null;
        }
    }

    @Override // com.google.android.gms.internal.ads.ep2
    public final void c(t6 t6Var) {
        if (this.f18501m) {
            this.f18498j = this.f18498j.p(new bj2(this.f18498j.f16187b, t6Var));
        } else {
            this.f18498j = vo2.o(t6Var);
        }
        this.f16553f.c(t6Var);
    }

    @Override // com.google.android.gms.internal.ads.no2, com.google.android.gms.internal.ads.fo2
    public final void g() {
        this.f18500l = false;
        this.f18499k = false;
        super.g();
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x005a  */
    @Override // com.google.android.gms.internal.ads.sq2
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void r(mk mkVar) {
        cp2 cp2VarA = null;
        if (this.f18500l) {
            this.f18498j = this.f18498j.p(mkVar);
            uo2 uo2Var = this.zzf;
            if (uo2Var != null) {
                t(uo2Var.f17359f);
            }
        } else if (mkVar.g()) {
            this.f18498j = this.f18501m ? this.f18498j.p(mkVar) : vo2.zzq(mkVar, tj.f16908l, vo2.f17743c);
        } else {
            tj tjVar = this.f18496h;
            mkVar.b(0, tjVar, 0L);
            Object obj = tjVar.f16910a;
            uo2 uo2Var2 = this.zzf;
            if (uo2Var2 != null) {
                this.f18498j.n(uo2Var2.f17354a.f10025a, this.f18497i);
                this.f18498j.b(0, tjVar, 0L);
                long j10 = uo2Var2.f17355b;
                if (j10 == 0) {
                    j10 = 0;
                }
                Pair pairM = mkVar.m(tjVar, this.f18497i, 0, j10);
                Object obj2 = pairM.first;
                long jLongValue = ((Long) pairM.second).longValue();
                this.f18498j = this.f18501m ? this.f18498j.p(mkVar) : vo2.zzq(mkVar, obj, obj2);
                uo2 uo2Var3 = this.zzf;
                if (uo2Var3 != null && t(jLongValue)) {
                    cp2 cp2Var = uo2Var3.f17354a;
                    Object objQ = cp2Var.f10025a;
                    if (this.f18498j.q() != null && objQ.equals(vo2.f17743c)) {
                        objQ = this.f18498j.q();
                    }
                    cp2VarA = cp2Var.a(objQ);
                }
            }
        }
        this.f18501m = true;
        this.f18500l = true;
        h(this.f18498j);
        if (cp2VarA != null) {
            uo2 uo2Var4 = this.zzf;
            uo2Var4.getClass();
            uo2Var4.k(cp2VarA);
        }
    }

    @Override // com.google.android.gms.internal.ads.ep2
    /* JADX INFO: renamed from: s, reason: merged with bridge method [inline-methods] */
    public final uo2 a(cp2 cp2Var, n nVar, long j10) {
        uo2 uo2Var = new uo2(cp2Var, nVar, j10);
        ih1.b1(uo2Var.f17357d == null);
        ep2 ep2Var = this.f16553f;
        uo2Var.f17357d = ep2Var;
        if (this.f18500l) {
            Object objQ = this.f18498j.q();
            Object objQ2 = cp2Var.f10025a;
            if (objQ != null && objQ2.equals(vo2.f17743c)) {
                objQ2 = this.f18498j.q();
            }
            uo2Var.k(cp2Var.a(objQ2));
        } else {
            this.zzf = uo2Var;
            if (!this.f18499k) {
                this.f18499k = true;
                p(null, ep2Var);
            }
        }
        return uo2Var;
    }

    public final boolean t(long j10) {
        uo2 uo2Var = this.zzf;
        int iE = this.f18498j.e(uo2Var.f17354a.f10025a);
        if (iE == -1) {
            return false;
        }
        vo2 vo2Var = this.f18498j;
        gj gjVar = this.f18497i;
        vo2Var.d(iE, gjVar, false);
        long j11 = gjVar.f11763b;
        if (j11 != -9223372036854775807L && j10 >= j11) {
            j10 = Math.max(0L, j11 - 1);
        }
        uo2Var.f17359f = j10;
        return true;
    }

    @Override // com.google.android.gms.internal.ads.sq2
    @Nullable
    public final cp2 zzF(cp2 cp2Var) {
        Object objQ = this.f18498j.q();
        Object obj = cp2Var.f10025a;
        if (objQ != null && this.f18498j.q().equals(obj)) {
            obj = vo2.f17743c;
        }
        return cp2Var.a(obj);
    }
}
