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.l;
import kotlin.reflect.w.internal.y0.g.o;
import kotlin.reflect.w.internal.y0.g.p;
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.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 m extends h.d<m> implements q {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final m f7890m;

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

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

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

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

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

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

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public List<c> f7897t;

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

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

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

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

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

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public p f7901p = p.f7957f;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public o f7902q = o.f7931f;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        public l f7903r = l.f7873m;

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

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

        @Override // r.i0.w.b.y0.i.h.b
        public Object clone() {
            b bVar = new b();
            bVar.o(n());
            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 {
            p(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 {
            p(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.o(n());
            return bVar;
        }

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

        public m n() {
            m mVar = new m(this, null);
            int i2 = this.f7900o;
            int i3 = (i2 & 1) != 1 ? 0 : 1;
            mVar.f7894q = this.f7901p;
            if ((i2 & 2) == 2) {
                i3 |= 2;
            }
            mVar.f7895r = this.f7902q;
            if ((i2 & 4) == 4) {
                i3 |= 4;
            }
            mVar.f7896s = this.f7903r;
            if ((i2 & 8) == 8) {
                this.f7904s = Collections.unmodifiableList(this.f7904s);
                this.f7900o &= -9;
            }
            mVar.f7897t = this.f7904s;
            mVar.f7893p = i3;
            return mVar;
        }

        public b o(m mVar) {
            l lVar;
            o oVar;
            p pVar;
            if (mVar == m.f7890m) {
                return this;
            }
            if ((mVar.f7893p & 1) == 1) {
                p pVarM = mVar.f7894q;
                if ((this.f7900o & 1) == 1 && (pVar = this.f7901p) != p.f7957f) {
                    p.b bVar = new p.b();
                    bVar.n(pVar);
                    bVar.n(pVarM);
                    pVarM = bVar.m();
                }
                this.f7901p = pVarM;
                this.f7900o |= 1;
            }
            if ((mVar.f7893p & 2) == 2) {
                o oVarM = mVar.f7895r;
                if ((this.f7900o & 2) == 2 && (oVar = this.f7902q) != o.f7931f) {
                    o.b bVar2 = new o.b();
                    bVar2.n(oVar);
                    bVar2.n(oVarM);
                    oVarM = bVar2.m();
                }
                this.f7902q = oVarM;
                this.f7900o |= 2;
            }
            if ((mVar.f7893p & 4) == 4) {
                l lVarN = mVar.f7896s;
                if ((this.f7900o & 4) == 4 && (lVar = this.f7903r) != l.f7873m) {
                    l.b bVar3 = new l.b();
                    bVar3.o(lVar);
                    bVar3.o(lVarN);
                    lVarN = bVar3.n();
                }
                this.f7903r = lVarN;
                this.f7900o |= 4;
            }
            if (!mVar.f7897t.isEmpty()) {
                if (this.f7904s.isEmpty()) {
                    this.f7904s = mVar.f7897t;
                    this.f7900o &= -9;
                } else {
                    if ((this.f7900o & 8) != 8) {
                        this.f7904s = new ArrayList(this.f7904s);
                        this.f7900o |= 8;
                    }
                    this.f7904s.addAll(mVar.f7897t);
                }
            }
            m(mVar);
            this.f8259f = this.f8259f.b(mVar.f7892o);
            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.m.b p(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.m> r1 = kotlin.reflect.w.internal.y0.g.m.f7891n     // 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.m r3 = (kotlin.reflect.w.internal.y0.g.m) r3     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                if (r3 == 0) goto Le
                r2.o(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.m r4 = (kotlin.reflect.w.internal.y0.g.m) 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.o(r0)
            L1e:
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: r.i0.w.b.y0.g.m.b.p(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.m$b");
        }
    }

    static {
        m mVar = new m();
        f7890m = mVar;
        mVar.f7894q = p.f7957f;
        mVar.f7895r = o.f7931f;
        mVar.f7896s = l.f7873m;
        mVar.f7897t = Collections.emptyList();
    }

    public m() {
        this.f7898u = (byte) -1;
        this.f7899v = -1;
        this.f7892o = c.f8234f;
    }

    public m(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        int i2;
        this.f7898u = (byte) -1;
        this.f7899v = -1;
        this.f7894q = p.f7957f;
        this.f7895r = o.f7931f;
        this.f7896s = l.f7873m;
        this.f7897t = Collections.emptyList();
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        int i3 = 0;
        while (!z2) {
            try {
                try {
                    int iO = dVar.o();
                    if (iO != 0) {
                        o.b bVar = null;
                        p.b bVar2 = null;
                        l.b bVar3 = null;
                        if (iO != 10) {
                            if (iO == 18) {
                                i2 = 2;
                                if ((this.f7893p & 2) == 2) {
                                    o oVar = this.f7895r;
                                    Objects.requireNonNull(oVar);
                                    bVar = new o.b();
                                    bVar.n(oVar);
                                }
                                o oVar2 = (o) dVar.h(o.f7932m, fVar);
                                this.f7895r = oVar2;
                                if (bVar != null) {
                                    bVar.n(oVar2);
                                    this.f7895r = bVar.m();
                                }
                            } else if (iO == 26) {
                                i2 = 4;
                                if ((this.f7893p & 4) == 4) {
                                    l lVar = this.f7896s;
                                    Objects.requireNonNull(lVar);
                                    bVar3 = new l.b();
                                    bVar3.o(lVar);
                                }
                                l lVar2 = (l) dVar.h(l.f7874n, fVar);
                                this.f7896s = lVar2;
                                if (bVar3 != null) {
                                    bVar3.o(lVar2);
                                    this.f7896s = bVar3.n();
                                }
                            } else if (iO == 34) {
                                int i4 = (i3 == true ? 1 : 0) & 8;
                                i3 = i3;
                                if (i4 != 8) {
                                    this.f7897t = new ArrayList();
                                    i3 = (i3 == true ? 1 : 0) | 8;
                                }
                                this.f7897t.add((c) dVar.h(c.f7720n, fVar));
                            } else if (!q(dVar, eVarK, fVar, iO)) {
                            }
                            this.f7893p |= i2;
                        } else {
                            if ((this.f7893p & 1) == 1) {
                                p pVar = this.f7894q;
                                Objects.requireNonNull(pVar);
                                bVar2 = new p.b();
                                bVar2.n(pVar);
                            }
                            p pVar2 = (p) dVar.h(p.f7958m, fVar);
                            this.f7894q = pVar2;
                            if (bVar2 != null) {
                                bVar2.n(pVar2);
                                this.f7894q = bVar2.m();
                            }
                            this.f7893p |= 1;
                        }
                    }
                    z2 = true;
                } catch (Throwable th) {
                    if (((i3 == true ? 1 : 0) & 8) == 8) {
                        this.f7897t = Collections.unmodifiableList(this.f7897t);
                    }
                    try {
                        eVarK.j();
                    } catch (IOException unused) {
                    } catch (Throwable th2) {
                        this.f7892o = bVarN.d();
                        throw th2;
                    }
                    this.f7892o = bVarN.d();
                    this.f8262f.i();
                    throw th;
                }
            } catch (j e2) {
                e2.f8275f = this;
                throw e2;
            } catch (IOException e3) {
                j jVar = new j(e3.getMessage());
                jVar.f8275f = this;
                throw jVar;
            }
        }
        if (((i3 == true ? 1 : 0) & 8) == 8) {
            this.f7897t = Collections.unmodifiableList(this.f7897t);
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f7892o = bVarN.d();
            throw th3;
        }
        this.f7892o = bVarN.d();
        this.f8262f.i();
    }

    @Override // kotlin.reflect.w.internal.y0.i.q
    public kotlin.reflect.w.internal.y0.i.p b() {
        return f7890m;
    }

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

    @Override // kotlin.reflect.w.internal.y0.i.p
    public void d(e eVar) throws IOException {
        f();
        h.d<MessageType>.a aVarP = p();
        if ((this.f7893p & 1) == 1) {
            eVar.r(1, this.f7894q);
        }
        if ((this.f7893p & 2) == 2) {
            eVar.r(2, this.f7895r);
        }
        if ((this.f7893p & 4) == 4) {
            eVar.r(3, this.f7896s);
        }
        for (int i2 = 0; i2 < this.f7897t.size(); i2++) {
            eVar.r(4, this.f7897t.get(i2));
        }
        aVarP.a(200, eVar);
        eVar.u(this.f7892o);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f7899v;
        if (i2 != -1) {
            return i2;
        }
        int iE = (this.f7893p & 1) == 1 ? e.e(1, this.f7894q) + 0 : 0;
        if ((this.f7893p & 2) == 2) {
            iE += e.e(2, this.f7895r);
        }
        if ((this.f7893p & 4) == 4) {
            iE += e.e(3, this.f7896s);
        }
        for (int i3 = 0; i3 < this.f7897t.size(); i3++) {
            iE += e.e(4, this.f7897t.get(i3));
        }
        int size = this.f7892o.size() + l() + iE;
        this.f7899v = 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.f7898u;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        if (((this.f7893p & 2) == 2) && !this.f7895r.i()) {
            this.f7898u = (byte) 0;
            return false;
        }
        if (((this.f7893p & 4) == 4) && !this.f7896s.i()) {
            this.f7898u = (byte) 0;
            return false;
        }
        for (int i2 = 0; i2 < this.f7897t.size(); i2++) {
            if (!this.f7897t.get(i2).i()) {
                this.f7898u = (byte) 0;
                return false;
            }
        }
        if (k()) {
            this.f7898u = (byte) 1;
            return true;
        }
        this.f7898u = (byte) 0;
        return false;
    }

    public m(h.c cVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(cVar);
        this.f7898u = (byte) -1;
        this.f7899v = -1;
        this.f7892o = cVar.f8259f;
    }
}
