package IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3;

import android.util.SparseArray;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
/* compiled from: BreakpointStoreOnCache.java */
/* loaded from: classes.dex */
public class IMuAHx_6 implements Xgtqvk_8 {
    public final XnFJ5_9 KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final SparseArray<PGPF6hQ_2> f140KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final HashMap<String, String> f141KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final List<Integer> f142KQgRr5e_0;
    public final SparseArray<IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.KQgRr5e_0> QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final List<Integer> f143QxJ9d_1;

    public IMuAHx_6() {
        this(new SparseArray(), new ArrayList(), new HashMap());
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8
    public PGPF6hQ_2 KQgRr5e_0(int i) {
        return null;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public PGPF6hQ_2 KQgRr5e_0(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2) {
        int KQgRr5e_0 = pGPF6hQ_2.KQgRr5e_0();
        PGPF6hQ_2 pGPF6hQ_22 = new PGPF6hQ_2(KQgRr5e_0, pGPF6hQ_2.QxJ9d_1(), pGPF6hQ_2.KQgRr5e_0(), pGPF6hQ_2.KQgRr5e_0());
        synchronized (this) {
            this.f140KQgRr5e_0.put(KQgRr5e_0, pGPF6hQ_22);
            this.QxJ9d_1.remove(KQgRr5e_0);
        }
        return pGPF6hQ_22;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8
    public void KQgRr5e_0(int i) {
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public boolean KQgRr5e_0() {
        return true;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public boolean PGPF6hQ_2(int i) {
        return this.f143QxJ9d_1.contains(Integer.valueOf(i));
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public PGPF6hQ_2 QxJ9d_1(int i) {
        return this.f140KQgRr5e_0.get(i);
    }

    public IMuAHx_6(SparseArray<PGPF6hQ_2> sparseArray, List<Integer> list, HashMap<String, String> hashMap) {
        this.QxJ9d_1 = new SparseArray<>();
        this.f140KQgRr5e_0 = sparseArray;
        this.f143QxJ9d_1 = list;
        this.f141KQgRr5e_0 = hashMap;
        this.KQgRr5e_0 = new XnFJ5_9();
        int size = sparseArray.size();
        this.f142KQgRr5e_0 = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            this.f142KQgRr5e_0.add(Integer.valueOf(sparseArray.valueAt(i).KQgRr5e_0));
        }
        Collections.sort(this.f142KQgRr5e_0);
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public boolean QxJ9d_1(int i) {
        boolean remove;
        synchronized (this.f143QxJ9d_1) {
            remove = this.f143QxJ9d_1.remove(Integer.valueOf(i));
        }
        return remove;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public synchronized void QxJ9d_1(int i) {
        this.f140KQgRr5e_0.remove(i);
        if (this.QxJ9d_1.get(i) == null) {
            this.f142KQgRr5e_0.remove(Integer.valueOf(i));
        }
        this.KQgRr5e_0.KQgRr5e_0(i);
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8
    public void KQgRr5e_0(PGPF6hQ_2 pGPF6hQ_2, int i, long j) throws IOException {
        PGPF6hQ_2 pGPF6hQ_22 = this.f140KQgRr5e_0.get(pGPF6hQ_2.KQgRr5e_0);
        if (pGPF6hQ_2 == pGPF6hQ_22) {
            pGPF6hQ_22.KQgRr5e_0(i).KQgRr5e_0(j);
            return;
        }
        throw new IOException("Info not on store!");
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public boolean KQgRr5e_0(PGPF6hQ_2 pGPF6hQ_2) {
        String m95QxJ9d_1 = pGPF6hQ_2.m95QxJ9d_1();
        if (pGPF6hQ_2.m96QxJ9d_1() && m95QxJ9d_1 != null) {
            this.f141KQgRr5e_0.put(pGPF6hQ_2.PGPF6hQ_2(), m95QxJ9d_1);
        }
        PGPF6hQ_2 pGPF6hQ_22 = this.f140KQgRr5e_0.get(pGPF6hQ_2.KQgRr5e_0);
        if (pGPF6hQ_22 != null) {
            if (pGPF6hQ_22 == pGPF6hQ_2) {
                return true;
            }
            synchronized (this) {
                this.f140KQgRr5e_0.put(pGPF6hQ_2.KQgRr5e_0, pGPF6hQ_2.m89KQgRr5e_0());
            }
            return true;
        }
        return false;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8
    public void KQgRr5e_0(int i, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.X6FRs_4.KQgRr5e_0 kQgRr5e_0, Exception exc) {
        if (kQgRr5e_0 == IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.X6FRs_4.KQgRr5e_0.COMPLETED) {
            QxJ9d_1(i);
        }
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8
    public boolean KQgRr5e_0(int i) {
        if (this.f143QxJ9d_1.contains(Integer.valueOf(i))) {
            return false;
        }
        synchronized (this.f143QxJ9d_1) {
            if (this.f143QxJ9d_1.contains(Integer.valueOf(i))) {
                return false;
            }
            this.f143QxJ9d_1.add(Integer.valueOf(i));
            return true;
        }
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public synchronized int KQgRr5e_0(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2) {
        Integer KQgRr5e_0 = this.KQgRr5e_0.KQgRr5e_0(pGPF6hQ_2);
        if (KQgRr5e_0 != null) {
            return KQgRr5e_0.intValue();
        }
        int size = this.f140KQgRr5e_0.size();
        for (int i = 0; i < size; i++) {
            PGPF6hQ_2 valueAt = this.f140KQgRr5e_0.valueAt(i);
            if (valueAt != null && valueAt.KQgRr5e_0(pGPF6hQ_2)) {
                return valueAt.KQgRr5e_0;
            }
        }
        int size2 = this.QxJ9d_1.size();
        for (int i2 = 0; i2 < size2; i2++) {
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.KQgRr5e_0 valueAt2 = this.QxJ9d_1.valueAt(i2);
            if (valueAt2 != null && valueAt2.KQgRr5e_0(pGPF6hQ_2)) {
                return valueAt2.KQgRr5e_0();
            }
        }
        int KQgRr5e_02 = KQgRr5e_0();
        this.QxJ9d_1.put(KQgRr5e_02, pGPF6hQ_2.KQgRr5e_0(KQgRr5e_02));
        this.KQgRr5e_0.KQgRr5e_0(pGPF6hQ_2, KQgRr5e_02);
        return KQgRr5e_02;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public PGPF6hQ_2 KQgRr5e_0(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2, PGPF6hQ_2 pGPF6hQ_22) {
        SparseArray<PGPF6hQ_2> clone;
        synchronized (this) {
            clone = this.f140KQgRr5e_0.clone();
        }
        int size = clone.size();
        for (int i = 0; i < size; i++) {
            PGPF6hQ_2 valueAt = clone.valueAt(i);
            if (valueAt != pGPF6hQ_22 && valueAt.KQgRr5e_0(pGPF6hQ_2)) {
                return valueAt;
            }
        }
        return null;
    }

    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    public String KQgRr5e_0(String str) {
        return this.f141KQgRr5e_0.get(str);
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x002e, code lost:
        r1 = 0;
     */
    @Override // IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.IFxWkV_5
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public synchronized int KQgRr5e_0() {
        int i;
        int i2 = 0;
        int i3 = 0;
        int i4 = 0;
        while (true) {
            i = 1;
            if (i3 >= this.f142KQgRr5e_0.size()) {
                break;
            }
            Integer num = this.f142KQgRr5e_0.get(i3);
            if (num == null) {
                i2 = i4 + 1;
                break;
            }
            int intValue = num.intValue();
            if (i4 != 0) {
                int i5 = i4 + 1;
                if (intValue != i5) {
                    i2 = i5;
                    break;
                }
            } else if (intValue != 1) {
                i2 = 1;
                break;
            }
            i3++;
            i4 = intValue;
        }
        if (i2 != 0) {
            i = i2;
        } else if (!this.f142KQgRr5e_0.isEmpty()) {
            i = 1 + this.f142KQgRr5e_0.get(this.f142KQgRr5e_0.size() - 1).intValue();
            i3 = this.f142KQgRr5e_0.size();
        }
        this.f142KQgRr5e_0.add(i3, Integer.valueOf(i));
        return i;
    }
}
