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

import androidx.annotation.Nullable;
import java.util.Objects;

/* JADX INFO: loaded from: classes2.dex */
public final class fk2 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f11267b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public long f11268c;

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final /* synthetic */ gk2 f11272g;

    public fk2(gk2 gk2Var, String str, @Nullable int i10, cp2 cp2Var) {
        Objects.requireNonNull(gk2Var);
        this.f11272g = gk2Var;
        this.f11266a = str;
        this.f11267b = i10;
        this.f11268c = cp2Var == null ? -1L : cp2Var.f10028d;
        if (cp2Var == null || !cp2Var.b()) {
            return;
        }
        this.f11269d = cp2Var;
    }

    public final boolean a(mk mkVar, mk mkVar2) {
        int i10 = this.f11267b;
        if (i10 < mkVar.a()) {
            gk2 gk2Var = this.f11272g;
            mkVar.b(i10, gk2Var.f11774a, 0L);
            tj tjVar = gk2Var.f11774a;
            for (int i11 = tjVar.f16919j; i11 <= tjVar.f16920k; i11++) {
                int iE = mkVar2.e(mkVar.f(i11));
                if (iE != -1) {
                    i10 = mkVar2.d(iE, gk2Var.f11775b, false).f11762a;
                    break;
                }
            }
            i10 = -1;
        } else if (i10 >= mkVar2.a()) {
            i10 = -1;
        }
        this.f11267b = i10;
        if (i10 == -1) {
            return false;
        }
        cp2 cp2Var = this.f11269d;
        return cp2Var == null || mkVar2.e(cp2Var.f10025a) != -1;
    }

    public final boolean b(nj2 nj2Var) {
        cp2 cp2Var = nj2Var.zzd;
        if (cp2Var == null) {
            return this.f11267b != nj2Var.f14653c;
        }
        long j10 = this.f11268c;
        if (j10 == -1) {
            return false;
        }
        long j11 = cp2Var.f10028d;
        if (j11 > j10) {
            return true;
        }
        cp2 cp2Var2 = this.f11269d;
        if (cp2Var2 == null) {
            return false;
        }
        mk mkVar = nj2Var.f14652b;
        int iE = mkVar.e(cp2Var.f10025a);
        int iE2 = mkVar.e(cp2Var2.f10025a);
        if (j11 < cp2Var2.f10028d || iE < iE2) {
            return false;
        }
        if (iE > iE2) {
            return true;
        }
        boolean zB = cp2Var.b();
        int i10 = cp2Var2.f10026b;
        if (!zB) {
            int i11 = cp2Var.f10029e;
            return i11 == -1 || i11 > i10;
        }
        int i12 = cp2Var.f10026b;
        if (i12 > i10) {
            return true;
        }
        if (i12 == i10) {
            return cp2Var.f10027c > cp2Var2.f10027c;
        }
        return false;
    }

    public final boolean zzb(int i10, @Nullable cp2 cp2Var) {
        if (cp2Var != null) {
            long j10 = cp2Var.f10028d;
            if (j10 != -1) {
                cp2 cp2Var2 = this.f11269d;
                return cp2Var2 == null ? !cp2Var.b() && j10 == this.f11268c : j10 == cp2Var2.f10028d && cp2Var.f10026b == cp2Var2.f10026b && cp2Var.f10027c == cp2Var2.f10027c;
            }
        }
        return i10 == this.f11267b;
    }

    public final void zzc(int i10, @Nullable cp2 cp2Var) {
        if (this.f11268c == -1 && i10 == this.f11267b && cp2Var != null) {
            long jH = this.f11272g.h();
            long j10 = cp2Var.f10028d;
            if (j10 >= jH) {
                this.f11268c = j10;
            }
        }
    }
}
