package kotlin.reflect.w.internal.y0.g;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import kotlin.reflect.w.internal.y0.g.q;
import kotlin.reflect.w.internal.y0.i.a;
import kotlin.reflect.w.internal.y0.i.c;
import kotlin.reflect.w.internal.y0.i.d;
import kotlin.reflect.w.internal.y0.i.e;
import kotlin.reflect.w.internal.y0.i.f;
import kotlin.reflect.w.internal.y0.i.h;
import kotlin.reflect.w.internal.y0.i.i;
import kotlin.reflect.w.internal.y0.i.j;
import kotlin.reflect.w.internal.y0.i.p;
import kotlin.reflect.w.internal.y0.i.q;
import kotlin.reflect.w.internal.y0.i.r;
import kotlin.reflect.w.internal.y0.i.v;

/* JADX INFO: loaded from: classes2.dex */
public final class h extends kotlin.reflect.w.internal.y0.i.h implements q {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final h f7809f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static r<h> f7810m = new a();

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final kotlin.reflect.w.internal.y0.i.c f7811n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f7812o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f7813p;

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public c f7815r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public q f7816s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f7817t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public List<h> f7818u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public List<h> f7819v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public byte f7820w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public int f7821x;

    public static class a extends kotlin.reflect.w.internal.y0.i.b<h> {
        @Override // kotlin.reflect.w.internal.y0.i.r
        public Object a(d dVar, f fVar) {
            return new h(dVar, fVar, null);
        }
    }

    public static final class b extends h.b<h, b> implements q {

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public int f7822m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public int f7823n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        public int f7824o;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        public int f7827r;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public c f7825p = c.TRUE;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public q f7826q = q.f7965m;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public List<h> f7828s = Collections.emptyList();

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        public List<h> f7829t = Collections.emptyList();

        @Override // r.i0.w.b.y0.i.p.a
        public p a() {
            h hVarM = m();
            if (hVarM.i()) {
                return hVarM;
            }
            throw new v();
        }

        @Override // r.i0.w.b.y0.i.h.b
        public Object clone() {
            b bVar = new b();
            bVar.n(m());
            return bVar;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a, r.i0.w.b.y0.i.p.a
        public /* bridge */ /* synthetic */ p.a h(d dVar, f fVar) throws Throwable {
            o(dVar, fVar);
            return this;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a
        /* JADX INFO: renamed from: j */
        public /* bridge */ /* synthetic */ a.AbstractC0155a h(d dVar, f fVar) throws Throwable {
            o(dVar, fVar);
            return this;
        }

        @Override // r.i0.w.b.y0.i.h.b
        /* JADX INFO: renamed from: k */
        public h.b clone() {
            b bVar = new b();
            bVar.n(m());
            return bVar;
        }

        @Override // r.i0.w.b.y0.i.h.b
        public /* bridge */ /* synthetic */ h.b l(kotlin.reflect.w.internal.y0.i.h hVar) {
            n((h) hVar);
            return this;
        }

        public h m() {
            h hVar = new h(this, null);
            int i2 = this.f7822m;
            int i3 = (i2 & 1) != 1 ? 0 : 1;
            hVar.f7813p = this.f7823n;
            if ((i2 & 2) == 2) {
                i3 |= 2;
            }
            hVar.f7814q = this.f7824o;
            if ((i2 & 4) == 4) {
                i3 |= 4;
            }
            hVar.f7815r = this.f7825p;
            if ((i2 & 8) == 8) {
                i3 |= 8;
            }
            hVar.f7816s = this.f7826q;
            if ((i2 & 16) == 16) {
                i3 |= 16;
            }
            hVar.f7817t = this.f7827r;
            if ((i2 & 32) == 32) {
                this.f7828s = Collections.unmodifiableList(this.f7828s);
                this.f7822m &= -33;
            }
            hVar.f7818u = this.f7828s;
            if ((this.f7822m & 64) == 64) {
                this.f7829t = Collections.unmodifiableList(this.f7829t);
                this.f7822m &= -65;
            }
            hVar.f7819v = this.f7829t;
            hVar.f7812o = i3;
            return hVar;
        }

        public b n(h hVar) {
            q qVar;
            if (hVar == h.f7809f) {
                return this;
            }
            int i2 = hVar.f7812o;
            if ((i2 & 1) == 1) {
                int i3 = hVar.f7813p;
                this.f7822m |= 1;
                this.f7823n = i3;
            }
            if ((i2 & 2) == 2) {
                int i4 = hVar.f7814q;
                this.f7822m = 2 | this.f7822m;
                this.f7824o = i4;
            }
            if ((i2 & 4) == 4) {
                c cVar = hVar.f7815r;
                Objects.requireNonNull(cVar);
                this.f7822m = 4 | this.f7822m;
                this.f7825p = cVar;
            }
            if ((hVar.f7812o & 8) == 8) {
                q qVarN = hVar.f7816s;
                if ((this.f7822m & 8) == 8 && (qVar = this.f7826q) != q.f7965m) {
                    q.c cVarY = q.y(qVar);
                    cVarY.l(qVarN);
                    qVarN = cVarY.n();
                }
                this.f7826q = qVarN;
                this.f7822m |= 8;
            }
            if ((hVar.f7812o & 16) == 16) {
                int i5 = hVar.f7817t;
                this.f7822m = 16 | this.f7822m;
                this.f7827r = i5;
            }
            if (!hVar.f7818u.isEmpty()) {
                if (this.f7828s.isEmpty()) {
                    this.f7828s = hVar.f7818u;
                    this.f7822m &= -33;
                } else {
                    if ((this.f7822m & 32) != 32) {
                        this.f7828s = new ArrayList(this.f7828s);
                        this.f7822m |= 32;
                    }
                    this.f7828s.addAll(hVar.f7818u);
                }
            }
            if (!hVar.f7819v.isEmpty()) {
                if (this.f7829t.isEmpty()) {
                    this.f7829t = hVar.f7819v;
                    this.f7822m &= -65;
                } else {
                    if ((this.f7822m & 64) != 64) {
                        this.f7829t = new ArrayList(this.f7829t);
                        this.f7822m |= 64;
                    }
                    this.f7829t.addAll(hVar.f7819v);
                }
            }
            this.f8259f = this.f8259f.b(hVar.f7811n);
            return this;
        }

        /* JADX WARN: Removed duplicated region for block: B:15:0x001b  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public r.i0.w.b.y0.g.h.b o(kotlin.reflect.w.internal.y0.i.d r3, kotlin.reflect.w.internal.y0.i.f r4) throws java.lang.Throwable {
            /*
                r2 = this;
                r0 = 0
                r.i0.w.b.y0.i.r<r.i0.w.b.y0.g.h> r1 = kotlin.reflect.w.internal.y0.g.h.f7810m     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                java.lang.Object r3 = r1.a(r3, r4)     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                r.i0.w.b.y0.g.h r3 = (kotlin.reflect.w.internal.y0.g.h) r3     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                if (r3 == 0) goto Le
                r2.n(r3)
            Le:
                return r2
            Lf:
                r3 = move-exception
                goto L19
            L11:
                r3 = move-exception
                r.i0.w.b.y0.i.p r4 = r3.f8275f     // Catch: java.lang.Throwable -> Lf
                r.i0.w.b.y0.g.h r4 = (kotlin.reflect.w.internal.y0.g.h) r4     // Catch: java.lang.Throwable -> Lf
                throw r3     // Catch: java.lang.Throwable -> L17
            L17:
                r3 = move-exception
                r0 = r4
            L19:
                if (r0 == 0) goto L1e
                r2.n(r0)
            L1e:
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: r.i0.w.b.y0.g.h.b.o(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.h$b");
        }
    }

    public enum c implements i.a {
        TRUE(0),
        FALSE(1),
        NULL(2);


        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public final int f7834p;

        c(int i2) {
            this.f7834p = i2;
        }

        public static c b(int i2) {
            if (i2 == 0) {
                return TRUE;
            }
            if (i2 == 1) {
                return FALSE;
            }
            if (i2 != 2) {
                return null;
            }
            return NULL;
        }

        @Override // r.i0.w.b.y0.i.i.a
        public final int a() {
            return this.f7834p;
        }
    }

    static {
        h hVar = new h();
        f7809f = hVar;
        hVar.k();
    }

    public h() {
        this.f7820w = (byte) -1;
        this.f7821x = -1;
        this.f7811n = kotlin.reflect.w.internal.y0.i.c.f8234f;
    }

    public h(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        List list;
        r<h> rVar;
        this.f7820w = (byte) -1;
        this.f7821x = -1;
        k();
        c.b bVarN = kotlin.reflect.w.internal.y0.i.c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        int i2 = 0;
        while (!z2) {
            try {
                try {
                    try {
                        int iO = dVar.o();
                        if (iO != 0) {
                            if (iO == 8) {
                                this.f7812o |= 1;
                                this.f7813p = dVar.l();
                            } else if (iO == 16) {
                                this.f7812o |= 2;
                                this.f7814q = dVar.l();
                            } else if (iO == 24) {
                                int iL = dVar.l();
                                c cVarB = c.b(iL);
                                if (cVarB == null) {
                                    eVarK.y(iO);
                                    eVarK.y(iL);
                                } else {
                                    this.f7812o |= 4;
                                    this.f7815r = cVarB;
                                }
                            } else if (iO == 34) {
                                q.c cVarY = null;
                                if ((this.f7812o & 8) == 8) {
                                    q qVar = this.f7816s;
                                    Objects.requireNonNull(qVar);
                                    cVarY = q.y(qVar);
                                }
                                q qVar2 = (q) dVar.h(q.f7966n, fVar);
                                this.f7816s = qVar2;
                                if (cVarY != null) {
                                    cVarY.l(qVar2);
                                    this.f7816s = cVarY.n();
                                }
                                this.f7812o |= 8;
                            } else if (iO != 40) {
                                if (iO == 50) {
                                    if ((i2 & 32) != 32) {
                                        this.f7818u = new ArrayList();
                                        i2 |= 32;
                                    }
                                    list = this.f7818u;
                                    rVar = f7810m;
                                } else if (iO == 58) {
                                    if ((i2 & 64) != 64) {
                                        this.f7819v = new ArrayList();
                                        i2 |= 64;
                                    }
                                    list = this.f7819v;
                                    rVar = f7810m;
                                } else if (!dVar.r(iO, eVarK)) {
                                }
                                list.add(dVar.h(rVar, fVar));
                            } else {
                                this.f7812o |= 16;
                                this.f7817t = dVar.l();
                            }
                        }
                        z2 = true;
                    } catch (IOException e2) {
                        j jVar = new j(e2.getMessage());
                        jVar.f8275f = this;
                        throw jVar;
                    }
                } catch (j e3) {
                    e3.f8275f = this;
                    throw e3;
                }
            } catch (Throwable th) {
                if ((i2 & 32) == 32) {
                    this.f7818u = Collections.unmodifiableList(this.f7818u);
                }
                if ((i2 & 64) == 64) {
                    this.f7819v = Collections.unmodifiableList(this.f7819v);
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f7811n = bVarN.d();
                    throw th2;
                }
                this.f7811n = bVarN.d();
                throw th;
            }
        }
        if ((i2 & 32) == 32) {
            this.f7818u = Collections.unmodifiableList(this.f7818u);
        }
        if ((i2 & 64) == 64) {
            this.f7819v = Collections.unmodifiableList(this.f7819v);
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f7811n = bVarN.d();
            throw th3;
        }
        this.f7811n = bVarN.d();
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a c() {
        b bVar = new b();
        bVar.n(this);
        return bVar;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public void d(e eVar) throws IOException {
        f();
        if ((this.f7812o & 1) == 1) {
            eVar.p(1, this.f7813p);
        }
        if ((this.f7812o & 2) == 2) {
            eVar.p(2, this.f7814q);
        }
        if ((this.f7812o & 4) == 4) {
            eVar.n(3, this.f7815r.f7834p);
        }
        if ((this.f7812o & 8) == 8) {
            eVar.r(4, this.f7816s);
        }
        if ((this.f7812o & 16) == 16) {
            eVar.p(5, this.f7817t);
        }
        for (int i2 = 0; i2 < this.f7818u.size(); i2++) {
            eVar.r(6, this.f7818u.get(i2));
        }
        for (int i3 = 0; i3 < this.f7819v.size(); i3++) {
            eVar.r(7, this.f7819v.get(i3));
        }
        eVar.u(this.f7811n);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f7821x;
        if (i2 != -1) {
            return i2;
        }
        int iC = (this.f7812o & 1) == 1 ? e.c(1, this.f7813p) + 0 : 0;
        if ((this.f7812o & 2) == 2) {
            iC += e.c(2, this.f7814q);
        }
        if ((this.f7812o & 4) == 4) {
            iC += e.b(3, this.f7815r.f7834p);
        }
        if ((this.f7812o & 8) == 8) {
            iC += e.e(4, this.f7816s);
        }
        if ((this.f7812o & 16) == 16) {
            iC += e.c(5, this.f7817t);
        }
        for (int i3 = 0; i3 < this.f7818u.size(); i3++) {
            iC += e.e(6, this.f7818u.get(i3));
        }
        for (int i4 = 0; i4 < this.f7819v.size(); i4++) {
            iC += e.e(7, this.f7819v.get(i4));
        }
        int size = this.f7811n.size() + iC;
        this.f7821x = size;
        return size;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a g() {
        return new b();
    }

    @Override // kotlin.reflect.w.internal.y0.i.q
    public final boolean i() {
        byte b2 = this.f7820w;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        if (((this.f7812o & 8) == 8) && !this.f7816s.i()) {
            this.f7820w = (byte) 0;
            return false;
        }
        for (int i2 = 0; i2 < this.f7818u.size(); i2++) {
            if (!this.f7818u.get(i2).i()) {
                this.f7820w = (byte) 0;
                return false;
            }
        }
        for (int i3 = 0; i3 < this.f7819v.size(); i3++) {
            if (!this.f7819v.get(i3).i()) {
                this.f7820w = (byte) 0;
                return false;
            }
        }
        this.f7820w = (byte) 1;
        return true;
    }

    public final void k() {
        this.f7813p = 0;
        this.f7814q = 0;
        this.f7815r = c.TRUE;
        this.f7816s = q.f7965m;
        this.f7817t = 0;
        this.f7818u = Collections.emptyList();
        this.f7819v = Collections.emptyList();
    }

    public h(h.b bVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(bVar);
        this.f7820w = (byte) -1;
        this.f7821x = -1;
        this.f7811n = bVar.f8259f;
    }
}
