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

/*
 * Duplicate member names - consider using --renamedupmembers true
 */
public class cw
implements dm,
gl,
jf,
ee,
Runnable {
    private static final Object d;
    private final fb[] a;
    private final String c;
    private final boolean e;
    private final int f;
    private final boolean g;
    private final es h;
    private final hj i;
    public final iv[] a;
    public final int c;
    private static int e;
    public static long b;
    private iv c;
    private long[][][] c;
    private lh j;
    public iv a;
    public boolean a;
    public int b;
    public cn b;
    public long f;
    public long g;

    private static long a(int n, int n2) {
        return (long)n << 32 | (long)n2 << 32 >>> 32;
    }

    public int z() {
        return 32;
    }

    public iv d() {
        return this.a[0];
    }

    public lk c() {
        lk lk2 = new lk(null);
        lk2.h(5, this.b);
        lk2.h(4, this.c);
        lk2.b(6, cw.a(this.a));
        return lk2;
    }

    public static cw a(lh lh2) {
        cw cw2 = new cw();
        lh2.b(cw2);
        return cw2;
    }

    public void a(int n, lh lh2) {
    }

    public cw(iv iv2, iv iv3, int n, int n2) {
        this(new iv[]{iv2, iv3}, 0, 1, n, n2);
    }

    public void run() {
        ka.c();
    }

    static {
        b = 1000;
        d = new Object();
        e = 1;
    }

    public cw(fb[] fbArray) {
        if (fbArray.length == 0) {
            throw new IllegalArgumentException();
        }
        this.a = fbArray;
    }

    public static iv[] b(DataInput dataInput) {
        int n = dataInput.readUnsignedShort();
        iv[] ivArray = new iv[n];
        for (int i = 0; i < n; ++i) {
            ivArray[i] = iv.a(dataInput);
        }
        return ivArray;
    }

    private static long[] a(int n, int n2, long[] lArray) {
        long[] lArray2 = new long[lArray.length];
        for (int i = 0; i < lArray.length; ++i) {
            lArray2[i] = cw.a((int)(lArray[i] >> 32) - n, cw.b(lArray[i]) - n2);
        }
        return lArray2;
    }

    private static int[] b(int n, int n2, int n3, int n4) {
        int n5 = n - n3;
        int n6 = n2 - n4;
        if (n > 4000 || n < -4000) {
            n = n <= 0 ? -4000 : 4000;
            n2 = n4 + (int)((long)(n - n3) * (long)n6 / (long)n5);
        }
        if (n2 > 4000 || n2 < -4000) {
            n2 = n6 + n4 <= 0 ? -4000 : 4000;
            n = n3 + (int)((long)(n2 - n4) * (long)n5 / (long)n6);
        }
        return new int[]{n, n2};
    }

    /*
     * WARNING - void declaration
     */
    public boolean a(DataInput dataInput) {
        lk lk2 = ar.a(la.T, dataInput);
        int bl2 = ar.b(lk2, 1, -1);
        int n = ar.b(lk2.f(2), 1, -1);
        switch (bl2) {
            case 1: {
                this.a(lk2);
            }
            default: {
                ka.a(n, this.i);
                break;
            }
            case 0: {
                this.a(lk2);
                gu.a(lk2);
            }
        }
        if (lk2.h(7) && lk2.b(7)) {
            boolean bl3 = true;
        } else {
            boolean bl4 = false;
        }
        if (this.j != null) {
            void var3_6;
            this.j.a((boolean)var3_6);
        }
        return true;
    }

    private static int a(int n, int n2, int n3, int n4) {
        n3 = n3 >= 0 ? (n3 > n ? 4 : 0) : 8;
        n = n4 >= 0 ? (n4 > n2 ? 1 : 0) : 2;
        return n3 | n;
    }

    private static boolean a(int[] nArray) {
        return nArray[0] <= 4000 && nArray[0] >= -4000 && nArray[1] <= 4000 && nArray[1] >= -4000;
    }

    private static int a(gl gl2) {
        if (gl2.n() != null) {
            return 1 + gl2.n().length;
        }
        return 1;
    }

    public final int a(cn cn2) {
        if (cn2.b >= 11) {
            return Math.min(10, Math.max(2, this.c));
        }
        return 2;
    }

    private void a(lk lk2) {
        if (lk2.h(3) && !this.e && !this.g) {
            br.a(lk2, this.i, this.h);
        }
    }

    public static void a(cw cw2, DataOutput dataOutput) {
        if (cw2 != null) {
            iv.a(cw2.a, dataOutput);
            dataOutput.writeInt(cw2.b.b);
            dataOutput.writeBoolean(cw2.a);
        }
    }

    public cw a(cn cn2) {
        return new cw(this.a, cn2, this.a);
    }

    public cw a(iv iv2) {
        return new cw(iv2, this.b, this.a);
    }

    public cw a() {
        cw cw2;
        iv iv2 = this.a;
        cn cn2 = this.b;
        boolean bl2 = !this.a;
        cw cw3 = cw2;
        cw3(iv2, cn2, bl2);
        return cw3;
    }

    public static byte[] a(iv[] ivArray) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(ivArray.length * 8);
        DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
        for (int i = 0; i < ivArray.length; ++i) {
            dataOutputStream.writeInt(ivArray[i].a);
            dataOutputStream.writeInt(ivArray[i].b);
        }
        return byteArrayOutputStream.toByteArray();
    }

    public static iv[] a(byte[] byArray) {
        int n = byArray.length / 8;
        iv[] ivArray = new iv[n];
        try {
            DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(byArray));
            for (int i = 0; i < n; ++i) {
                int n2 = dataInputStream.readInt();
                int n3 = dataInputStream.readInt();
                ivArray[i] = new iv(n2, n3);
            }
            return ivArray;
        }
        catch (IOException iOException) {
            return ivArray;
        }
    }

    public static cw a(lk lk2) {
        int n = lk2.d(5);
        int n2 = lk2.d(4);
        return new cw(cw.a(lk2.c(6)), n, n2);
    }

    public static cw a(DataInput dataInput) {
        int n = dataInput.readInt();
        byte by2 = dataInput.readByte();
        return new cw(cw.b(dataInput), n, (int)by2);
    }

    public static cw b(DataInput dataInput) {
        return new cw(iv.a(dataInput), cn.b(dataInput.readInt()), dataInput.readBoolean());
    }

    public static int b(long l) {
        return (int)(l & 0xFFFFFFFFL);
    }

    public static int a(long l) {
        return (int)(l >> 32);
    }

    public final int a(int n) {
        return -1;
    }

    public final int k() {
        return -1;
    }

    public int m() {
        return -1;
    }

    public int a() {
        return 2;
    }

    public final boolean f() {
        return true;
    }

    public boolean A_() {
        return false;
    }

    public boolean z_() {
        return false;
    }

    public boolean l() {
        return false;
    }

    public final int b() {
        return 0;
    }

    public final iv[] j() {
        return null;
    }

    public iv[][] n() {
        return null;
    }

    public final iv[] h() {
        return this.a;
    }

    public boolean y_() {
        return this.a;
    }

    public final int i() {
        return this.b;
    }

    public final int g() {
        return this.f;
    }

    public cw(boolean bl2) {
    }

    private cw() {
    }

    public cw(int n, int n2, int n3) {
        this.b = n;
        this.g = n2;
        this.f = n3;
    }

    public cw(iv iv2, cn cn2, boolean bl2) {
        this.a = iv2;
        this.b = cn2;
        this.a = bl2;
    }

    public cw(iv[] ivArray, int n, int n2, long l, int n3) {
        this.a = ivArray;
        this.c = n;
        this.b = n2;
        this.f = n3;
        this.g = l;
        this.f = System.currentTimeMillis();
        this.a = false;
    }

    public cw(iv iv2, String string, int n, boolean bl2, boolean bl3, boolean bl4, es es2, hj hj2, lh lh2) {
        this.f = iv2.a;
        this.b = iv2.b;
        this.c = string;
        this.c = n;
        this.e = bl2;
        this.a = bl3;
        this.g = bl4;
        this.h = es2;
        this.i = hj2;
        this.j = lh2;
    }

    public cw(iv[] ivArray, int n, int n2) {
        int n3;
        Object object = d;
        synchronized (object) {
            n3 = e;
            e = n3 + 1;
        }
        this.f = n3;
        this.a = ivArray;
        this.b = n;
        this.c = n2;
    }

    public void a(DataOutput dataOutput) {
        lk lk2 = new lk(la.R);
        lk lk3 = new lk(la.g);
        lk lk4 = new lk(la.d);
        lk4.h(1, this.f);
        lk4.h(2, this.b);
        lk lk5 = lk4;
        lk3.h(1, 1);
        lk3.b(2, lk5);
        lk2.b(1, lk3);
        if (this.c != 99999) {
            lk2.h(2, this.c);
        }
        lk2.b(3, this.c);
        lk2.a(4, this.e);
        dataOutput.writeInt(lk2.b());
        lk2.a((OutputStream)((Object)dataOutput));
    }

    public long[] a(fb fb2, cn cn2) {
        this.a(cn2);
        for (int i = 0; i < this.a.length; ++i) {
            if (this.a[i] != fb2) {
                continue;
            }
            return this.c[i][0];
        }
        return null;
    }

    public int c() {
        block2: {
            int n = 0;
            for (int i = 0; i < this.a.length; ++i) {
                if (this.a[i].f()) {
                    n = n * 29 + this.a[i].g();
                    continue;
                }
                break block2;
            }
            return n;
        }
        return 0;
    }

    private int a(int n, int n2, long l, long l2) {
        if (this.f == 1) {
            return (int)((long)n + (long)(n2 - n) * l / l2);
        }
        if (l2 != 0L) {
            return (int)((long)(n2 - n) * ((long)3 * l * l * l2 - (long)2 * l * l * l) / (l2 * l2 * l2) + (long)n);
        }
        return n2;
    }

    public iv a() {
        long l = System.currentTimeMillis();
        if (l < this.f + this.g && this.b <= this.a.length - 1) {
            int n = this.a(this.c, this.b, l - this.f, this.g);
            int n2 = this.b > this.c ? 1 : -1;
            n2 = Math.max(Math.min(n + n2, this.a.length - 1), 0);
            long l2 = this.g * (long)(this.b - this.c);
            l = (l - this.f) * (long)(this.b - this.c) - (long)(n - this.c) * this.g;
            return new iv(this.a(this.a[n].a, this.a[n2].a, l, l2), this.a(this.a[n].b, this.a[n2].b, l, l2));
        }
        this.a = true;
        return this.a[Math.min(this.b, this.a.length - 1)];
    }

    public void a(iv iv2, lh lh2) {
        block11: {
            long l;
            block12: {
                block10: {
                    iv2 = lh2.m();
                    l = System.currentTimeMillis();
                    long l2 = this.g == 0L ? 0L : l - this.g;
                    if (!this.a && l2 > 600000L) {
                        l2 = this.a == null ? Long.MAX_VALUE : this.a.a(iv2);
                        this.b = l2 >= 40000L ? 0 : ++this.b;
                        if (this.b < 2) {
                            this.a = true;
                            this.g = l;
                        }
                    }
                    if (this.a) break block10;
                    l2 = this.c != null ? this.c.a(iv2) : Long.MAX_VALUE;
                    if (l2 < (long)10000) break block11;
                    if (lh2.l()) {
                        if (lh2.f() == 1000) {
                            px.a(lh2);
                        } else {
                            px.a(lh2, false);
                        }
                    }
                    break block12;
                }
                if (l - this.f < (long)12000 || lh2.f() > 100) break block11;
                boolean bl2 = false;
                if (l - this.g > 120000L) {
                    this.a = false;
                    this.a = iv2;
                    bl2 = true;
                }
                px.a(lh2, bl2);
            }
            this.f = l;
            this.c = iv2;
        }
    }

    public static boolean a(long[] lArray, iv iv2, cn cn2) {
        block5: {
            if (lArray != null) {
                int n = iv2.a(cn2);
                int n2 = iv2.b(cn2);
                int n3 = 1;
                for (int i = 0; i < lArray.length - 1; ++i) {
                    int n4 = (int)(lArray[i] >> 32);
                    int n5 = cw.b(lArray[i]);
                    int n6 = (int)(lArray[n3] >> 32);
                    int n7 = cw.b(lArray[n3]);
                    if (!(n5 <= n7 ? n5 - 4 > n2 || n2 > n7 + 4 : n7 - 4 > n2 || n2 > n5 + 4)) {
                        if (!(n4 <= n6 ? n4 - 4 > n || n > n6 + 4 : n6 - 4 > n || n > n4 + 4)) {
                            if (Math.abs((n - n4) * (n7 -= n5) - (n2 - n5) * (n6 -= n4)) / Math.min(80, ck.g(n6 * n6 + n7 * n7)) <= 4) break block5;
                        }
                    }
                    ++n3;
                }
            }
            return false;
        }
        return true;
    }

    private void a(cn cn2) {
        if (cn2 != this.b) {
            this.c = new long[this.a.length][][];
            for (int i = 0; i < this.a.length; ++i) {
                int n;
                iv[][] ivArrayArray;
                if (!(this.a[i] instanceof gl)) continue;
                gl gl2 = (gl)this.a[i];
                int n2 = cw.a(gl2);
                this.c[i] = new long[n2][];
                if (gl2.n() != null) {
                    ivArrayArray = new iv[cw.a(gl2)][];
                    ivArrayArray[0] = gl2.h();
                    for (n = 1; n < ivArrayArray.length; ++n) {
                        ivArrayArray[n] = gl2.n()[n - 1];
                    }
                } else {
                    ivArrayArray = new iv[][]{gl2.h()};
                }
                for (n = 0; n < n2; ++n) {
                    iv[] ivArray = ivArrayArray[n];
                    long[] lArray = new long[ivArray.length];
                    this.b = cn2;
                    lArray[0] = cw.a(ivArray[0].a(this.b), ivArray[0].b(this.b));
                    int n3 = 1;
                    for (int k = 1; k < ivArray.length; ++k) {
                        int n4 = ivArray[k].a(this.b);
                        int n5 = ivArray[k].b(this.b);
                        if (Math.abs(n4 - (int)(lArray[n3 - 1] >> 32)) <= 2 && Math.abs(n5 - cw.b(lArray[n3 - 1])) <= 2 && k != ivArray.length - 1) continue;
                        lArray[n3] = cw.a(n4, n5);
                        ++n3;
                    }
                    this.c[i][n] = new long[n3];
                    System.arraycopy(lArray, 0, this.c[i][n], 0, n3);
                }
            }
        }
    }

    public void a(ny ny2, int n, int n2, int n3, int n4, cn cn2) {
        if (this.c() != 0) {
            this.a(cn2);
            for (int i = 0; i < this.a.length; ++i) {
                iv iv2;
                int n5;
                int n6;
                int n7;
                int n8;
                if (!(this.a[i] instanceof mi)) {
                    iv[] ivArray;
                    int n9;
                    int n10;
                    gl gl2 = (gl)this.a[i];
                    if (!this.a[i].l()) {
                        for (n8 = 0; n8 < this.c[i].length; ++n8) {
                            long[] lArray = this.c[i][n8];
                            int[] nArray = new int[2];
                            int[] nArray2 = new int[]{(int)(lArray[0] >> 32) - n, cw.b(lArray[0]) - n2};
                            n7 = 1;
                            n6 = 0;
                            n10 = cw.a(n3, n4, nArray2[0], nArray2[1]);
                            n5 = 1;
                            while (true) {
                                n9 = n10;
                                if (n7 >= lArray.length) break;
                                nArray[0] = (int)(lArray[n7] >> 32) - n;
                                nArray[1] = cw.b(lArray[n7]) - n2;
                                n10 = cw.a(n3, n4, nArray[0], nArray[1]);
                                if ((n9 & n10) == 0) {
                                    if (n6 == 0) {
                                        n6 = 1;
                                        ny2.a(gl2.i(), gl2.a(cn2), gl2.b());
                                    }
                                    int[] nArray3 = null;
                                    n9 = cw.a(nArray) ? 1 : 0;
                                    if (n9 == 0) {
                                        nArray3 = cw.b(nArray[0], nArray[1], nArray2[0], nArray2[1]);
                                    }
                                    if (!cw.a(nArray2)) {
                                        nArray2 = cw.b(nArray2[0], nArray2[1], nArray[0], nArray[1]);
                                    }
                                    if (n9 == 0) {
                                        ny2.a(nArray3, nArray2, n5 != 0);
                                    } else {
                                        ny2.a(nArray, nArray2, n5 != 0);
                                    }
                                    n5 = n9 != 0 ? 0 : 1;
                                } else {
                                    n5 = 1;
                                }
                                ++n7;
                                nArray2[0] = nArray[0];
                                nArray2[1] = nArray[1];
                            }
                            if (n6 == 0) continue;
                            ny2.a();
                        }
                    } else {
                        long[][] lArrayArray;
                        long[][] lArray;
                        block19: {
                            lArray = this.c[i];
                            n10 = cw.a(gl2);
                            lArrayArray = new long[n10][];
                            lArrayArray[0] = cw.a(n, n2, lArray[0]);
                            n8 = n5 = cw.a(n3, n4, (int)(lArrayArray[0][0] >> 32), cw.b(lArrayArray[0][0]));
                            n6 = 1;
                            n7 = 0;
                            while (true) {
                                n9 = n5;
                                if (n6 >= lArrayArray[0].length) break block19;
                                n5 = cw.a(n3, n4, (int)(lArrayArray[0][n6] >> 32), cw.b(lArrayArray[0][n6]));
                                if ((n9 & n5) == 0) break;
                                ++n6;
                                n8 |= n5;
                            }
                            n7 = 1;
                        }
                        if (n8 == 15) {
                            n7 = 1;
                        }
                        if (n7 != 0) {
                            for (n5 = 1; n5 < n10; ++n5) {
                                lArrayArray[n5] = cw.a(n, n2, lArray[n5]);
                            }
                            ny2.a(lArrayArray, gl2.i(), gl2.a(cn2), gl2.m());
                        }
                    }
                    if ((ivArray = gl2.j()) == null) continue;
                    for (n5 = ivArray.length - 1; n5 >= 0 && (iv2 = ivArray[n5]) != null; --n5) {
                        n6 = iv2.a(cn2) - n;
                        n8 = iv2.b(cn2) - n2;
                        if (n6 <= -5 || n6 >= 133 || n8 <= -5 || n8 >= 133) continue;
                        ny2.a(n6, n8, gl2.a(n5), gl2.k());
                    }
                    continue;
                }
                mi mi2 = (mi)this.a[i];
                if (mi2.i() == -1 && mi2.m() == -1) continue;
                iv2 = mi2.n();
                n5 = cn2.a(mi2.k());
                n6 = cn2.a(mi2.j());
                n8 = iv2.a(cn2) - n;
                if ((cw.a(n3, n4, n8 - n5 / 2, (n7 = iv2.b(cn2) - n2) - n6 / 2) & cw.a(n3, n4, n8 + n5 / 2, n7 + n6 / 2)) != 0) continue;
                ny2.a(n8, n7, n5, n6, mi2.a(cn2), mi2.i(), mi2.m());
            }
        }
    }
}

