/*
 * Decompiled with CFR 0.152.
 */
public final class cx
extends mi {
    private final lh d;
    private final ck e;
    private final gd f;
    private final lh g;
    private final fe k;
    private static int b = 2;
    private static int c = 3;
    private boolean h;
    private ft i;
    private int j;
    private boolean l;
    public boolean a;

    public final iv n() {
        return this.x();
    }

    private static int q() {
        ps ps2 = ps.a();
        return ps2.b - (ps2.g + ps2.h());
    }

    private static int p() {
        ps ps2 = ps.a();
        return ps2.a - ps2.i();
    }

    private int z() {
        return this.e.c().a(this.d.f());
    }

    private iv x() {
        if (this.w()) {
            return gu.i().c(this.d.m());
        }
        return this.d.m();
    }

    private String a(String string) {
        fy fy2;
        if (gu.g().c() && (fy2 = this.d.a()) != null && !ed.b(fy2.a)) {
            return string + " " + fy2.a;
        }
        return string;
    }

    public final void b(ht ht2) {
        if (this.k != null && this.d.m() && je.p()) {
            this.k.a(ht2, 0, 0);
        }
    }

    public final void o() {
        if (lh.t()) {
            this.k.a();
        }
    }

    private boolean u() {
        return this.i != null;
    }

    private boolean w() {
        return gu.aa() && !this.e.m();
    }

    public final boolean a() {
        return this.d.o() && (this.d.n() || !this.d.i() && this.d.m());
    }

    public final boolean d() {
        return this.d.m() && this.d.i();
    }

    private boolean y() {
        return this.d.i() && this.d.f() > 30 && this.z() > 8;
    }

    public final int g() {
        if (this.y()) {
            return this.x().hashCode() * 29 + this.d.f();
        }
        return 0;
    }

    public final int j() {
        if (this.d.i()) {
            return this.d.f() * 2;
        }
        return 0;
    }

    public final int k() {
        if (this.d.i()) {
            return this.d.f() * 2;
        }
        return 0;
    }

    public final void a(boolean bl2) {
        if (bl2 && this.d.i()) {
            this.l = true;
        }
        this.b(false);
    }

    public final boolean a(nj nj2) {
        if (this.k != null) {
            switch (this.k.b(nj2)) {
                case 3: {
                    this.b(false);
                }
                case -2: {
                    return true;
                }
            }
        }
        return false;
    }

    public final boolean a(pb pb2) {
        if (this.f.j() && this.u()) {
            if (pb2.c == 7) {
                this.f.a(lh.d(312));
            }
            this.i = null;
            return true;
        }
        if (pb2.b() == '0') {
            this.a(false);
            return true;
        }
        return false;
    }

    public final void c() {
        if (this.u()) {
            this.s();
        }
        if (this.k != null) {
            ps ps2 = ps.a();
            this.k.d(cx.p(), cx.q(), ps2.i(), ps2.h());
        }
    }

    public cx(lh lh2, gd gd2, ck ck2, lh lh3) {
        this.d = lh2;
        this.f = gd2;
        this.e = ck2;
        this.g = lh3;
        if (lh.t()) {
            this.k = new fe(cx.p(), cx.q(), '\ued39', '\ued3a');
        }
    }

    public final void h() {
        this.a = false;
        this.i = null;
        if (this.l && this.f.j() && !lh.t()) {
            this.g.a(lh.d(261), 2);
            this.l = false;
        }
    }

    public final boolean e() {
        if (this.d.i() && this.h) {
            if (this.j == 0 && !this.a && this.f.j() && !lh.t()) {
                this.g.a(lh.d(261), 2);
                this.j = 1;
                return true;
            }
            if (this.j == b && this.d.n() && !this.g.a() && this.f.j()) {
                this.j = c;
                if (!lh.t()) {
                    this.g.a(lh.d(256), 2);
                }
                return true;
            }
        }
        return false;
    }

    private void s() {
        ob ob2 = lh.k().h();
        w w2 = ob2.a(1, false, false, -16777216, false);
        w w3 = ob2.a(1, true, false, -16777216, false);
        String string = lh.t() ? lh.d(543) : lh.d(264);
        String[] stringArray = ed.a(string, '\n');
        ps ps2 = ps.a();
        this.i = ps2.a(stringArray, new w[]{w3, w2, w2}, ps2.a / 2, ps2.b / 2);
        this.l = true;
        nz.a("GPS_FIX", true);
    }

    public final void a(ht ht2) {
        if (this.y() && !gu.p()) {
            cn cn2 = this.e.c();
            oa oa2 = this.e.b(this.x());
            int n = cn2.a(this.k());
            int n2 = cn2.a(this.j());
            oa2.a -= n / 2;
            oa2.b -= n2 / 2;
            ps.a();
            ps.a(ht2, oa2, n, n2, this.i(), this.m());
        }
    }

    public final void a(ht ht2, int n) {
        block4: {
            oa oa2;
            block5: {
                block3: {
                    if (!this.d()) break block3;
                    ps.a();
                    if (!ps.f()) break block4;
                    oa2 = this.e.b(this.x());
                    le le2 = ps.f[n % ps.f.length];
                    int n2 = le2.b();
                    ht2.a(le2, oa2.a - n2 / 2, oa2.b - n2 / 2);
                    if (this.d.e() >= 1) {
                        n = 90 - this.d.c();
                        if (n < 0) {
                            n += 360;
                        }
                        int n3 = -n2 * ck.i(n) * 4 / 3;
                        n = n2 * ck.h(n) * 4 / 3;
                        n2 = ck.a(n3, 250);
                        n = ck.a(n, 250);
                        n3 = ck.a(n * 3, 8);
                        int n4 = ck.a(n2 * 3, 8);
                        int n5 = -n2 / 4 + n3;
                        int n6 = n / 4 + n4;
                        n3 = n2 / 4 + n3;
                        n4 = -n / 4 + n4;
                        ht2.a(27567);
                        ht2.e(oa2.a + n, oa2.b + n2, oa2.a + n5, oa2.b + n6, oa2.a + n3, oa2.b + n4);
                        ht2.a(40191);
                        ht2.f(oa2.a + n, oa2.b + n2, oa2.a + n5, oa2.b + n6, oa2.a + n3, oa2.b + n4);
                    }
                    break block5;
                }
                this.i = null;
            }
            if (this.u()) {
                oa2 = this.e.b(this.x());
                this.i.d(oa2.a + 3, oa2.b - 3);
                n = (ps.a().n() - this.i.r) / 2;
                this.i.a(ht2, n, 0);
            }
        }
    }

    /*
     * Enabled aggressive block sorting
     */
    private void b(boolean n) {
        if (this.d.i()) {
            this.a = true;
            iu iu2 = this.f.j.a();
            if (iu2 != null) {
                iu2.P();
            }
            if (n != 0) {
                this.e.a(cn.b(15));
                if (ck.f(this.d.m())) {
                    this.e.a(cn.b(19));
                }
            }
            while ((n = this.z()) > ps.a().b / 2 || n > ps.a().a / 2) {
                this.e.a(this.e.c().b());
            }
            iv iv2 = this.x();
            this.f.a(iv2, true);
            if (this.j == 0 || this.j == 1 || this.j == b || this.d.n() || this.j == c && !this.d.n()) {
                n = this.d.f();
                if (n >= 0) {
                    if (this.w() && !gu.i().a(iv2)) {
                        n += gu.m;
                    }
                    if (n <= 100) {
                        if (n > 10) {
                            n -= n % 10;
                        }
                    } else {
                        n -= n % 100;
                    }
                    String string = ed.a(lh.d(262), String.valueOf(n));
                    if (gu.g().c()) {
                        string = this.a(string);
                    }
                    this.g.a(string, 2);
                }
                this.j = b;
            }
            this.f.j.c.F();
            return;
        }
        if (!this.d.m()) return;
        if (!this.d.n()) {
            String string = lh.d(558);
            if (gu.g().c()) {
                string = this.a(string);
            }
            this.g.a(string, 2);
            return;
        } else {
            this.a = true;
            iu iu3 = this.f.j.a();
            if (iu3 == null) return;
            iu3.P();
            return;
        }
    }

    public final boolean b() {
        block6: {
            iv iv2;
            block7: {
                boolean bl2;
                block8: {
                    if (!this.d.i()) break block6;
                    iv2 = this.x();
                    if (this.h || !this.f.k()) break block7;
                    bl2 = nz.b("GPS_FIX", false);
                    if (!bl2) break block8;
                    long l = this.f.h;
                    boolean bl3 = l + (long)8000 > System.currentTimeMillis();
                    boolean bl4 = this.f.g + 10800000L < l;
                    if (!(bl4 = bl4 && bl3)) break block7;
                }
                this.b(true);
                if (!bl2) {
                    this.s();
                }
            }
            this.h = true;
            if (this.a && !iv2.equals(this.e.d())) {
                this.f.a(iv2, true);
                if ((long)this.d.e() > (long)5) {
                    this.f.A();
                }
                return true;
            }
        }
        return false;
    }

    public final int m() {
        if (this.y()) {
            if (this.e.m()) {
                return 402653439;
            }
            return 0x100000FF;
        }
        return -1;
    }

    public final int i() {
        if (this.y()) {
            if (this.e.m()) {
                return 0x400000FF;
            }
            return 0x200000FF;
        }
        return -1;
    }
}

