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

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;

/* JADX INFO: loaded from: classes2.dex */
public final class ua1 extends f00 {

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

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

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

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

    @Nullable
    private sp0 zzd;

    public ua1(qa1 qa1Var, la1 la1Var, fb1 fb1Var) {
        super("com.google.android.gms.ads.internal.reward.client.IRewardedVideoAd");
        this.f17194d = false;
        this.f17191a = qa1Var;
        this.f17192b = la1Var;
        this.f17193c = fb1Var;
    }

    public final synchronized void I0(k8.a aVar) {
        com.google.android.gms.common.internal.w.d("resume must be called on the main UI thread.");
        if (this.zzd != null) {
            Context context = aVar == null ? null : (Context) k8.b.O(aVar);
            kf0 kf0Var = this.zzd.f14058c;
            kf0Var.getClass();
            kf0Var.H0(new qn(context, 1));
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x0042, code lost:
    
        if (((java.lang.Boolean) n7.y.f31093e.f31096c.b(com.google.android.gms.internal.ads.ao.f9000o6)).booleanValue() == false) goto L18;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final synchronized void R2(j00 j00Var) {
        com.google.android.gms.common.internal.w.d("loadAd must be called on the main UI thread.");
        String str = j00Var.f12670b;
        String str2 = (String) n7.y.f31093e.f31096c.b(ao.f8966m6);
        if (str2 != null && str != null) {
            try {
                if (!Pattern.matches(str2, str)) {
                }
            } catch (RuntimeException e10) {
                m7.n.C.f30469h.d("NonagonUtil.isPatternMatched", e10);
            }
            return;
        }
        if (X2()) {
        }
        ma1 ma1Var = new ma1();
        this.zzd = null;
        qa1 qa1Var = this.f17191a;
        qa1Var.f15671h.f12114k.f30185b = 1;
        qa1Var.zza(j00Var.f12669a, j00Var.f12670b, ma1Var, new dh0(this));
    }

    public final synchronized void S2(k8.a aVar) {
        com.google.android.gms.common.internal.w.d("destroy must be called on the main UI thread.");
        Context context = null;
        this.f17192b.f13570b.set(null);
        if (this.zzd != null) {
            if (aVar != null) {
                context = (Context) k8.b.O(aVar);
            }
            this.zzd.f14058c.zzc(context);
        }
    }

    public final Bundle T2() {
        Bundle bundle;
        com.google.android.gms.common.internal.w.d("getAdMetadata can only be called from the UI thread.");
        sp0 sp0Var = this.zzd;
        if (sp0Var == null) {
            return new Bundle();
        }
        bg0 bg0Var = sp0Var.f16529p;
        synchronized (bg0Var) {
            bundle = new Bundle(bg0Var.f9523b);
        }
        return bundle;
    }

    public final boolean U2() {
        x50 x50Var;
        sp0 sp0Var = this.zzd;
        return (sp0Var == null || (x50Var = (x50) sp0Var.f16525l.get()) == null || x50Var.A()) ? false : true;
    }

    public final /* synthetic */ sp0 V2() {
        return this.zzd;
    }

    public final /* synthetic */ void W2(sp0 sp0Var) {
        this.zzd = sp0Var;
    }

    public final synchronized boolean X2() {
        sp0 sp0Var = this.zzd;
        if (sp0Var != null) {
            if (!sp0Var.f16530q.f9498b.get()) {
                return true;
            }
        }
        return false;
    }

    public final synchronized void zzi(k8.a aVar) {
        com.google.android.gms.common.internal.w.d("pause must be called on the main UI thread.");
        if (this.zzd != null) {
            Context context = aVar == null ? null : (Context) k8.b.O(aVar);
            kf0 kf0Var = this.zzd.f14058c;
            kf0Var.getClass();
            kf0Var.H0(new qn(context, 3));
        }
    }

    @Nullable
    public final synchronized String zzl() throws RemoteException {
        oe0 oe0Var;
        sp0 sp0Var = this.zzd;
        if (sp0Var == null || (oe0Var = sp0Var.f14060e) == null) {
            return null;
        }
        return oe0Var.f15040a;
    }

    @Override // com.google.android.gms.internal.ads.f00, com.google.android.gms.internal.ads.g00
    public final synchronized void zzp(@Nullable k8.a aVar) throws RemoteException {
        try {
            com.google.android.gms.common.internal.w.d("showAd must be called on the main UI thread.");
            if (this.zzd != null) {
                Activity activity = null;
                if (aVar != null) {
                    Object objO = k8.b.O(aVar);
                    if (objO instanceof Activity) {
                        activity = (Activity) objO;
                    }
                }
                this.zzd.zza(this.f17194d, activity);
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    @Nullable
    public final synchronized n7.m2 zzt() throws RemoteException {
        sp0 sp0Var;
        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f9151x7)).booleanValue() && (sp0Var = this.zzd) != null) {
            return sp0Var.f14060e;
        }
        return null;
    }
}
