/*
 * 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.util.Hashtable;
import java.util.Vector;

public final class mj {
    private static final Object f = new Object();
    private final Vector b = new Vector();
    private static byte[] d;
    private static mj e;
    private boolean c;
    public int a = -1;

    public static void e() {
        Object object = f;
        synchronized (object) {
            d = null;
            e = null;
            return;
        }
    }

    public final mz a(int n) {
        return (mz)this.b.elementAt(n);
    }

    public final boolean c() {
        return this.a != -1;
    }

    public final boolean a(mz mz2) {
        if (this.a() < 255 && this.a == -1) {
            this.b.addElement(mz2);
            mz2.a(this);
            return true;
        }
        return false;
    }

    public final void a(String string, int n, byte[] byArray) {
        if (this.a == -1) {
            lh.k().f().a(byArray, string);
            this.a = n;
            return;
        }
        throw new IllegalStateException("already saved");
    }

    public final void d() {
        this.a = -1;
    }

    public final String toString() {
        return super.toString();
    }

    public final int hashCode() {
        return this.a;
    }

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

    public final int b() {
        int n = 1;
        int n2 = this.b.size();
        for (int i = 0; i < n2; ++i) {
            n += this.a(i).b();
        }
        return n;
    }

    public static mj a(DataInput dataInput) {
        int n = dataInput.readUnsignedByte();
        int n2 = dataInput.readInt();
        mj mj2 = new mj();
        for (int i = 0; i < n; ++i) {
            if (mj2.a(mz.a(dataInput))) {
                continue;
            }
            throw new IOException("FlashRecord full");
        }
        mj2.c = true;
        mj2.a = n2;
        return mj2;
    }

    public final void a(DataOutput dataOutput) {
        if (this.a != -1) {
            int n = this.a();
            dataOutput.writeByte(n);
            dataOutput.writeInt(this.a);
            for (int i = 0; i < n; ++i) {
                this.a(i).a(dataOutput);
            }
            return;
        }
        throw new IllegalStateException("Can't write unsaved FlashRecord");
    }

    public final mz a(ke ke2) {
        for (int i = 0; i < this.b.size(); ++i) {
            mz mz2 = this.a(i);
            if (!mz2.a.equals(ke2)) {
                continue;
            }
            return mz2;
        }
        return null;
    }

    public final long a(long l) {
        long l2 = 0L;
        int n = this.b.size();
        if (n > 0) {
            for (int i = 0; i < n; ++i) {
                l2 += ck.a(l, this.a(i).a());
            }
            return l2 / (long)n;
        }
        return Long.MAX_VALUE;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public final dx a(String string, ke ke2) {
        byte[] byArray;
        if (this.a == -1) return null;
        Object object = f;
        synchronized (object) {
            byArray = null;
            if (this.equals(e)) {
                byArray = d;
            }
        }
        if (byArray == null && (byArray = lh.k().f().d(string)) != null) {
            object = f;
            synchronized (object) {
                d = byArray;
                e = this;
            }
        }
        if (byArray == null) return null;
        dx dx2 = null;
        try {
            DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(byArray));
            int n = dataInputStream.readUnsignedByte();
            if (n != this.a()) return null;
            for (int i = 0; i < n; ++i) {
                dx dx3 = dx.a(dataInputStream);
                if (this.c && !new mz(dx3).equals(this.b.elementAt(i))) return null;
                if (!dx3.e.equals(ke2)) continue;
                if (this.c) {
                    dx2 = dx3;
                    continue;
                }
                dx2 = dx3;
                break;
            }
            this.c = false;
            return dx2;
        }
        catch (IOException iOException) {
            me.a("FLASH", iOException);
            return dx2;
        }
    }

    public final byte[] a(Hashtable hashtable) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(ck.b);
        DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
        int n = this.a();
        dataOutputStream.writeByte(n);
        for (int i = 0; i < n; ++i) {
            ((dx)hashtable.get(this.a((int)i).a)).a(dataOutputStream);
        }
        return byteArrayOutputStream.toByteArray();
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public final boolean equals(Object object) {
        int n;
        if (this == object) return true;
        if (!(object instanceof mj)) return false;
        mj mj2 = (mj)object;
        if (this.a != mj2.a || (n = this.a()) != mj2.a()) return false;
        Vector vector = mj2.b;
        for (int i = 0; i < n; ++i) {
            if (!((mz)this.b.elementAt(i)).equals(vector.elementAt(i))) return false;
        }
        return true;
    }
}

