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

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import kotlin.reflect.w.internal.y0.i.a;
import kotlin.reflect.w.internal.y0.i.c;
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 d extends h.d<d> implements q {

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

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

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

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

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

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

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public List<Integer> f7760s;

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

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

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

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

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

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

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

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

        @Override // r.i0.w.b.y0.i.p.a
        public p a() {
            d dVarN = n();
            if (dVarN.i()) {
                return dVarN;
            }
            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(kotlin.reflect.w.internal.y0.i.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(kotlin.reflect.w.internal.y0.i.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((d) hVar);
            return this;
        }

        public d n() {
            d dVar = new d(this, null);
            int i2 = this.f7763o;
            int i3 = (i2 & 1) != 1 ? 0 : 1;
            dVar.f7758q = this.f7764p;
            if ((i2 & 2) == 2) {
                this.f7765q = Collections.unmodifiableList(this.f7765q);
                this.f7763o &= -3;
            }
            dVar.f7759r = this.f7765q;
            if ((this.f7763o & 4) == 4) {
                this.f7766r = Collections.unmodifiableList(this.f7766r);
                this.f7763o &= -5;
            }
            dVar.f7760s = this.f7766r;
            dVar.f7757p = i3;
            return dVar;
        }

        public b o(d dVar) {
            if (dVar == d.f7754m) {
                return this;
            }
            if ((dVar.f7757p & 1) == 1) {
                int i2 = dVar.f7758q;
                this.f7763o = 1 | this.f7763o;
                this.f7764p = i2;
            }
            if (!dVar.f7759r.isEmpty()) {
                if (this.f7765q.isEmpty()) {
                    this.f7765q = dVar.f7759r;
                    this.f7763o &= -3;
                } else {
                    if ((this.f7763o & 2) != 2) {
                        this.f7765q = new ArrayList(this.f7765q);
                        this.f7763o |= 2;
                    }
                    this.f7765q.addAll(dVar.f7759r);
                }
            }
            if (!dVar.f7760s.isEmpty()) {
                if (this.f7766r.isEmpty()) {
                    this.f7766r = dVar.f7760s;
                    this.f7763o &= -5;
                } else {
                    if ((this.f7763o & 4) != 4) {
                        this.f7766r = new ArrayList(this.f7766r);
                        this.f7763o |= 4;
                    }
                    this.f7766r.addAll(dVar.f7760s);
                }
            }
            m(dVar);
            this.f8259f = this.f8259f.b(dVar.f7756o);
            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.d.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.d> r1 = kotlin.reflect.w.internal.y0.g.d.f7755n     // 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.d r3 = (kotlin.reflect.w.internal.y0.g.d) 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.d r4 = (kotlin.reflect.w.internal.y0.g.d) 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.d.b.p(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.d$b");
        }
    }

    static {
        d dVar = new d();
        f7754m = dVar;
        dVar.f7758q = 6;
        dVar.f7759r = Collections.emptyList();
        dVar.f7760s = Collections.emptyList();
    }

    public d() {
        this.f7761t = (byte) -1;
        this.f7762u = -1;
        this.f7756o = c.f8234f;
    }

    public d(kotlin.reflect.w.internal.y0.i.d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        List list;
        Object objH;
        this.f7761t = (byte) -1;
        this.f7762u = -1;
        this.f7758q = 6;
        this.f7759r = Collections.emptyList();
        this.f7760s = Collections.emptyList();
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        int i2 = 0;
        while (!z2) {
            try {
                try {
                    int iO = dVar.o();
                    if (iO != 0) {
                        if (iO != 8) {
                            if (iO == 18) {
                                if ((i2 & 2) != 2) {
                                    this.f7759r = new ArrayList();
                                    i2 |= 2;
                                }
                                list = this.f7759r;
                                objH = dVar.h(u.f8071n, fVar);
                            } else if (iO == 248) {
                                if ((i2 & 4) != 4) {
                                    this.f7760s = new ArrayList();
                                    i2 |= 4;
                                }
                                list = this.f7760s;
                                objH = Integer.valueOf(dVar.l());
                            } else if (iO == 250) {
                                int iD = dVar.d(dVar.l());
                                if ((i2 & 4) != 4 && dVar.b() > 0) {
                                    this.f7760s = new ArrayList();
                                    i2 |= 4;
                                }
                                while (dVar.b() > 0) {
                                    this.f7760s.add(Integer.valueOf(dVar.l()));
                                }
                                dVar.f8248i = iD;
                                dVar.p();
                            } else if (!q(dVar, eVarK, fVar, iO)) {
                            }
                            list.add(objH);
                        } else {
                            this.f7757p |= 1;
                            this.f7758q = dVar.l();
                        }
                    }
                    z2 = true;
                } catch (j e2) {
                    e2.f8275f = this;
                    throw e2;
                } catch (IOException e3) {
                    j jVar = new j(e3.getMessage());
                    jVar.f8275f = this;
                    throw jVar;
                }
            } catch (Throwable th) {
                if ((i2 & 2) == 2) {
                    this.f7759r = Collections.unmodifiableList(this.f7759r);
                }
                if ((i2 & 4) == 4) {
                    this.f7760s = Collections.unmodifiableList(this.f7760s);
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f7756o = bVarN.d();
                    throw th2;
                }
                this.f7756o = bVarN.d();
                this.f8262f.i();
                throw th;
            }
        }
        if ((i2 & 2) == 2) {
            this.f7759r = Collections.unmodifiableList(this.f7759r);
        }
        if ((i2 & 4) == 4) {
            this.f7760s = Collections.unmodifiableList(this.f7760s);
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f7756o = bVarN.d();
            throw th3;
        }
        this.f7756o = bVarN.d();
        this.f8262f.i();
    }

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

    @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.f7757p & 1) == 1) {
            eVar.p(1, this.f7758q);
        }
        for (int i2 = 0; i2 < this.f7759r.size(); i2++) {
            eVar.r(2, this.f7759r.get(i2));
        }
        for (int i3 = 0; i3 < this.f7760s.size(); i3++) {
            eVar.p(31, this.f7760s.get(i3).intValue());
        }
        aVarP.a(19000, eVar);
        eVar.u(this.f7756o);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f7762u;
        if (i2 != -1) {
            return i2;
        }
        int iC = (this.f7757p & 1) == 1 ? e.c(1, this.f7758q) + 0 : 0;
        for (int i3 = 0; i3 < this.f7759r.size(); i3++) {
            iC += e.e(2, this.f7759r.get(i3));
        }
        int iD = 0;
        for (int i4 = 0; i4 < this.f7760s.size(); i4++) {
            iD += e.d(this.f7760s.get(i4).intValue());
        }
        int size = this.f7756o.size() + l() + (this.f7760s.size() * 2) + iC + iD;
        this.f7762u = 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.f7761t;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        for (int i2 = 0; i2 < this.f7759r.size(); i2++) {
            if (!this.f7759r.get(i2).i()) {
                this.f7761t = (byte) 0;
                return false;
            }
        }
        if (k()) {
            this.f7761t = (byte) 1;
            return true;
        }
        this.f7761t = (byte) 0;
        return false;
    }

    public d(h.c cVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(cVar);
        this.f7761t = (byte) -1;
        this.f7762u = -1;
        this.f7756o = cVar.f8259f;
    }
}
