package o;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Pn0 implements Iterable, InterfaceC1991no0, InterfaceC1037do0 {
    public final TreeMap l;
    public final TreeMap m;

    public Pn0() {
        this.l = new TreeMap();
        this.m = new TreeMap();
    }

    @Override // o.InterfaceC1991no0
    public final Iterator a() {
        return new Mn0(this, this.l.keySet().iterator(), this.m.keySet().iterator());
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Code restructure failed: missing block: B:135:0x02e5, code lost:
    
        if (o.AbstractC0940cn0.N(r7, r2, (o.C1801lo0) r0, java.lang.Boolean.FALSE, java.lang.Boolean.TRUE).l() == r7.l()) goto L168;
     */
    /* JADX WARN: Removed duplicated region for block: B:120:0x0294  */
    /* JADX WARN: Removed duplicated region for block: B:127:0x02ae  */
    /* JADX WARN: Removed duplicated region for block: B:139:0x02f1  */
    /* JADX WARN: Removed duplicated region for block: B:154:0x0350  */
    /* JADX WARN: Removed duplicated region for block: B:174:0x03cd  */
    /* JADX WARN: Removed duplicated region for block: B:183:0x0407  */
    /* JADX WARN: Removed duplicated region for block: B:201:0x044e  */
    /* JADX WARN: Removed duplicated region for block: B:208:0x046c  */
    /* JADX WARN: Removed duplicated region for block: B:220:0x04a6  */
    /* JADX WARN: Removed duplicated region for block: B:241:0x053b  */
    /* JADX WARN: Removed duplicated region for block: B:272:0x05e6  */
    /* JADX WARN: Removed duplicated region for block: B:283:0x061a  */
    /* JADX WARN: Removed duplicated region for block: B:329:0x0749  */
    /* JADX WARN: Removed duplicated region for block: B:333:0x0757  */
    /* JADX WARN: Removed duplicated region for block: B:348:0x07c0  */
    /* JADX WARN: Removed duplicated region for block: B:366:0x0827  */
    /* JADX WARN: Removed duplicated region for block: B:370:0x083f  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x012b  */
    /* JADX WARN: Removed duplicated region for block: B:81:0x01bf  */
    /* JADX WARN: Removed duplicated region for block: B:95:0x01f7  */
    /* JADX WARN: Removed duplicated region for block: B:99:0x0203  */
    @Override // o.InterfaceC1991no0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.InterfaceC1991no0 b(java.lang.String r38, o.C2062oc0 r39, java.util.ArrayList r40) {
        /*
            Method dump skipped, instructions count: 2202
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Pn0.b(java.lang.String, o.oc0, java.util.ArrayList):o.no0");
    }

    @Override // o.InterfaceC1037do0
    public final InterfaceC1991no0 c(String str) {
        InterfaceC1991no0 interfaceC1991no0;
        return "length".equals(str) ? new Wn0(Double.valueOf(l())) : (!f(str) || (interfaceC1991no0 = (InterfaceC1991no0) this.m.get(str)) == null) ? InterfaceC1991no0.d : interfaceC1991no0;
    }

    @Override // o.InterfaceC1037do0
    public final void d(String str, InterfaceC1991no0 interfaceC1991no0) {
        TreeMap treeMap = this.m;
        if (interfaceC1991no0 == null) {
            treeMap.remove(str);
        } else {
            treeMap.put(str, interfaceC1991no0);
        }
    }

    public final boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Pn0)) {
            return false;
        }
        Pn0 pn0 = (Pn0) obj;
        if (l() != pn0.l()) {
            return false;
        }
        TreeMap treeMap = this.l;
        if (treeMap.isEmpty()) {
            return pn0.l.isEmpty();
        }
        for (int iIntValue = ((Integer) treeMap.firstKey()).intValue(); iIntValue <= ((Integer) treeMap.lastKey()).intValue(); iIntValue++) {
            if (!m(iIntValue).equals(pn0.m(iIntValue))) {
                return false;
            }
        }
        return true;
    }

    @Override // o.InterfaceC1037do0
    public final boolean f(String str) {
        return "length".equals(str) || this.m.containsKey(str);
    }

    @Override // o.InterfaceC1991no0
    public final InterfaceC1991no0 h() {
        Pn0 pn0 = new Pn0();
        for (Map.Entry entry : this.l.entrySet()) {
            boolean z = entry.getValue() instanceof InterfaceC1037do0;
            TreeMap treeMap = pn0.l;
            if (z) {
                treeMap.put((Integer) entry.getKey(), (InterfaceC1991no0) entry.getValue());
            } else {
                treeMap.put((Integer) entry.getKey(), ((InterfaceC1991no0) entry.getValue()).h());
            }
        }
        return pn0;
    }

    public final int hashCode() {
        return this.l.hashCode() * 31;
    }

    public final List i() {
        ArrayList arrayList = new ArrayList(l());
        for (int i = 0; i < l(); i++) {
            arrayList.add(m(i));
        }
        return arrayList;
    }

    @Override // java.lang.Iterable
    public final Iterator iterator() {
        return new C2276qo0(2, this);
    }

    public final Iterator k() {
        return this.l.keySet().iterator();
    }

    public final int l() {
        TreeMap treeMap = this.l;
        if (treeMap.isEmpty()) {
            return 0;
        }
        return ((Integer) treeMap.lastKey()).intValue() + 1;
    }

    public final InterfaceC1991no0 m(int i) {
        InterfaceC1991no0 interfaceC1991no0;
        if (i < l()) {
            return (!o(i) || (interfaceC1991no0 = (InterfaceC1991no0) this.l.get(Integer.valueOf(i))) == null) ? InterfaceC1991no0.d : interfaceC1991no0;
        }
        throw new IndexOutOfBoundsException("Attempting to get element outside of current array");
    }

    public final void n(int i, InterfaceC1991no0 interfaceC1991no0) {
        if (i > 32468) {
            throw new IllegalStateException("Array too large");
        }
        if (i < 0) {
            StringBuilder sb = new StringBuilder(String.valueOf(i).length() + 21);
            sb.append("Out of bounds index: ");
            sb.append(i);
            throw new IndexOutOfBoundsException(sb.toString());
        }
        TreeMap treeMap = this.l;
        if (interfaceC1991no0 == null) {
            treeMap.remove(Integer.valueOf(i));
        } else {
            treeMap.put(Integer.valueOf(i), interfaceC1991no0);
        }
    }

    public final boolean o(int i) {
        if (i >= 0) {
            TreeMap treeMap = this.l;
            if (i <= ((Integer) treeMap.lastKey()).intValue()) {
                return treeMap.containsKey(Integer.valueOf(i));
            }
        }
        StringBuilder sb = new StringBuilder(String.valueOf(i).length() + 21);
        sb.append("Out of bounds index: ");
        sb.append(i);
        throw new IndexOutOfBoundsException(sb.toString());
    }

    public final void p(int i) {
        TreeMap treeMap = this.l;
        int iIntValue = ((Integer) treeMap.lastKey()).intValue();
        if (i > iIntValue || i < 0) {
            return;
        }
        treeMap.remove(Integer.valueOf(i));
        if (i == iIntValue) {
            int i2 = i - 1;
            Integer numValueOf = Integer.valueOf(i2);
            if (treeMap.containsKey(numValueOf) || i2 < 0) {
                return;
            }
            treeMap.put(numValueOf, InterfaceC1991no0.d);
            return;
        }
        while (true) {
            i++;
            if (i > ((Integer) treeMap.lastKey()).intValue()) {
                return;
            }
            Integer numValueOf2 = Integer.valueOf(i);
            InterfaceC1991no0 interfaceC1991no0 = (InterfaceC1991no0) treeMap.get(numValueOf2);
            if (interfaceC1991no0 != null) {
                treeMap.put(Integer.valueOf(i - 1), interfaceC1991no0);
                treeMap.remove(numValueOf2);
            }
        }
    }

    public final String q(String str) {
        String str2;
        StringBuilder sb = new StringBuilder();
        if (!this.l.isEmpty()) {
            int i = 0;
            while (true) {
                str2 = str == null ? "" : str;
                if (i >= l()) {
                    break;
                }
                InterfaceC1991no0 interfaceC1991no0M = m(i);
                sb.append(str2);
                if (!(interfaceC1991no0M instanceof C2655uo0) && !(interfaceC1991no0M instanceof C1516io0)) {
                    sb.append(interfaceC1991no0M.zzc());
                }
                i++;
            }
            sb.delete(0, str2.length());
        }
        return sb.toString();
    }

    public final String toString() {
        return q(",");
    }

    @Override // o.InterfaceC1991no0
    public final String zzc() {
        return q(",");
    }

    @Override // o.InterfaceC1991no0
    public final Double zzd() {
        TreeMap treeMap = this.l;
        return treeMap.size() == 1 ? m(0).zzd() : treeMap.size() <= 0 ? Double.valueOf(0.0d) : Double.valueOf(Double.NaN);
    }

    @Override // o.InterfaceC1991no0
    public final Boolean zze() {
        return Boolean.TRUE;
    }

    public Pn0(List list) {
        this();
        if (list != null) {
            for (int i = 0; i < list.size(); i++) {
                n(i, (InterfaceC1991no0) list.get(i));
            }
        }
    }
}
