/*
 * Decompiled with CFR 0.152.
 */
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;

/*
 * Duplicate member names - consider using --renamedupmembers true
 */
public class be
extends cf {
    private static final int[][] b;
    private static final int[] S;
    private static final int[][] T;
    private static final int[][] U;
    private static final int[] V;
    private static final String a;
    private final Vector Y;
    private int W = -1;
    private byte X = (byte)-1;
    private boolean Z = false;
    private ps aa;
    private String ab = null;
    private String ac = null;

    public final boolean s() {
        this.aa = null;
        return true;
    }

    private boolean ag() {
        return this.z.i() == 3 && this.aa != null;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public boolean c(pb pb2) {
        this.w.b("");
        if (pb2.b() != '#') {
            int n;
            if (this.L() && pb2.b() == '9') {
                this.v.a(this.z.i());
            }
            ar ar2 = (ar)this.M();
            if (this.z != null && ar2 != null) {
                if (pb2.c == 8 && this.z.i() == 2) {
                    this.y();
                    this.d();
                    return true;
                }
                if (!ar2.s()) {
                    switch (ar2.b) {
                        default: {
                            n = 0;
                            break;
                        }
                        case 13: {
                            n = 0;
                            break;
                        }
                        case 0: {
                            n = 0;
                            break;
                        }
                        case 1: 
                        case 2: 
                        case 6: 
                        case 10: 
                        case 11: 
                        case 12: 
                        case 14: 
                        case 15: {
                            n = 1;
                            break;
                        }
                    }
                } else {
                    n = 1;
                }
                if (n != 0) {
                    if (pb2.c == 7 && this.z.i() == 1) {
                        n = 1;
                        this.A();
                        me.a((short)5, "0", String.valueOf(this.z.w()));
                        this.d();
                    } else {
                        n = 0;
                    }
                } else {
                    n = 0;
                }
            } else {
                n = 0;
            }
            if (n != 0) return true;
            if (pb2.c == 12 && this.H()) {
                this.g();
                return true;
            }
            n = 0;
            if (n != 0) return true;
            n = 0;
            int n2 = this.z.i();
            char c = pb2.b();
            if (n2 != 3) {
                boolean bl2 = this.ah();
                boolean bl3 = this.ai();
                if (!this.Z) {
                    if (c == this.t && bl2 && this.ae() && n2 != 0 || c == this.s && bl3 && this.af() && n2 != 0) {
                        this.Z = true;
                        this.z.a((byte)0);
                    } else if (c == this.t && (!bl2 || this.ae()) || c == this.s && (!bl3 || this.af())) {
                        n = 1;
                    }
                } else {
                    this.Z = false;
                    if (c == this.t && bl2) {
                        this.q();
                    } else if (c == this.s && bl3) {
                        this.r();
                    } else if (c != this.t && c != this.s) {
                        this.y();
                    } else {
                        n = 1;
                        this.y();
                    }
                }
                if (n == 0) return false;
                n = this.z.w();
                if (n2 != 0 || n == -1) {
                    while (this.z.c(n += (n2 = c == this.t ? -1 : 1)).a() == null && n > 0 && n < this.z.a()) {
                    }
                }
                if (n < 0) {
                    n = 0;
                }
                if ((n = Math.min(n, this.z.a() - 1)) < 0) return false;
                if (n >= this.z.a()) return false;
                this.b(n);
                this.a(true);
                return true;
            }
            if (c == this.t && this.ae()) {
                this.q();
                return true;
            } else {
                if (c != this.s) return true;
                if (!this.af()) return true;
                this.r();
            }
            return true;
        }
        if (this.z.i() == 3) {
            be.b("m", "#");
            String string = this.U();
            for (int i = 0; i < this.z.a(); ++i) {
                if (!string.equals(this.c(i))) {
                    continue;
                }
                this.b(i);
                this.a(false);
                break;
            }
            this.y();
            this.d();
            return true;
        }
        if (this.z.i() != 2) {
            be.b("l", "#");
            this.z();
            this.e(this.z.w());
            return true;
        }
        be.b("l", "#");
        this.y();
        return true;
    }

    /*
     * Enabled aggressive block sorting
     */
    public final String i() {
        String string;
        if (!lh.t()) {
            String string2;
            if (this.z.a() == 1) return null;
            if (this.S()) return null;
            if (!this.Z) {
                StringBuffer stringBuffer = new StringBuffer();
                if (this.ah() && !this.ae()) {
                    stringBuffer.append(lh.d(401));
                } else if (this.ai() && !this.af()) {
                    stringBuffer.append(lh.d(404));
                } else {
                    stringBuffer.append(lh.d(414));
                    stringBuffer.append("   ");
                    stringBuffer.append(lh.d(412));
                }
                if (stringBuffer.length() > 0) {
                    stringBuffer.append("\n");
                }
                stringBuffer.append(lh.d(15));
                if (stringBuffer.length() <= 0) return null;
                return stringBuffer.toString();
            }
            int n = ((ps)this.z).v();
            if (this.ah()) {
                string2 = lh.d(373);
                return ed.a(string2, Integer.toString(n));
            }
            if (n == 1) {
                string2 = lh.d(321);
                return ed.a(string2, Integer.toString(n));
            }
            string2 = lh.d(320);
            return ed.a(string2, Integer.toString(n));
        }
        if (!this.Z) return null;
        ps ps2 = (ps)this.z;
        if (this.ah()) {
            string = ed.a(lh.d(373), Integer.toString(ps2.g()));
            return string.replace('4', '\ued0f').replace('6', '\ued0c');
        }
        int n = ps2.v();
        string = n != 1 ? lh.d(320) : lh.d(321);
        string = ed.a(string, Integer.toString(n));
        return string.replace('4', '\ued0f').replace('6', '\ued0c');
    }

    public final void b() {
        int n;
        String string;
        this.B = this.u.a(false, true, lh.u());
        this.C = (hx)this.B.a();
        ps ps2 = (ps)this.z;
        w w2 = jj.a();
        new hc(4, 0, dz.a(this.C), w2, this.b(ps2), true).u = true;
        this.C.d(new hc(4, 0, dz.a(this.C), w2, this.b(ps2), true));
        switch (ps2.l) {
            case 8: {
                string = lh.d(375);
                break;
            }
            case 4: {
                string = lh.d(377);
                break;
            }
            case 1: {
                string = lh.d(376);
                break;
            }
            default: {
                string = null;
                break;
            }
            case 0: {
                string = lh.d(378);
            }
        }
        if (string != null) {
            this.a(jj.e(true), string, this.C);
        }
        if (!ed.b(string = ps2.s)) {
            this.a(this.F, ed.a(cf.p, string), this.C);
        }
        if (!ed.b(string = ps2.q())) {
            this.a(this.F, ar.h(string), this.C);
        }
        if (ps2.h && ps2.a > ps2.a()) {
            this.c(ed.a(this.i, new String[]{Integer.toString(ps2.q + 1), Integer.toString(ps2.q + this.z.a()), Integer.toString(ps2.a)}), this.C);
        }
        if (be.Z()) {
            this.a(this.c, this.C, 4).c(-5636096, -5636096);
        }
        jp jp2 = null;
        for (n = 0; n < this.z.a(); ++n) {
            jp jp3;
            ar ar2 = (ar)this.z.c(n);
            if (ar2.t() && ed.b(ar2.v())) {
                jp3 = null;
            } else {
                string = this.c(n);
                ar ar3 = (ar)this.z.c(n);
                Vector<w> vector = new Vector<w>(5);
                if (ar3.q()) {
                    vector.addElement(this.D);
                }
                vector.addElement(this.E);
                if (!ar3.t()) {
                    if (!ar3.q()) {
                        if (!ed.b(ar3.b())) {
                            vector.addElement(this.D);
                        }
                        if (!ed.b(ar3.c())) {
                            vector.addElement(this.D);
                        }
                    } else {
                        if (!ed.b(ar3.E())) {
                            vector.addElement(this.D);
                        }
                        if (!ed.b(ar3.F())) {
                            vector.addElement(this.D);
                        }
                    }
                } else {
                    String string2 = ar3.S();
                    if (!ed.b(string2) && !ar3.v().equals(string2)) {
                        vector.addElement(this.D);
                    }
                    vector.addElement(this.F);
                }
                if (ar3.X()) {
                    vector.addElement(this.F);
                }
                if (ar3.j()) {
                    vector.addElement(this.D);
                }
                Object[] objectArray = new w[vector.size()];
                vector.copyInto(objectArray);
                if (ar2.q()) {
                    jp3 = null;
                    this.a(string, this.C, 1, (w[])objectArray, ar2.d).h = true;
                    this.a(string, this.C, 1, (w[])objectArray, ar2.d).a(b, S, T, U, V);
                } else {
                    jp3 = this.a(string, this.C, 0, (w[])objectArray, null);
                }
            }
            if ((this.z.w() != n || jp3 == null) && (jp2 != null || jp3 == null)) continue;
            jp2 = jp3;
        }
        if (this.af() || this.ae() || this.L()) {
            this.W();
        }
        if (this.af()) {
            n = ((ps)this.z).v();
            string = n != 1 ? this.e : this.d;
            this.ab = ed.a(string, Integer.toString(n));
            this.a(this.ab, this.C, 4);
        }
        if (this.ae()) {
            ps2 = (ps)this.z;
            this.ac = ed.a(this.f, Integer.toString(ps2.g()));
            this.a(this.ac, this.C, 4);
        }
        if (this.L()) {
            this.a(this.g, this.C, 4).a('9', true);
        }
        if (jp2 != null && be.b(this.z)) {
            this.C.l(jp2);
        }
        this.C.d();
    }

    private String b(ps ps2) {
        if (ed.b(ps2.r)) {
            if (!ps2.b.startsWith("http:")) {
                if (!this.ae() && !this.af()) {
                    return ed.a(lh.d(400), ps2.b);
                }
                int n = 1;
                if (this.W > 0) {
                    n = 1 + ps2.g() * this.W;
                }
                int n2 = n - 1;
                for (int i = 0; i < this.z.a(); ++i) {
                    if (((ar)this.z.c(i)).q()) continue;
                    ++n2;
                }
                return ed.a(lh.d(406), new String[]{String.valueOf(n), String.valueOf(n2), ps2.b});
            }
            return cf.o;
        }
        return ps2.r;
    }

    public final void a(ps ps2, boolean n) {
        this.c(ps2);
        if (ps2.e) {
            this.w.b(ed.a(lh.d(523), new String[]{ps2.b, "" + ps2.a(), ps2.d}));
        }
        if (n != 0) {
            this.x.a(ps2.o, ps2.g);
            if (ps2.a() != 1 && be.b(ps2)) {
                dm dm2;
                this.v.n();
                this.x.a(ps2.n());
                n = this.a(ps2.n());
                if (n == -1 && ps2.a() > 0 && (dm2 = ((ar)ps2.c((int)0)).c) != null && dm2.a() == 3) {
                    n = 0;
                }
                if (((ar)ps2.c(n)).q()) {
                    ++n;
                }
                this.b(n);
                return;
            }
            this.b(0);
            this.a(true);
        }
    }

    private String c(int n) {
        ar ar2 = (ar)this.z.c(n);
        StringBuffer stringBuffer = new StringBuffer();
        if (ar2.q()) {
            stringBuffer.append(lh.d(476) + "\n");
        }
        stringBuffer.append(ar2.v());
        if (ar2.t()) {
            String string = ar2.S();
            if (!ed.b(string) && !ar2.v().equals(string)) {
                az.a(stringBuffer, "\n", string);
            }
            az.a(stringBuffer, "\n", cf.n);
        } else if (ar2.q()) {
            az.a(stringBuffer, "\n", ar2.E());
            az.a(stringBuffer, "\n", ar2.F());
        } else {
            az.a(stringBuffer, "\n", ar2.b());
            az.a(stringBuffer, "\n", ar2.c());
        }
        if (ar2.X()) {
            az.a(stringBuffer, "\n", cf.r);
        }
        if (ar2.j()) {
            az.a(stringBuffer, "\n", ar2.R());
        }
        return stringBuffer.toString();
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public void d_() {
        aa aa2 = lh.k().f();
        ps ps2 = this.z instanceof ps ? (ps)this.z : null;
        if (ps2 != null && ps2.l == 2) {
            try {
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                ps2.b(new DataOutputStream(byteArrayOutputStream));
                aa2.b(byteArrayOutputStream.toByteArray(), "PROTO_SAVED_SEARCH_DB");
                ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                cw.a(ps2.i, new DataOutputStream(byteArrayOutputStream2));
                aa2.a("SAVED_SEARCH_INFO", byteArrayOutputStream2.toByteArray());
                return;
            }
            catch (IOException iOException) {
                return;
            }
            catch (OutOfMemoryError outOfMemoryError) {
                me.b("UI-SL save", outOfMemoryError);
                return;
            }
        }
        aa2.b("PROTO_SAVED_SEARCH_DB");
        aa2.b("SAVED_SEARCH_INFO");
    }

    public final void e_() {
        byte[] byArray;
        DataInput dataInput;
        Object object = lh.k().f();
        if (gu.g().t()) {
            object.a("SAVED_SEARCH_1", null);
            object.b("SAVED_SEARCH_1_DB");
        }
        if ((dataInput = nz.a((aa)object, "PROTO_SAVED_SEARCH_DB")) != null && (byArray = object.g("SAVED_SEARCH_INFO")) != null) {
            try {
                object = new DataInputStream(new ByteArrayInputStream(byArray));
                ps ps2 = ps.b(dataInput);
                ps2.i = cw.b((DataInput)object);
                ps2.a(true);
                if (ps2.o()) {
                    this.v.a.a(new oo(this, ps2));
                }
                return;
            }
            catch (IOException iOException) {
                me.a("UI-SL load", iOException);
            }
        }
    }

    public final void a(hh hh2) {
        this.G.a((fb[])null);
        boolean bl2 = this.z != hh2;
        this.z = hh2;
        if (bl2) {
            this.d_();
        }
        if (hh2 != null) {
            this.v.a(this);
            if (this.X == -1) {
                if (hh2.a() != 1 && be.b(hh2)) {
                    this.z();
                } else {
                    this.y();
                }
            } else {
                this.a(this.X);
            }
            this.d();
            this.O();
            this.G.a(((ps)hh2).r());
        }
    }

    public final void a(ht ht2) {
        if (lh.t()) {
            fe fe2 = this.J;
            boolean bl2 = this.ae() || !this.ah() || this.z.i() == 0;
            fe2.a = bl2;
            fe2 = this.I;
            bl2 = this.af() || !this.ai();
            fe2.a = bl2;
            this.I.a(ht2, 0, 0);
            this.J.a(ht2, 0, 0);
            if (lh.u()) {
                this.K.a = true;
                this.K.a(ht2, 0, 0);
            }
        }
    }

    public final void a() {
        if (this.z.i() == 3 && this.z.w() != -1) {
            int n = this.z.w();
            int n2 = be.Z() ? 1 : 0;
            this.C.l(dz.a((fs)this.C, n + n2));
        }
    }

    public final void j() {
        be.b("b", "");
        if (this.z.i() == 2 && this.H) {
            this.z();
            this.e(this.z.w());
            return;
        }
        if (this.ag()) {
            this.o();
            this.a(this.aa);
            this.c(this.aa);
            this.s();
            this.v.a((byte)3);
            return;
        }
        this.k();
    }

    public final void g() {
        String string = this.U();
        for (int i = 0; i < this.z.a(); ++i) {
            if (!string.equals(this.c(i))) {
                continue;
            }
            be.b("m", String.valueOf(i));
            this.b(i);
            this.a(false);
            this.A();
            this.H = true;
            return;
        }
        super.g();
    }

    private void e(int n) {
        if (n != -1) {
            String string = this.c(n);
            for (n = 0; n < this.C.m(); ++n) {
                gm gm2 = this.C.h(n);
                if (!(gm2 instanceof cu) || !((cu)gm2).c().equals(string)) {
                    continue;
                }
                this.C.l(gm2);
                this.C.d();
                break;
            }
        }
    }

    private jp a(String string, hx hx2, int n, w[] wArray, le le2) {
        lc lc2 = this.u.k;
        jp jp2 = !lh.t() ? new bb(0, 0, dz.a(hx2), 4, 0, this.D, string, lc2, n, wArray, le2) : new jp(0, 0, dz.a(hx2), 4, 0, this.D, string, false, lc2, n, wArray, le2);
        jp2.u = true;
        hx2.d(jp2);
        return jp2;
    }

    private void a(boolean bl2) {
        iv iv2;
        block3: {
            block2: {
                ar ar2 = (ar)this.M();
                if (ar2 == null || (iv2 = ar2.a()) == null) break block2;
                if (!bl2) break block3;
                this.v.a(iv2, false);
            }
            return;
        }
        this.v.n();
        this.x.a(iv2);
    }

    public final void k() {
        int n = this.a(this.x.d());
        if (n != -1) {
            this.y();
            this.z.b(n);
        } else {
            this.z.a((byte)0);
        }
        this.d();
    }

    public final void d() {
        short s;
        super.d();
        if (this.M() != null && (s = this.z.i()) != 0) {
            s = s == 1 ? (short)33 : 34;
            this.a(s);
        }
    }

    private void ad() {
        byte by2 = this.f((int)this.W).p;
        if (by2 == 0) {
            by2 = 1;
        }
        this.X = by2;
    }

    public final void af() {
        super.af();
        if (this.Y.size() != 0) {
            ps ps2 = this.f(this.W);
            this.Y.removeAllElements();
            this.s();
            this.a(ps2);
        }
    }

    /*
     * Enabled aggressive block sorting
     */
    private boolean af() {
        ps ps2 = this.f(this.W);
        return !(ps2.h && ps2.a != -1 ? ps2.q + ps2.a() >= ps2.a : ps2.a() < ps2.g());
    }

    public final boolean q() {
        if (this.ae()) {
            this.ad();
            this.s();
            ps ps2 = this.f(this.W);
            ps ps3 = this.f(--this.W);
            if (ps3 != null) {
                this.a(ps3, true);
                if (this.X != 3) {
                    this.b(ps3.a() - 1);
                    this.a(true);
                    return true;
                }
            } else {
                this.v.a(ps2.a(ps2.g() * this.W), true);
            }
            return true;
        }
        return false;
    }

    public final boolean r() {
        if (this.af()) {
            this.ad();
            this.s();
            if (this.W >= this.Y.size() - 1) {
                ps ps2 = this.f(this.W);
                this.v.a(ps2.a(ps2.g() * (this.W + 1)), true);
                return true;
            }
            this.a(this.f(++this.W), true);
            return true;
        }
        return false;
    }

    public final int b(pz pz2) {
        switch (pz2.l()) {
            case 12: {
                return -this.u.a(pz2.l());
            }
            case 15: {
                return 1 - this.d(pz2) / 2;
            }
            case 0: {
                return 0;
            }
        }
        return 1 - this.d(pz2);
    }

    public final int a(pz pz2) {
        switch (pz2.l()) {
            case 12: {
                return -this.u.b(pz2.l()) / 2;
            }
            case 0: {
                return 0;
            }
        }
        return this.c(pz2) / 4;
    }

    private boolean ai() {
        for (int i = this.z.w() + 1; i < this.z.a(); ++i) {
            if (this.z.c(i).a() == null) {
                continue;
            }
            return false;
        }
        return true;
    }

    private boolean ah() {
        block2: {
            for (int i = this.z.w() - 1; i >= 0; --i) {
                if (this.z.c(i).a() == null) {
                    continue;
                }
                break block2;
            }
            return true;
        }
        return false;
    }

    private static boolean b(hh hh2) {
        for (int i = 0; i < hh2.a(); ++i) {
            if (ed.b(((ar)hh2.c(i)).v())) {
                continue;
            }
            return true;
        }
        return false;
    }

    public final boolean a(short s) {
        if (this.z != null) {
            return ((ps)this.z).a(s);
        }
        return false;
    }

    private boolean ae() {
        return this.W > 0;
    }

    public cq m() {
        if (this.z.i() != 2 && !this.ag()) {
            return super.m();
        }
        return jy.g;
    }

    public cq n() {
        if (lh.t() && !lh.u()) {
            if (!this.S()) {
                return jy.r;
            }
            return jy.q;
        }
        return super.n();
    }

    public final ft e() {
        String string = lh.t() ? lh.d(541) : lh.d(123);
        if (lh.v()) {
            string = lh.d(124);
        }
        return this.c(string);
    }

    public final boolean a(nj nj2) {
        if (super.a(nj2)) {
            return true;
        }
        this.Z = false;
        return false;
    }

    public final void a(String string, String string2, String string3, String string4, iv iv2, int n, int n2) {
        if (n == 0) {
            n = this.x.k();
        }
        if (n2 == 0) {
            n2 = this.x.l();
        }
        ar ar2 = new ar(iv2, string, string2, string3, string4, 1);
        this.a(new ps(new ar[]{ar2}, this.x.e.a(ar2.a()), n, n2), true);
    }

    public be(gd gd2, ck ck2, lh lh2, jt jt2) {
        super(gd2, ck2, lh2, jt2);
        this.Y = new Vector();
        nz.a(this);
    }

    public final void o() {
        super.o();
        this.Y.removeAllElements();
        this.W = -1;
        this.X = (byte)-1;
        this.Z = false;
    }

    static {
        a = lh.d(420);
        b = new int[][]{{0xFFFFFD, 0xFEFFF5, 16580584}, {0xFEFFF5, 15987904, 14274940}, {16580584, 14143355, 15197102}};
        S = new int[]{16515038, 13747822, 0xFAFADF};
        T = new int[][]{{16383962, 16383706}, {13616237, 10588748}, {16317147, 16052932}};
        U = new int[][]{{16449251, 11510878, 13813650}, {16645875, 14803628, 11379549}, {0xFFFFFD, 16382700, 15659986}};
        V = new int[]{16052938, 10457163, 15594695};
    }

    public final void a(ps ps2) {
        int n = ps2.s();
        this.Y.setSize(n + 1);
        int n2 = n;
        this.Y.setElementAt(ps2, n2);
        this.W = n2;
    }

    public final void f_() {
        this.aa = this.f(this.W);
    }

    public final String u() {
        return this.ac;
    }

    public final String t() {
        return this.ab;
    }

    public final String l() {
        return a;
    }

    private ps f(int n) {
        return (ps)this.Y.elementAt(n);
    }

    private static void b(String string, String string2) {
        me.a((short)5, "v", me.a(new String[]{"v=" + string, "s=" + string2}));
    }
}

