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

import android.net.Uri;
import androidx.annotation.Nullable;
import com.google.android.gms.ads.internal.util.client.zzt;
import java.util.HashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final q7.p f14095a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final q7.m f14096b;

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

    @Nullable
    private final ne1 zzd;

    @Nullable
    private final e70 zze;

    public me1(q7.p pVar, q7.m mVar, ev1 ev1Var, @Nullable ne1 ne1Var, @Nullable e70 e70Var) {
        this.f14095a = pVar;
        this.f14096b = mVar;
        this.f14097c = ev1Var;
        this.zzd = ne1Var;
        this.zze = e70Var;
    }

    public final com.google.common.util.concurrent.w a(String str) {
        zzt zztVar = zzt.f7960b;
        if (str != null) {
            if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f8862g)).booleanValue() || !str.isEmpty()) {
                try {
                    return b(1, 0L, str);
                } catch (NullPointerException | RejectedExecutionException unused) {
                    return ih1.k(zztVar);
                }
            }
        }
        return ih1.k(zztVar);
    }

    public final com.google.common.util.concurrent.w b(final int i10, final long j10, final String str) {
        final String strP;
        q7.i iVar = (q7.i) this.f14095a;
        if (i10 > iVar.f32238a) {
            ne1 ne1Var = this.zzd;
            if (ne1Var == null || !iVar.f32241d) {
                return ih1.k(zzt.f7961c);
            }
            m7.n.C.f30472k.getClass();
            ne1Var.f14572a.k(new vc(System.currentTimeMillis(), "", str, 2));
            return ih1.k(zzt.f7962d);
        }
        final int i11 = 1;
        if (((Boolean) n7.y.f31093e.f31096c.b(ao.H9)).booleanValue()) {
            Uri uri = Uri.parse(str);
            String encodedQuery = uri.getEncodedQuery();
            Uri.Builder builderClearQuery = uri.buildUpon().clearQuery();
            builderClearQuery.appendQueryParameter("pa", Integer.toString(i10));
            String strValueOf = String.valueOf(builderClearQuery.build());
            strP = defpackage.e.p(new StringBuilder(strValueOf.length() + 1 + String.valueOf(encodedQuery).length()), strValueOf, "&", encodedQuery);
        } else {
            strP = str;
        }
        qu1 qu1Var = new qu1() { // from class: com.google.android.gms.internal.ads.le1
            @Override // com.google.android.gms.internal.ads.qu1
            public final com.google.common.util.concurrent.w zza(Object obj) {
                zzt zztVar = (zzt) obj;
                zzt zztVar2 = zzt.f7961c;
                me1 me1Var = this.f13648a;
                if (zztVar != zztVar2) {
                    me1Var.getClass();
                    return ih1.k(zztVar);
                }
                q7.i iVar2 = (q7.i) me1Var.f14095a;
                long j11 = iVar2.f32239b;
                int i12 = i10;
                if (i12 != 1) {
                    j11 = (long) (iVar2.f32240c * j10);
                }
                return me1Var.b(i12 + 1, j11, str);
            }
        };
        dv1 dv1Var = this.f14097c;
        if (j10 == 0) {
            return ih1.e1(((iu1) dv1Var).g(new Callable(this) { // from class: com.google.android.gms.internal.ads.je1

                /* JADX INFO: renamed from: b, reason: collision with root package name */
                public final /* synthetic */ me1 f12836b;

                {
                    this.f12836b = this;
                }

                @Override // java.util.concurrent.Callable
                public final /* synthetic */ Object call() {
                    int i12 = i11;
                    String str2 = strP;
                    me1 me1Var = this.f12836b;
                    switch (i12) {
                    }
                    return me1Var.c(str2);
                }
            }), qu1Var, dv1Var);
        }
        final int i12 = 0;
        Callable callable = new Callable(this) { // from class: com.google.android.gms.internal.ads.je1

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ me1 f12836b;

            {
                this.f12836b = this;
            }

            @Override // java.util.concurrent.Callable
            public final /* synthetic */ Object call() {
                int i122 = i12;
                String str2 = strP;
                me1 me1Var = this.f12836b;
                switch (i122) {
                }
                return me1Var.c(str2);
            }
        };
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        kv1 kv1Var = (kv1) dv1Var;
        kv1Var.getClass();
        ov1 ov1Var = new ov1(callable);
        return ih1.e1(new iv1(ov1Var, kv1Var.f13414c.schedule(ov1Var, j10, timeUnit)), qu1Var, kv1Var);
    }

    public final zzt c(String str) {
        e70 e70Var;
        tn tnVar = ao.Z9;
        n7.y yVar = n7.y.f31093e;
        boolean zBooleanValue = ((Boolean) yVar.f31096c.b(tnVar)).booleanValue();
        q7.m mVar = this.f14096b;
        if (zBooleanValue && (e70Var = this.zze) != null) {
            m7.n nVar = m7.n.C;
            if (nVar.f30464c.B(str) || nVar.f30464c.C(str)) {
                String strZzb = e70Var.zzb();
                HashMap map = new HashMap();
                if (strZzb != null) {
                    map.put((String) yVar.f31096c.b(ao.f8772aa), strZzb);
                }
                return mVar.zzc(str, map);
            }
        }
        return mVar.zzc(str, null);
    }
}
