package L1;

import com.google.android.gms.internal.measurement.C0345a1;
import com.google.android.gms.internal.measurement.C0405m1;
import com.google.android.gms.internal.measurement.C0410n1;
import com.google.android.gms.internal.measurement.C0415o1;
import com.google.android.gms.internal.measurement.C0419p0;
import com.google.android.gms.internal.measurement.C0420p1;
import com.google.android.gms.internal.measurement.C0446u3;
import com.google.android.gms.internal.measurement.C0453w0;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import r.C0963b;
import r.C0966e;

/* JADX INFO: loaded from: classes.dex */
public final class g2 {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final BitSet f1818d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final BitSet f1819e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final C0966e f1820f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final C0966e f1821g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final /* synthetic */ C0086c f1822h;

    public g2(C0086c c0086c, String str, C0410n1 c0410n1, BitSet bitSet, BitSet bitSet2, C0966e c0966e, C0966e c0966e2) {
        Objects.requireNonNull(c0086c);
        this.f1822h = c0086c;
        this.f1815a = str;
        this.f1818d = bitSet;
        this.f1819e = bitSet2;
        this.f1820f = c0966e;
        this.f1821g = new C0966e(0);
        for (Integer num : (C0963b) c0966e2.keySet()) {
            ArrayList arrayList = new ArrayList();
            arrayList.add((Long) c0966e2.get(num));
            this.f1821g.put(num, arrayList);
        }
        this.f1816b = false;
        this.f1817c = c0410n1;
    }

    public final void a(C0083b c0083b) {
        int iQ;
        boolean z5;
        boolean zV;
        switch (c0083b.f1679g) {
            case 0:
                iQ = ((C0419p0) c0083b.i).q();
                break;
            default:
                iQ = ((C0453w0) c0083b.i).q();
                break;
        }
        if (c0083b.f1675c != null) {
            this.f1819e.set(iQ, true);
        }
        Boolean bool = c0083b.f1676d;
        if (bool != null) {
            this.f1818d.set(iQ, bool.booleanValue());
        }
        if (c0083b.f1677e != null) {
            Integer numValueOf = Integer.valueOf(iQ);
            C0966e c0966e = this.f1820f;
            Long l5 = (Long) c0966e.get(numValueOf);
            long jLongValue = c0083b.f1677e.longValue() / 1000;
            if (l5 == null || jLongValue > l5.longValue()) {
                c0966e.put(numValueOf, Long.valueOf(jLongValue));
            }
        }
        if (c0083b.f1678f != null) {
            C0966e c0966e2 = this.f1821g;
            Integer numValueOf2 = Integer.valueOf(iQ);
            List arrayList = (List) c0966e2.get(numValueOf2);
            if (arrayList == null) {
                arrayList = new ArrayList();
                c0966e2.put(numValueOf2, arrayList);
            }
            switch (c0083b.f1679g) {
                case 0:
                    z5 = false;
                    break;
                default:
                    z5 = true;
                    break;
            }
            if (z5) {
                arrayList.clear();
            }
            C0446u3.a();
            C0146w0 c0146w0 = (C0146w0) this.f1822h.f29k;
            C0098g c0098g = c0146w0.f2035n;
            E e2 = F.f1359F0;
            String str = this.f1815a;
            if (c0098g.u(str, e2)) {
                switch (c0083b.f1679g) {
                    case 0:
                        zV = ((C0419p0) c0083b.i).v();
                        break;
                    default:
                        zV = false;
                        break;
                }
                if (zV) {
                    arrayList.clear();
                }
            }
            C0446u3.a();
            if (!c0146w0.f2035n.u(str, e2)) {
                arrayList.add(Long.valueOf(c0083b.f1678f.longValue() / 1000));
                return;
            }
            Long lValueOf = Long.valueOf(c0083b.f1678f.longValue() / 1000);
            if (arrayList.contains(lValueOf)) {
                return;
            }
            arrayList.add(lValueOf);
        }
    }

    public final com.google.android.gms.internal.measurement.U0 b(int i) {
        ArrayList arrayList;
        List list;
        com.google.android.gms.internal.measurement.T0 t0W = com.google.android.gms.internal.measurement.U0.w();
        t0W.b();
        ((com.google.android.gms.internal.measurement.U0) t0W.f5142l).x(i);
        t0W.b();
        ((com.google.android.gms.internal.measurement.U0) t0W.f5142l).A(this.f1816b);
        C0410n1 c0410n1 = this.f1817c;
        if (c0410n1 != null) {
            t0W.b();
            ((com.google.android.gms.internal.measurement.U0) t0W.f5142l).z(c0410n1);
        }
        C0405m1 c0405m1X = C0410n1.x();
        ArrayList arrayListS = C0084b0.S(this.f1818d);
        c0405m1X.b();
        ((C0410n1) c0405m1X.f5142l).B(arrayListS);
        ArrayList arrayListS2 = C0084b0.S(this.f1819e);
        c0405m1X.b();
        ((C0410n1) c0405m1X.f5142l).z(arrayListS2);
        C0966e c0966e = this.f1820f;
        if (c0966e == null) {
            arrayList = null;
        } else {
            ArrayList arrayList2 = new ArrayList(c0966e.f9618m);
            for (Integer num : (C0963b) c0966e.keySet()) {
                int iIntValue = num.intValue();
                Long l5 = (Long) c0966e.get(num);
                if (l5 != null) {
                    com.google.android.gms.internal.measurement.Z0 z0T = C0345a1.t();
                    z0T.b();
                    ((C0345a1) z0T.f5142l).u(iIntValue);
                    long jLongValue = l5.longValue();
                    z0T.b();
                    ((C0345a1) z0T.f5142l).v(jLongValue);
                    arrayList2.add((C0345a1) z0T.e());
                }
            }
            arrayList = arrayList2;
        }
        if (arrayList != null) {
            c0405m1X.b();
            ((C0410n1) c0405m1X.f5142l).D(arrayList);
        }
        C0966e c0966e2 = this.f1821g;
        if (c0966e2 == null) {
            list = Collections.EMPTY_LIST;
        } else {
            ArrayList arrayList3 = new ArrayList(c0966e2.f9618m);
            for (Integer num2 : (C0963b) c0966e2.keySet()) {
                C0415o1 c0415o1U = C0420p1.u();
                int iIntValue2 = num2.intValue();
                c0415o1U.b();
                ((C0420p1) c0415o1U.f5142l).v(iIntValue2);
                List list2 = (List) c0966e2.get(num2);
                if (list2 != null) {
                    Collections.sort(list2);
                    c0415o1U.b();
                    ((C0420p1) c0415o1U.f5142l).w(list2);
                }
                arrayList3.add((C0420p1) c0415o1U.e());
            }
            list = arrayList3;
        }
        c0405m1X.b();
        ((C0410n1) c0405m1X.f5142l).F(list);
        t0W.b();
        ((com.google.android.gms.internal.measurement.U0) t0W.f5142l).y((C0410n1) c0405m1X.e());
        return (com.google.android.gms.internal.measurement.U0) t0W.e();
    }

    public g2(C0086c c0086c, String str) {
        Objects.requireNonNull(c0086c);
        this.f1822h = c0086c;
        this.f1815a = str;
        this.f1816b = true;
        this.f1818d = new BitSet();
        this.f1819e = new BitSet();
        this.f1820f = new C0966e(0);
        this.f1821g = new C0966e(0);
    }
}
