package a.i.b.a.c.e;

import a.i.b.a.c.g.d;
import a.i.b.a.c.g.d.b;
import a.i.b.a.c.g.e;
import a.i.b.a.c.g.f;
import a.i.b.a.c.g.g;
import a.i.b.a.c.g.i;
import a.i.b.a.c.g.i.a;
import a.i.b.a.c.g.k;
import a.i.b.a.c.g.q;
import a.i.b.a.c.g.s;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.ttpic.baseutils.ApiHelper$VERSION_CODES;
import java.io.IOException;

public final class a$ak extends i implements a$al {
    public static s<a$ak> BsC = new 1();
    private static final a$ak BvR;
    private final d BsB;
    private int BsD;
    private byte BsG;
    private int BsH;
    public int BvS;
    public int BvT;
    public b BvU;
    public int BvV;
    public int BvW;
    public c BvX;

    /* synthetic */ a$ak(e eVar, g gVar, byte b) {
        this(eVar, gVar);
    }

    private a$ak(a aVar) {
        super((byte) 0);
        this.BsG = (byte) -1;
        this.BsH = -1;
        this.BsB = aVar.BsB;
    }

    private a$ak() {
        this.BsG = (byte) -1;
        this.BsH = -1;
        this.BsB = d.Bzq;
    }

    public static a$ak efY() {
        return BvR;
    }

    private a$ak(e eVar, g gVar) {
        AppMethodBeat.i(121031);
        this.BsG = (byte) -1;
        this.BsH = -1;
        ecA();
        b ehS = d.ehS();
        f e = f.e(ehS, 1);
        int i = 0;
        while (i == 0) {
            try {
                int vc = eVar.vc();
                int vd;
                switch (vc) {
                    case 0:
                        i = 1;
                        break;
                    case 8:
                        this.BsD |= 1;
                        this.BvS = eVar.vd();
                        break;
                    case ApiHelper$VERSION_CODES.JELLY_BEAN /*16*/:
                        this.BsD |= 2;
                        this.BvT = eVar.vd();
                        break;
                    case ApiHelper$VERSION_CODES.NOUGAT /*24*/:
                        vd = eVar.vd();
                        b Ud = b.Ud(vd);
                        if (Ud != null) {
                            this.BsD |= 4;
                            this.BvU = Ud;
                            break;
                        }
                        e.fw(vc);
                        e.fw(vd);
                        break;
                    case 32:
                        this.BsD |= 8;
                        this.BvV = eVar.vd();
                        break;
                    case 40:
                        this.BsD |= 16;
                        this.BvW = eVar.vd();
                        break;
                    case 48:
                        vd = eVar.vd();
                        c Ue = c.Ue(vd);
                        if (Ue != null) {
                            this.BsD |= 32;
                            this.BvX = Ue;
                            break;
                        }
                        e.fw(vc);
                        e.fw(vd);
                        break;
                    default:
                        if (!a(eVar, e, gVar, vc)) {
                            i = 1;
                            break;
                        }
                        break;
                }
            } catch (k e2) {
                e2.BzY = this;
                AppMethodBeat.o(121031);
                throw e2;
            } catch (IOException e3) {
                k kVar = new k(e3.getMessage());
                kVar.BzY = this;
                AppMethodBeat.o(121031);
                throw kVar;
            } catch (Throwable th) {
                try {
                    e.flush();
                    this.BsB = ehS.ehW();
                } catch (IOException e4) {
                    this.BsB = ehS.ehW();
                } catch (Throwable th2) {
                    this.BsB = ehS.ehW();
                    AppMethodBeat.o(121031);
                }
                eio();
                AppMethodBeat.o(121031);
            }
        }
        try {
            e.flush();
            this.BsB = ehS.ehW();
        } catch (IOException e5) {
            this.BsB = ehS.ehW();
        } catch (Throwable th3) {
            this.BsB = ehS.ehW();
            AppMethodBeat.o(121031);
        }
        eio();
        AppMethodBeat.o(121031);
    }

    static {
        AppMethodBeat.i(121036);
        a$ak a_ak = new a$ak();
        BvR = a_ak;
        a_ak.ecA();
        AppMethodBeat.o(121036);
    }

    public final s<a$ak> ecy() {
        return BsC;
    }

    public final boolean efZ() {
        return (this.BsD & 1) == 1;
    }

    public final boolean ega() {
        return (this.BsD & 2) == 2;
    }

    public final boolean egb() {
        return (this.BsD & 4) == 4;
    }

    public final boolean egc() {
        return (this.BsD & 8) == 8;
    }

    public final boolean egd() {
        return (this.BsD & 16) == 16;
    }

    public final boolean ege() {
        return (this.BsD & 32) == 32;
    }

    private void ecA() {
        this.BvS = 0;
        this.BvT = 0;
        this.BvU = b.BvZ;
        this.BvV = 0;
        this.BvW = 0;
        this.BvX = c.Bwc;
    }

    public final boolean isInitialized() {
        byte b = this.BsG;
        if (b == (byte) 1) {
            return true;
        }
        if (b == (byte) 0) {
            return false;
        }
        this.BsG = (byte) 1;
        return true;
    }

    public final void a(f fVar) {
        AppMethodBeat.i(121032);
        vq();
        if ((this.BsD & 1) == 1) {
            fVar.bq(1, this.BvS);
        }
        if ((this.BsD & 2) == 2) {
            fVar.bq(2, this.BvT);
        }
        if ((this.BsD & 4) == 4) {
            fVar.io(3, this.BvU.value);
        }
        if ((this.BsD & 8) == 8) {
            fVar.bq(4, this.BvV);
        }
        if ((this.BsD & 16) == 16) {
            fVar.bq(5, this.BvW);
        }
        if ((this.BsD & 32) == 32) {
            fVar.io(6, this.BvX.value);
        }
        fVar.d(this.BsB);
        AppMethodBeat.o(121032);
    }

    public final int vq() {
        AppMethodBeat.i(121033);
        int i = this.BsH;
        if (i != -1) {
            AppMethodBeat.o(121033);
            return i;
        }
        i = 0;
        if ((this.BsD & 1) == 1) {
            i = f.bs(1, this.BvS) + 0;
        }
        if ((this.BsD & 2) == 2) {
            i += f.bs(2, this.BvT);
        }
        if ((this.BsD & 4) == 4) {
            i += f.ip(3, this.BvU.value);
        }
        if ((this.BsD & 8) == 8) {
            i += f.bs(4, this.BvV);
        }
        if ((this.BsD & 16) == 16) {
            i += f.bs(5, this.BvW);
        }
        if ((this.BsD & 32) == 32) {
            i += f.ip(6, this.BvX.value);
        }
        i += this.BsB.size();
        this.BsH = i;
        AppMethodBeat.o(121033);
        return i;
    }

    public final /* synthetic */ q.a ecC() {
        AppMethodBeat.i(121034);
        a b = a.egh().b(this);
        AppMethodBeat.o(121034);
        return b;
    }

    public final /* synthetic */ q.a ecD() {
        AppMethodBeat.i(121035);
        a egh = a.egh();
        AppMethodBeat.o(121035);
        return egh;
    }

    public final /* bridge */ /* synthetic */ q ecE() {
        return BvR;
    }
}
