package d3;

import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.text.TextUtils;
import com.google.android.gms.measurement.internal.AppMeasurementDynamiteService;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes.dex */
public final class U0 implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f11729q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ Object f11730r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ Object f11731s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final /* synthetic */ boolean f11732t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final /* synthetic */ Object f11733u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final /* synthetic */ Object f11734v;

    public U0(X0 x02, boolean z8, Uri uri, String str, String str2) {
        this.f11729q = 2;
        this.f11732t = z8;
        this.f11733u = uri;
        this.f11730r = str;
        this.f11731s = str2;
        this.f11734v = x02;
    }

    /* JADX WARN: Removed duplicated region for block: B:54:0x00fe  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x0147  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0150  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x0152 A[Catch: RuntimeException -> 0x0136, TRY_LEAVE, TryCatch #1 {RuntimeException -> 0x0136, blocks: (B:55:0x0100, B:57:0x010b, B:60:0x0118, B:62:0x011e, B:66:0x013d, B:69:0x014a, B:72:0x0152, B:74:0x0157, B:78:0x016f, B:80:0x017e, B:79:0x0176, B:81:0x018f, B:83:0x0198, B:85:0x019e, B:87:0x01a4, B:89:0x01ac, B:91:0x01b4, B:93:0x01bc, B:95:0x01c2, B:96:0x01d0), top: B:109:0x0100 }] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // java.lang.Runnable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void run() throws Throwable {
        X0 x02;
        Bundle bundleQ0;
        boolean z8;
        String str;
        CharSequence charSequence;
        switch (this.f11729q) {
            case n4.u0.f15495q /* 0 */:
                C0824t1 c0824t1R = ((AppMeasurementDynamiteService) this.f11734v).f10093e.r();
                c0824t1R.E();
                c0824t1R.F();
                c0824t1R.V(new RunnableC0801l1(c0824t1R, (String) this.f11730r, (String) this.f11731s, c0824t1R.S(false), this.f11732t, (com.google.android.gms.internal.measurement.L) this.f11733u));
                break;
            case 1:
                C0824t1 c0824t1R2 = ((C0817r0) ((Y0) this.f11734v).f5146q).r();
                c0824t1R2.E();
                c0824t1R2.F();
                c0824t1R2.V(new RunnableC0801l1(c0824t1R2, (AtomicReference) this.f11733u, (String) this.f11730r, (String) this.f11731s, c0824t1R2.S(false), this.f11732t));
                break;
            case 2:
                X0 x03 = (X0) this.f11734v;
                Y0 y02 = x03.f11809q;
                C0817r0 c0817r0 = (C0817r0) y02.f5146q;
                y02.E();
                String str2 = (String) this.f11731s;
                Uri uri = (Uri) this.f11733u;
                try {
                    W1 w12 = c0817r0.f12122B;
                    Z z9 = c0817r0.f12150y;
                    C0817r0.i(w12);
                    try {
                        if (!TextUtils.isEmpty(str2)) {
                            if (!str2.contains("gclid")) {
                                try {
                                    if (!str2.contains("gbraid") && !str2.contains("utm_campaign") && !str2.contains("utm_source") && !str2.contains("utm_medium") && !str2.contains("utm_id") && !str2.contains("dclid") && !str2.contains("srsltid") && !str2.contains("sfmc_id")) {
                                        Z z10 = ((C0817r0) w12.f5146q).f12150y;
                                        C0817r0.k(z10);
                                        z10.f11871C.b("Activity created with data 'referrer' without required params");
                                        bundleQ0 = null;
                                        String str3 = (String) this.f11730r;
                                        x02 = x03;
                                        z8 = this.f11732t;
                                        C0791i0 c0791i0 = y02.H;
                                        if (z8) {
                                            str = "Activity created with data 'referrer' without required params";
                                            try {
                                                W1 w13 = c0817r0.f12122B;
                                                C0817r0.i(w13);
                                                Bundle bundleQ02 = w13.Q0(uri);
                                                if (bundleQ02 != null) {
                                                    bundleQ02.putString("_cis", "intent");
                                                    if (bundleQ02.containsKey("gclid") || bundleQ0 == null || !bundleQ0.containsKey("gclid")) {
                                                        charSequence = "utm_medium";
                                                    } else {
                                                        charSequence = "utm_medium";
                                                        bundleQ02.putString("_cer", "gclid=" + bundleQ0.getString("gclid"));
                                                    }
                                                    y02.P(str3, "_cmp", bundleQ02);
                                                    c0791i0.a(str3, bundleQ02);
                                                }
                                                if (TextUtils.isEmpty(str2)) {
                                                    C0817r0.k(z9);
                                                    X x8 = z9.f11871C;
                                                    x8.c(str2, "Activity created with referrer");
                                                    if (c0817r0.f12148w.R(null, I.f11499G0)) {
                                                        if (bundleQ0 != null) {
                                                            y02.P(str3, "_cmp", bundleQ0);
                                                            c0791i0.a(str3, bundleQ0);
                                                        } else {
                                                            C0817r0.k(z9);
                                                            x8.c(str2, "Referrer does not contain valid parameters");
                                                        }
                                                        c0817r0.D.getClass();
                                                        y02.Y("auto", "_ldl", null, true, System.currentTimeMillis());
                                                    } else if (!str2.contains("gclid") || (!str2.contains("utm_campaign") && !str2.contains("utm_source") && !str2.contains(charSequence) && !str2.contains("utm_term") && !str2.contains("utm_content"))) {
                                                        C0817r0.k(z9);
                                                        x8.b(str);
                                                    } else if (!TextUtils.isEmpty(str2)) {
                                                        c0817r0.D.getClass();
                                                        y02.Y("auto", "_ldl", str2, true, System.currentTimeMillis());
                                                    }
                                                }
                                            } catch (RuntimeException e8) {
                                                e = e8;
                                                x03 = x02;
                                                Z z11 = ((C0817r0) x03.f11809q.f5146q).f12150y;
                                                C0817r0.k(z11);
                                                z11.f11875v.c(e, "Throwable caught in handleReferrerForOnActivityCreated");
                                                return;
                                            }
                                        } else {
                                            str = "Activity created with data 'referrer' without required params";
                                        }
                                        charSequence = "utm_medium";
                                        if (TextUtils.isEmpty(str2)) {
                                        }
                                    }
                                } catch (RuntimeException e9) {
                                    e = e9;
                                }
                            }
                            bundleQ0 = w12.Q0(Uri.parse("https://google.com/search?".concat(str2)));
                            if (bundleQ0 != null) {
                                bundleQ0.putString("_cis", "referrer");
                            }
                            String str32 = (String) this.f11730r;
                            x02 = x03;
                            z8 = this.f11732t;
                            C0791i0 c0791i02 = y02.H;
                            if (z8) {
                            }
                            charSequence = "utm_medium";
                            if (TextUtils.isEmpty(str2)) {
                            }
                            break;
                        } else {
                            bundleQ0 = null;
                            String str322 = (String) this.f11730r;
                            x02 = x03;
                            z8 = this.f11732t;
                            C0791i0 c0791i022 = y02.H;
                            if (z8) {
                            }
                            charSequence = "utm_medium";
                            if (TextUtils.isEmpty(str2)) {
                            }
                        }
                    } catch (RuntimeException e10) {
                        e = e10;
                    }
                } catch (RuntimeException e11) {
                    e = e11;
                    x02 = x03;
                }
                Z z112 = ((C0817r0) x03.f11809q.f5146q).f12150y;
                C0817r0.k(z112);
                z112.f11875v.c(e, "Throwable caught in handleReferrerForOnActivityCreated");
                break;
            default:
                C0824t1 c0824t1 = (C0824t1) this.f11734v;
                K k8 = c0824t1.f12179t;
                C0817r0 c0817r02 = (C0817r0) c0824t1.f5146q;
                if (k8 == null) {
                    Z z12 = c0817r02.f12150y;
                    C0817r0.k(z12);
                    z12.f11875v.b("Failed to send default event parameters to service");
                } else {
                    boolean zR = c0817r02.f12148w.R(null, I.f11570m1);
                    X1 x12 = (X1) this.f11733u;
                    if (zR) {
                        c0824t1.L(k8, this.f11732t ? null : (C0825u) this.f11730r, x12);
                    } else {
                        try {
                            k8.r((Bundle) this.f11731s, x12);
                            c0824t1.U();
                        } catch (RemoteException e12) {
                            Z z13 = c0817r02.f12150y;
                            C0817r0.k(z13);
                            z13.f11875v.c(e12, "Failed to send default event parameters to service");
                        }
                    }
                }
                break;
        }
    }

    public U0(C0824t1 c0824t1, X1 x12, boolean z8, C0825u c0825u, Bundle bundle) {
        this.f11729q = 3;
        this.f11733u = x12;
        this.f11732t = z8;
        this.f11730r = c0825u;
        this.f11731s = bundle;
        this.f11734v = c0824t1;
    }

    public /* synthetic */ U0(Object obj, Object obj2, String str, String str2, boolean z8, int i) {
        this.f11729q = i;
        this.f11733u = obj2;
        this.f11730r = str;
        this.f11731s = str2;
        this.f11732t = z8;
        this.f11734v = obj;
    }
}
