package o;

import android.os.Bundle;
import com.google.android.gms.common.internal.Preconditions;
import java.util.Iterator;
import java.util.TreeSet;
import org.json.JSONException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Is0 implements Runnable {
    public final /* synthetic */ int l;
    public final /* synthetic */ Bundle m;
    public final /* synthetic */ Xs0 n;

    public /* synthetic */ Is0(Xs0 xs0, Bundle bundle, int i) {
        this.l = i;
        this.m = bundle;
        this.n = xs0;
    }

    @Override // java.lang.Runnable
    public final void run() throws JSONException {
        Bundle bundle;
        switch (this.l) {
            case 0:
                Xs0 xs0 = this.n;
                xs0.r();
                xs0.t();
                Bundle bundle2 = this.m;
                Preconditions.checkNotNull(bundle2);
                String string = bundle2.getString("name");
                String string2 = bundle2.getString("origin");
                Preconditions.checkNotEmpty(string);
                Preconditions.checkNotEmpty(string2);
                Preconditions.checkNotNull(bundle2.get("value"));
                Kr0 kr0 = (Kr0) xs0.a;
                if (!kr0.a()) {
                    Nq0 nq0 = kr0.f;
                    Kr0.l(nq0);
                    nq0.n.b("Conditional property not set since app measurement is disabled");
                    break;
                } else {
                    C1910mv0 c1910mv0 = new C1910mv0(bundle2.getLong("triggered_timestamp"), bundle2.get("value"), string, string2);
                    try {
                        C2574tv0 c2574tv0 = kr0.i;
                        Kr0.j(c2574tv0);
                        bundle2.getString("app_id");
                        No0 no0T = c2574tv0.T(bundle2.getString("triggered_event_name"), bundle2.getBundle("triggered_event_params"), string2, 0L, true);
                        Kr0.j(c2574tv0);
                        bundle2.getString("app_id");
                        No0 no0T2 = c2574tv0.T(bundle2.getString("timed_out_event_name"), bundle2.getBundle("timed_out_event_params"), string2, 0L, true);
                        bundle2.getString("app_id");
                        kr0.o().L(new Xn0(bundle2.getString("app_id"), string2, c1910mv0, bundle2.getLong("creation_timestamp"), false, bundle2.getString("trigger_event_name"), no0T2, bundle2.getLong("trigger_timeout"), no0T, bundle2.getLong("time_to_live"), c2574tv0.T(bundle2.getString("expired_event_name"), bundle2.getBundle("expired_event_params"), string2, 0L, true)));
                        break;
                    } catch (IllegalArgumentException unused) {
                        return;
                    }
                }
            case 1:
                Xs0 xs02 = this.n;
                xs02.r();
                xs02.t();
                Bundle bundle3 = this.m;
                Preconditions.checkNotNull(bundle3);
                String strCheckNotEmpty = Preconditions.checkNotEmpty(bundle3.getString("name"));
                Kr0 kr02 = (Kr0) xs02.a;
                if (!kr02.a()) {
                    Nq0 nq02 = kr02.f;
                    Kr0.l(nq02);
                    nq02.n.b("Conditional property not cleared since app measurement is disabled");
                    break;
                } else {
                    C1910mv0 c1910mv02 = new C1910mv0(0L, null, strCheckNotEmpty, "");
                    try {
                        C2574tv0 c2574tv02 = kr02.i;
                        Kr0.j(c2574tv02);
                        bundle3.getString("app_id");
                        kr02.o().L(new Xn0(bundle3.getString("app_id"), "", c1910mv02, bundle3.getLong("creation_timestamp"), bundle3.getBoolean("active"), bundle3.getString("trigger_event_name"), null, bundle3.getLong("trigger_timeout"), null, bundle3.getLong("time_to_live"), c2574tv02.T(bundle3.getString("expired_event_name"), bundle3.getBundle("expired_event_params"), "", bundle3.getLong("creation_timestamp"), true)));
                        break;
                    } catch (IllegalArgumentException unused2) {
                        return;
                    }
                }
            default:
                Xs0 xs03 = this.n;
                C1696kj0 c1696kj0 = xs03.w;
                Kr0 kr03 = (Kr0) xs03.a;
                Bundle bundle4 = this.m;
                if (bundle4.isEmpty()) {
                    bundle = bundle4;
                } else {
                    C1617jr0 c1617jr0 = kr03.e;
                    C2574tv0 c2574tv03 = kr03.i;
                    C1421ho0 c1421ho0 = kr03.d;
                    Nq0 nq03 = kr03.f;
                    Kr0.j(c1617jr0);
                    bundle = new Bundle(c1617jr0.y.p());
                    for (String str : bundle4.keySet()) {
                        Object obj = bundle4.get(str);
                        if (obj != null && !(obj instanceof String) && !(obj instanceof Long) && !(obj instanceof Double)) {
                            Kr0.j(c2574tv03);
                            if (C2574tv0.z0(obj)) {
                                C2574tv0.I(c1696kj0, null, 27, null, null, 0);
                            }
                            Kr0.l(nq03);
                            nq03.k.d("Invalid default event parameter type. Name, value", str, obj);
                        } else if (C2574tv0.P(str)) {
                            Kr0.l(nq03);
                            nq03.k.c(str, "Invalid default event parameter name. Name");
                        } else if (obj == null) {
                            bundle.remove(str);
                        } else {
                            Kr0.j(c2574tv03);
                            c1421ho0.getClass();
                            if (c2574tv03.A0("param", str, 500, obj)) {
                                c2574tv03.H(bundle, str, obj);
                            }
                        }
                    }
                    Kr0.j(c2574tv03);
                    C2574tv0 c2574tv04 = ((Kr0) c1421ho0.a).i;
                    Kr0.j(c2574tv04);
                    int i = c2574tv04.W(201500000) ? 100 : 25;
                    if (bundle.size() > i) {
                        Iterator it = new TreeSet(bundle.keySet()).iterator();
                        int i2 = 0;
                        while (it.hasNext()) {
                            String str2 = (String) it.next();
                            i2++;
                            if (i2 > i) {
                                bundle.remove(str2);
                            }
                        }
                        Kr0.j(c2574tv03);
                        C2574tv0.I(c1696kj0, null, 26, null, null, 0);
                        Kr0.l(nq03);
                        nq03.k.b("Too many default event parameters set. Discarding beyond event parameter limit");
                    }
                }
                C1617jr0 c1617jr02 = kr03.e;
                Kr0.j(c1617jr02);
                c1617jr02.y.s(bundle);
                if (!bundle4.isEmpty() || kr03.d.C(null, AbstractC1900mq0.W0)) {
                    kr03.o().x(bundle);
                    break;
                }
                break;
        }
    }
}
