package o;

import android.text.TextUtils;
import com.google.android.gms.common.internal.Preconditions;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.wr0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2851wr0 extends Iu0 implements InterfaceC1133eo0 {
    public final C1839m9 d;
    public final C1839m9 e;
    public final C1839m9 f;
    public final C1839m9 g;
    public final C1839m9 h;
    public final C1839m9 i;
    public final G00 j;
    public final C1696kj0 k;
    public final C1839m9 l;
    public final C1839m9 m;
    public final C1839m9 n;

    public C2851wr0(C1051dv0 c1051dv0) {
        super(c1051dv0);
        this.d = new C1839m9(0);
        this.e = new C1839m9(0);
        this.f = new C1839m9(0);
        this.g = new C1839m9(0);
        this.h = new C1839m9(0);
        this.l = new C1839m9(0);
        this.m = new C1839m9(0);
        this.n = new C1839m9(0);
        this.i = new C1839m9(0);
        this.j = new G00(this);
        this.k = new C1696kj0(11, this);
    }

    public static final C1839m9 C(Dq0 dq0) {
        C1839m9 c1839m9 = new C1839m9(0);
        for (Mq0 mq0 : dq0.t()) {
            c1839m9.put(mq0.p(), mq0.q());
        }
        return c1839m9;
    }

    public static final EnumC2094os0 D(int i) {
        int i2 = i - 1;
        if (i2 == 1) {
            return EnumC2094os0.m;
        }
        if (i2 == 2) {
            return EnumC2094os0.n;
        }
        if (i2 == 3) {
            return EnumC2094os0.f667o;
        }
        if (i2 != 4) {
            return null;
        }
        return EnumC2094os0.p;
    }

    public final void A(String str, Dq0 dq0) {
        Kr0 kr0 = (Kr0) this.a;
        int iY = dq0.y();
        G00 g00 = this.j;
        if (iY == 0) {
            g00.m(str);
            return;
        }
        Nq0 nq0 = kr0.f;
        Kr0.l(nq0);
        nq0.n.c(Integer.valueOf(dq0.y()), "EES programs found");
        C1141es0 c1141es0 = (C1141es0) dq0.x().get(0);
        try {
            C0944cp0 c0944cp0 = new C0944cp0();
            S60 s60 = c0944cp0.a;
            ((C0559Vo) s60.p).a.put("internal.remoteConfig", new CallableC2282qr0(this, str, 2));
            ((C0559Vo) s60.p).a.put("internal.appMetadata", new CallableC2282qr0(this, str, 0));
            ((C0559Vo) s60.p).a.put("internal.logger", new CallableC2471sr0(this));
            c0944cp0.b(c1141es0);
            g00.l(str, c0944cp0);
            Kr0.l(nq0);
            C1984nl c1984nl = nq0.n;
            c1984nl.d("EES program loaded for appId, activities", str, Integer.valueOf(c1141es0.q().q()));
            for (C0950cs0 c0950cs0 : c1141es0.q().p()) {
                Kr0.l(nq0);
                c1984nl.c(c0950cs0.p(), "EES program activity");
            }
        } catch (C2657up0 unused) {
            Nq0 nq02 = kr0.f;
            Kr0.l(nq02);
            nq02.f.c(str, "Failed to load EES program. appId");
        }
    }

    public final Dq0 B(String str, byte[] bArr) {
        Kr0 kr0 = (Kr0) this.a;
        if (bArr == null) {
            return Dq0.G();
        }
        try {
            Dq0 dq0 = (Dq0) ((Bq0) C1720kv0.a0(Dq0.F(), bArr)).e();
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.n.d("Parsed config. version, gmp_app_id", dq0.p() ? Long.valueOf(dq0.q()) : null, dq0.r() ? dq0.s() : null);
            return dq0;
        } catch (RuntimeException e) {
            Nq0 nq02 = kr0.f;
            Kr0.l(nq02);
            nq02.i.d("Unable to merge remote config. appId", Nq0.A(str), e);
            return Dq0.G();
        } catch (Gt0 e2) {
            Nq0 nq03 = kr0.f;
            Kr0.l(nq03);
            nq03.i.d("Unable to merge remote config. appId", Nq0.A(str), e2);
            return Dq0.G();
        }
    }

    public final Dq0 E(String str) {
        t();
        r();
        Preconditions.checkNotEmpty(str);
        y(str);
        return (Dq0) this.h.get(str);
    }

    public final String F(String str) {
        r();
        y(str);
        return (String) this.l.get(str);
    }

    /* JADX WARN: Code restructure failed: missing block: B:100:0x03ff, code lost:
    
        r3 = java.lang.Integer.valueOf(r6.q());
     */
    /* JADX WARN: Code restructure failed: missing block: B:101:0x0408, code lost:
    
        r3 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:102:0x0409, code lost:
    
        r5.put(r0, r3);
        r28 = r0;
        r5.put("property_name", r6.r());
     */
    /* JADX WARN: Code restructure failed: missing block: B:103:0x041b, code lost:
    
        if (r6.v() == false) goto L105;
     */
    /* JADX WARN: Code restructure failed: missing block: B:104:0x041d, code lost:
    
        r3 = java.lang.Boolean.valueOf(r6.w());
     */
    /* JADX WARN: Code restructure failed: missing block: B:105:0x0426, code lost:
    
        r3 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:106:0x0427, code lost:
    
        r5.put("session_scoped", r3);
        r5.put("data", r14);
     */
    /* JADX WARN: Code restructure failed: missing block: B:108:0x0439, code lost:
    
        if (r8.h0().insertWithOnConflict("property_filters", null, r5, 5) != (-1)) goto L113;
     */
    /* JADX WARN: Code restructure failed: missing block: B:109:0x043b, code lost:
    
        r0 = r13.f;
        o.Kr0.l(r0);
        r0.f.c(o.Nq0.A(r30), "Failed to insert property filter (got -1). appId");
     */
    /* JADX WARN: Code restructure failed: missing block: B:111:0x044c, code lost:
    
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:113:0x044e, code lost:
    
        r5 = r23;
        r3 = r26;
        r0 = r28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:114:0x0456, code lost:
    
        r1 = r13.f;
        o.Kr0.l(r1);
        r1.f.d("Error storing property filter. appId", o.Nq0.A(r30), r0);
     */
    /* JADX WARN: Code restructure failed: missing block: B:115:0x0466, code lost:
    
        r8.t();
        r8.r();
        com.google.android.gms.common.internal.Preconditions.checkNotEmpty(r30);
        r0 = r8.h0();
        r0.delete("property_filters", "app_id=? and audience_id=?", new java.lang.String[]{r30, java.lang.String.valueOf(r7)});
        r0.delete("event_filters", "app_id=? and audience_id=?", new java.lang.String[]{r30, java.lang.String.valueOf(r7)});
     */
    /* JADX WARN: Code restructure failed: missing block: B:116:0x0489, code lost:
    
        r1 = r24;
        r3 = r25;
        r0 = r27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:53:0x0268, code lost:
    
        r0 = r5.r().iterator();
     */
    /* JADX WARN: Code restructure failed: missing block: B:55:0x0274, code lost:
    
        if (r0.hasNext() == false) goto L193;
     */
    /* JADX WARN: Code restructure failed: missing block: B:57:0x0280, code lost:
    
        if (((o.C1425hq0) r0.next()).p() != false) goto L202;
     */
    /* JADX WARN: Code restructure failed: missing block: B:58:0x0282, code lost:
    
        r0 = r13.f;
        o.Kr0.l(r0);
        r0.i.d("Property filter with no ID. Audience definition ignored. appId, audienceId", o.Nq0.A(r30), java.lang.Integer.valueOf(r7));
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0297, code lost:
    
        r0 = r5.u().iterator();
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x029f, code lost:
    
        r14 = r0.hasNext();
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x02a3, code lost:
    
        r23 = r0;
        r0 = "filter_id";
        r24 = r1;
        r25 = r3;
        r3 = "app_id";
     */
    /* JADX WARN: Code restructure failed: missing block: B:63:0x02b5, code lost:
    
        if (r14 == false) goto L204;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x02b7, code lost:
    
        r14 = (o.C0755aq0) r23.next();
        r8.t();
        r8.r();
        com.google.android.gms.common.internal.Preconditions.checkNotEmpty(r30);
        com.google.android.gms.common.internal.Preconditions.checkNotNull(r14);
     */
    /* JADX WARN: Code restructure failed: missing block: B:65:0x02d1, code lost:
    
        if (r14.r().isEmpty() == false) goto L73;
     */
    /* JADX WARN: Code restructure failed: missing block: B:66:0x02d3, code lost:
    
        r0 = r13.f;
        o.Kr0.l(r0);
        r0 = r0.i;
        r3 = o.Nq0.A(r30);
        r4 = java.lang.Integer.valueOf(r7);
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x02e8, code lost:
    
        if (r14.p() == false) goto L71;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x02ea, code lost:
    
        r5 = java.lang.Integer.valueOf(r14.q());
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x02f3, code lost:
    
        r0 = th;
     */
    /* JADX WARN: Code restructure failed: missing block: B:71:0x02f8, code lost:
    
        r5 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:72:0x02f9, code lost:
    
        r0.e("Event filter had no event name. Audience definition ignored. appId, audienceId, filterId", r3, r4, java.lang.String.valueOf(r5));
        r27 = r6;
     */
    /* JADX WARN: Code restructure failed: missing block: B:73:0x0304, code lost:
    
        r26 = r5;
        r5 = r14.a();
        r27 = r6;
        r6 = new android.content.ContentValues();
        r6.put("app_id", r30);
        r6.put("audience_id", java.lang.Integer.valueOf(r7));
     */
    /* JADX WARN: Code restructure failed: missing block: B:74:0x031f, code lost:
    
        if (r14.p() == false) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x0321, code lost:
    
        r1 = java.lang.Integer.valueOf(r14.q());
     */
    /* JADX WARN: Code restructure failed: missing block: B:76:0x032a, code lost:
    
        r1 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:77:0x032b, code lost:
    
        r6.put("filter_id", r1);
        r6.put("event_name", r14.r());
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:0x033b, code lost:
    
        if (r14.z() == false) goto L80;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x033d, code lost:
    
        r0 = java.lang.Boolean.valueOf(r14.A());
     */
    /* JADX WARN: Code restructure failed: missing block: B:80:0x0346, code lost:
    
        r0 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:81:0x0347, code lost:
    
        r6.put("session_scoped", r0);
        r6.put("data", r5);
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x0359, code lost:
    
        if (r8.h0().insertWithOnConflict("event_filters", null, r6, 5) != (-1)) goto L206;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:0x035b, code lost:
    
        r0 = r13.f;
        o.Kr0.l(r0);
        r0.f.c(o.Nq0.A(r30), "Failed to insert event filter (got -1). appId");
     */
    /* JADX WARN: Code restructure failed: missing block: B:85:0x036b, code lost:
    
        r0 = r23;
        r1 = r24;
        r3 = r25;
        r5 = r26;
        r6 = r27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:86:0x0377, code lost:
    
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:87:0x0378, code lost:
    
        r1 = r13.f;
        o.Kr0.l(r1);
        r1.f.d("Error storing event filter. appId", o.Nq0.A(r30), r0);
     */
    /* JADX WARN: Code restructure failed: missing block: B:88:0x038a, code lost:
    
        r27 = r6;
        r5 = r5.r().iterator();
     */
    /* JADX WARN: Code restructure failed: missing block: B:90:0x039a, code lost:
    
        if (r5.hasNext() == false) goto L208;
     */
    /* JADX WARN: Code restructure failed: missing block: B:91:0x039c, code lost:
    
        r6 = (o.C1425hq0) r5.next();
        r8.t();
        r8.r();
        com.google.android.gms.common.internal.Preconditions.checkNotEmpty(r30);
        com.google.android.gms.common.internal.Preconditions.checkNotNull(r6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:92:0x03b6, code lost:
    
        if (r6.r().isEmpty() == false) goto L98;
     */
    /* JADX WARN: Code restructure failed: missing block: B:93:0x03b8, code lost:
    
        r0 = r13.f;
        o.Kr0.l(r0);
        r0 = r0.i;
        r3 = o.Nq0.A(r30);
        r4 = java.lang.Integer.valueOf(r7);
     */
    /* JADX WARN: Code restructure failed: missing block: B:94:0x03cd, code lost:
    
        if (r6.p() == false) goto L96;
     */
    /* JADX WARN: Code restructure failed: missing block: B:95:0x03cf, code lost:
    
        r5 = java.lang.Integer.valueOf(r6.q());
     */
    /* JADX WARN: Code restructure failed: missing block: B:96:0x03d8, code lost:
    
        r5 = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:97:0x03d9, code lost:
    
        r0.e("Property filter had no property name. Audience definition ignored. appId, audienceId, filterId", r3, r4, java.lang.String.valueOf(r5));
     */
    /* JADX WARN: Code restructure failed: missing block: B:98:0x03e2, code lost:
    
        r14 = r6.a();
        r23 = r5;
        r5 = new android.content.ContentValues();
        r5.put(r3, r30);
        r26 = r3;
        r5.put("audience_id", java.lang.Integer.valueOf(r7));
     */
    /* JADX WARN: Code restructure failed: missing block: B:99:0x03fd, code lost:
    
        if (r6.p() == false) goto L101;
     */
    /* JADX WARN: Removed duplicated region for block: B:155:0x05f6 A[Catch: SQLiteException -> 0x0607, TRY_LEAVE, TryCatch #1 {SQLiteException -> 0x0607, blocks: (B:153:0x05df, B:155:0x05f6), top: B:165:0x05df }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void G(java.lang.String r30, byte[] r31, java.lang.String r32, java.lang.String r33) throws java.lang.Throwable {
        /*
            Method dump skipped, instructions count: 1586
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2851wr0.G(java.lang.String, byte[], java.lang.String, java.lang.String):void");
    }

    public final boolean H(String str, String str2) {
        Boolean bool;
        r();
        y(str);
        if ("1".equals(a(str, "measurement.upload.blacklist_internal")) && C2574tv0.P(str2)) {
            return true;
        }
        if ("1".equals(a(str, "measurement.upload.blacklist_public")) && C2574tv0.p0(str2)) {
            return true;
        }
        Map map = (Map) this.f.get(str);
        if (map == null || (bool = (Boolean) map.get(str2)) == null) {
            return false;
        }
        return bool.booleanValue();
    }

    public final boolean I(String str, String str2) {
        Boolean bool;
        r();
        y(str);
        if ("ecommerce_purchase".equals(str2) || "purchase".equals(str2) || "refund".equals(str2)) {
            return true;
        }
        Map map = (Map) this.g.get(str);
        if (map == null || (bool = (Boolean) map.get(str2)) == null) {
            return false;
        }
        return bool.booleanValue();
    }

    public final int J(String str, String str2) {
        Integer num;
        r();
        y(str);
        Map map = (Map) this.i.get(str);
        if (map == null || (num = (Integer) map.get(str2)) == null) {
            return 1;
        }
        return num.intValue();
    }

    public final boolean K(String str) {
        r();
        y(str);
        C1839m9 c1839m9 = this.e;
        if (c1839m9.get(str) != null) {
            return ((Set) c1839m9.get(str)).contains("os_version") || ((Set) c1839m9.get(str)).contains("device_info");
        }
        return false;
    }

    public final boolean L(String str) {
        r();
        y(str);
        C1839m9 c1839m9 = this.e;
        return c1839m9.get(str) != null && ((Set) c1839m9.get(str)).contains("app_instance_id");
    }

    public final boolean M(String str, EnumC2094os0 enumC2094os0) {
        r();
        y(str);
        C2659uq0 c2659uq0N = N(str);
        if (c2659uq0N == null) {
            return false;
        }
        for (C1615jq0 c1615jq0 : c2659uq0N.p()) {
            if (enumC2094os0 == D(c1615jq0.p())) {
                return c1615jq0.q() == 2;
            }
        }
        return false;
    }

    public final C2659uq0 N(String str) {
        r();
        y(str);
        Dq0 dq0E = E(str);
        if (dq0E == null || !dq0E.B()) {
            return null;
        }
        return dq0E.C();
    }

    @Override // o.InterfaceC1133eo0
    public final String a(String str, String str2) {
        r();
        y(str);
        Map map = (Map) this.d.get(str);
        if (map != null) {
            return (String) map.get(str2);
        }
        return null;
    }

    public final EnumC1809ls0 w(String str, EnumC2094os0 enumC2094os0) {
        r();
        y(str);
        C2659uq0 c2659uq0N = N(str);
        if (c2659uq0N != null) {
            Iterator it = c2659uq0N.u().iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                C1615jq0 c1615jq0 = (C1615jq0) it.next();
                if (D(c1615jq0.p()) == enumC2094os0) {
                    int iQ = c1615jq0.q() - 1;
                    if (iQ == 1) {
                        return EnumC1809ls0.p;
                    }
                    if (iQ == 2) {
                        return EnumC1809ls0.f627o;
                    }
                }
            }
        }
        return EnumC1809ls0.m;
    }

    public final boolean x(String str) {
        r();
        y(str);
        C2659uq0 c2659uq0N = N(str);
        if (c2659uq0N == null) {
            return false;
        }
        for (C1615jq0 c1615jq0 : c2659uq0N.p()) {
            if (c1615jq0.p() == 3 && c1615jq0.r() == 3) {
                return true;
            }
        }
        return false;
    }

    public final void y(String str) {
        t();
        r();
        Preconditions.checkNotEmpty(str);
        C1839m9 c1839m9 = this.h;
        if (c1839m9.get(str) == null) {
            C2940xo0 c2940xo0 = this.b.c;
            C1051dv0.T(c2940xo0);
            C70 c70Y0 = c2940xo0.y0(str);
            C1839m9 c1839m92 = this.n;
            C1839m9 c1839m93 = this.m;
            C1839m9 c1839m94 = this.l;
            C1839m9 c1839m95 = this.d;
            if (c70Y0 != null) {
                Bq0 bq0 = (Bq0) B(str, (byte[]) c70Y0.m).i();
                z(str, bq0);
                c1839m95.put(str, C((Dq0) bq0.e()));
                c1839m9.put(str, (Dq0) bq0.e());
                A(str, (Dq0) bq0.e());
                c1839m94.put(str, ((Dq0) bq0.m).A());
                c1839m93.put(str, (String) c70Y0.n);
                c1839m92.put(str, (String) c70Y0.f65o);
                return;
            }
            c1839m95.put(str, null);
            this.f.put(str, null);
            this.e.put(str, null);
            this.g.put(str, null);
            c1839m9.put(str, null);
            c1839m94.put(str, null);
            c1839m93.put(str, null);
            c1839m92.put(str, null);
            this.i.put(str, null);
        }
    }

    public final void z(String str, Bq0 bq0) {
        Kr0 kr0 = (Kr0) this.a;
        HashSet hashSet = new HashSet();
        C1839m9 c1839m9 = new C1839m9(0);
        C1839m9 c1839m92 = new C1839m9(0);
        C1839m9 c1839m93 = new C1839m9(0);
        Iterator it = Collections.unmodifiableList(((Dq0) bq0.m).z()).iterator();
        while (it.hasNext()) {
            hashSet.add(((C2849wq0) it.next()).p());
        }
        for (int i = 0; i < ((Dq0) bq0.m).u(); i++) {
            C3039yq0 c3039yq0 = (C3039yq0) ((Dq0) bq0.m).v(i).i();
            if (c3039yq0.h().isEmpty()) {
                Nq0 nq0 = kr0.f;
                Kr0.l(nq0);
                nq0.i.b("EventConfig contained null event name");
            } else {
                String strH = c3039yq0.h();
                String strO = AbstractC0662Zn.O(c3039yq0.h(), AbstractC2841wm0.k, AbstractC2841wm0.m);
                if (!TextUtils.isEmpty(strO)) {
                    c3039yq0.b();
                    ((C3134zq0) c3039yq0.m).w(strO);
                    bq0.b();
                    ((Dq0) bq0.m).H(i, (C3134zq0) c3039yq0.e());
                }
                if (((C3134zq0) c3039yq0.m).q() && ((C3134zq0) c3039yq0.m).r()) {
                    c1839m9.put(strH, Boolean.TRUE);
                }
                if (((C3134zq0) c3039yq0.m).s() && ((C3134zq0) c3039yq0.m).t()) {
                    c1839m92.put(c3039yq0.h(), Boolean.TRUE);
                }
                if (((C3134zq0) c3039yq0.m).u()) {
                    if (((C3134zq0) c3039yq0.m).v() < 2 || ((C3134zq0) c3039yq0.m).v() > 65535) {
                        Nq0 nq02 = kr0.f;
                        Kr0.l(nq02);
                        nq02.i.d("Invalid sampling rate. Event name, sample rate", c3039yq0.h(), Integer.valueOf(((C3134zq0) c3039yq0.m).v()));
                    } else {
                        c1839m93.put(c3039yq0.h(), Integer.valueOf(((C3134zq0) c3039yq0.m).v()));
                    }
                }
            }
        }
        this.e.put(str, hashSet);
        this.f.put(str, c1839m9);
        this.g.put(str, c1839m92);
        this.i.put(str, c1839m93);
    }

    @Override // o.Iu0
    public final void v() {
    }
}
