package androidx.compose.runtime.collection;

import J4.c;
import J4.e;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import n.N;
import n.O;
import n.Y;
import n.c0;
import x4.AbstractC3229F;

/* JADX INFO: loaded from: classes.dex */
public final class ScopeMap<Key, Scope> {
    private final N map;

    private /* synthetic */ ScopeMap(N n6) {
        this.map = n6;
    }

    /* JADX INFO: renamed from: add-impl, reason: not valid java name */
    public static final void m177addimpl(N n6, Key key, Scope scope) {
        int iH = n6.h(key);
        boolean z6 = iH < 0;
        Object obj = z6 ? null : n6.f21383c[iH];
        if (obj != null) {
            if (obj instanceof O) {
                ((O) obj).d(scope);
            } else if (obj != scope) {
                O o6 = new O();
                o6.d(obj);
                o6.d(scope);
                scope = (Scope) o6;
            }
            scope = (Scope) obj;
        }
        if (!z6) {
            n6.f21383c[iH] = scope;
            return;
        }
        int i6 = ~iH;
        n6.f21382b[i6] = key;
        n6.f21383c[i6] = scope;
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x0055  */
    /* JADX INFO: renamed from: anyScopeOf-impl, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final boolean m178anyScopeOfimpl(N n6, Key key, c cVar) {
        Object objD = n6.d(key);
        if (objD != null) {
            if (objD instanceof O) {
                O o6 = (O) objD;
                Object[] objArr = o6.f21389b;
                long[] jArr = o6.f21388a;
                int length = jArr.length - 2;
                if (length >= 0) {
                    int i6 = 0;
                    while (true) {
                        long j4 = jArr[i6];
                        if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                            int i7 = 8 - ((~(i6 - length)) >>> 31);
                            for (int i8 = 0; i8 < i7; i8++) {
                                if ((255 & j4) < 128 && ((Boolean) cVar.invoke(objArr[(i6 << 3) + i8])).booleanValue()) {
                                    return true;
                                }
                                j4 >>= 8;
                            }
                            if (i7 != 8) {
                                break;
                            }
                            if (i6 == length) {
                                break;
                            }
                            i6++;
                        }
                    }
                }
            } else if (((Boolean) cVar.invoke(objD)).booleanValue()) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0078  */
    /* JADX INFO: renamed from: asMap-impl, reason: not valid java name */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Map<Key, Set<Scope>> m179asMapimpl(N n6) {
        Collection linkedHashSet;
        HashMap map = new HashMap();
        Object[] objArr = n6.f21382b;
        Object[] objArr2 = n6.f21383c;
        long[] jArr = n6.f21381a;
        int length = jArr.length - 2;
        if (length >= 0) {
            int i6 = 0;
            while (true) {
                long j4 = jArr[i6];
                if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                    int i7 = 8 - ((~(i6 - length)) >>> 31);
                    for (int i8 = 0; i8 < i7; i8++) {
                        if ((255 & j4) < 128) {
                            int i9 = (i6 << 3) + i8;
                            Object obj = objArr[i9];
                            Object obj2 = objArr2[i9];
                            o.f(obj, "null cannot be cast to non-null type Key of androidx.compose.runtime.collection.ScopeMap");
                            if (obj2 instanceof O) {
                                o.f(obj2, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap>");
                                O o6 = (O) obj2;
                                o6.getClass();
                                linkedHashSet = new c0(o6);
                            } else {
                                o.f(obj2, "null cannot be cast to non-null type Scope of androidx.compose.runtime.collection.ScopeMap");
                                linkedHashSet = new LinkedHashSet(AbstractC3229F.u(1));
                                linkedHashSet.add(new Object[]{obj2}[0]);
                            }
                            map.put(obj, linkedHashSet);
                        }
                        j4 >>= 8;
                    }
                    if (i7 != 8) {
                        break;
                    }
                    if (i6 == length) {
                        break;
                    }
                    i6++;
                }
            }
        }
        return map;
    }

    /* JADX INFO: renamed from: box-impl, reason: not valid java name */
    public static final /* synthetic */ ScopeMap m180boximpl(N n6) {
        return new ScopeMap(n6);
    }

    /* JADX INFO: renamed from: clear-impl, reason: not valid java name */
    public static final void m181clearimpl(N n6) {
        n6.f();
    }

    /* JADX INFO: renamed from: constructor-impl$default, reason: not valid java name */
    public static N m183constructorimpl$default(N n6, int i6, h hVar) {
        if ((i6 & 1) != 0) {
            long[] jArr = Y.f21386a;
            n6 = new N();
        }
        return m182constructorimpl(n6);
    }

    /* JADX INFO: renamed from: contains-impl, reason: not valid java name */
    public static final boolean m184containsimpl(N n6, Key key) {
        return n6.b(key);
    }

    /* JADX INFO: renamed from: equals-impl, reason: not valid java name */
    public static boolean m185equalsimpl(N n6, Object obj) {
        return (obj instanceof ScopeMap) && o.c(n6, ((ScopeMap) obj).m196unboximpl());
    }

    /* JADX INFO: renamed from: equals-impl0, reason: not valid java name */
    public static final boolean m186equalsimpl0(N n6, N n7) {
        return o.c(n6, n7);
    }

    /* JADX INFO: renamed from: forEachScopeOf-impl, reason: not valid java name */
    public static final void m187forEachScopeOfimpl(N n6, Key key, c cVar) {
        Object objD = n6.d(key);
        if (objD == null) {
            return;
        }
        if (!(objD instanceof O)) {
            cVar.invoke(objD);
            return;
        }
        O o6 = (O) objD;
        Object[] objArr = o6.f21389b;
        long[] jArr = o6.f21388a;
        int length = jArr.length - 2;
        if (length < 0) {
            return;
        }
        int i6 = 0;
        while (true) {
            long j4 = jArr[i6];
            if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i7 = 8 - ((~(i6 - length)) >>> 31);
                for (int i8 = 0; i8 < i7; i8++) {
                    if ((255 & j4) < 128) {
                        cVar.invoke(objArr[(i6 << 3) + i8]);
                    }
                    j4 >>= 8;
                }
                if (i7 != 8) {
                    return;
                }
            }
            if (i6 == length) {
                return;
            } else {
                i6++;
            }
        }
    }

    /* JADX INFO: renamed from: getSize-impl, reason: not valid java name */
    public static final int m188getSizeimpl(N n6) {
        return n6.f21385e;
    }

    /* JADX INFO: renamed from: hashCode-impl, reason: not valid java name */
    public static int m189hashCodeimpl(N n6) {
        return n6.hashCode();
    }

    /* JADX INFO: renamed from: remove-impl, reason: not valid java name */
    public static final boolean m190removeimpl(N n6, Key key, Scope scope) {
        Object objD = n6.d(key);
        if (objD == null) {
            return false;
        }
        if (!(objD instanceof O)) {
            if (!objD.equals(scope)) {
                return false;
            }
            n6.j(key);
            return true;
        }
        O o6 = (O) objD;
        boolean zL = o6.l(scope);
        if (zL && o6.b()) {
            n6.j(key);
        }
        return zL;
    }

    /* JADX INFO: renamed from: removeIf-impl, reason: not valid java name */
    public static final void m191removeIfimpl(N n6, e eVar) {
        long[] jArr;
        long[] jArr2;
        long j4;
        char c6;
        long j6;
        int i6;
        int i7;
        boolean zBooleanValue;
        long[] jArr3;
        long j7;
        long[] jArr4 = n6.f21381a;
        int length = jArr4.length - 2;
        if (length < 0) {
            return;
        }
        int i8 = 0;
        while (true) {
            long j8 = jArr4[i8];
            char c7 = 7;
            long j9 = -9187201950435737472L;
            if ((((~j8) << 7) & j8 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i9 = 8;
                int i10 = 8 - ((~(i8 - length)) >>> 31);
                int i11 = 0;
                while (i11 < i10) {
                    if ((j8 & 255) < 128) {
                        int i12 = (i8 << 3) + i11;
                        c6 = c7;
                        Object obj = n6.f21382b[i12];
                        j6 = j9;
                        Object obj2 = n6.f21383c[i12];
                        o.f(obj, "null cannot be cast to non-null type Key of androidx.compose.runtime.collection.ScopeMap");
                        if (obj2 instanceof O) {
                            o.f(obj2, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap>");
                            O o6 = (O) obj2;
                            Object[] objArr = o6.f21389b;
                            long[] jArr5 = o6.f21388a;
                            int length2 = jArr5.length - 2;
                            if (length2 >= 0) {
                                j4 = j8;
                                int i13 = i9;
                                int i14 = 0;
                                while (true) {
                                    long j10 = jArr5[i14];
                                    Object[] objArr2 = objArr;
                                    i6 = i11;
                                    if ((((~j10) << c6) & j10 & j6) != j6) {
                                        int i15 = 8 - ((~(i14 - length2)) >>> 31);
                                        int i16 = 0;
                                        while (i16 < i15) {
                                            if ((j10 & 255) < 128) {
                                                jArr3 = jArr4;
                                                int i17 = (i14 << 3) + i16;
                                                j7 = j10;
                                                if (((Boolean) eVar.invoke(obj, objArr2[i17])).booleanValue()) {
                                                    o6.m(i17);
                                                }
                                            } else {
                                                jArr3 = jArr4;
                                                j7 = j10;
                                            }
                                            j10 = j7 >> i13;
                                            i16++;
                                            jArr4 = jArr3;
                                        }
                                        jArr2 = jArr4;
                                        if (i15 != i13) {
                                            break;
                                        }
                                    } else {
                                        jArr2 = jArr4;
                                    }
                                    if (i14 == length2) {
                                        break;
                                    }
                                    i14++;
                                    i11 = i6;
                                    objArr = objArr2;
                                    jArr4 = jArr2;
                                    i13 = 8;
                                }
                            } else {
                                jArr2 = jArr4;
                                j4 = j8;
                                i6 = i11;
                            }
                            zBooleanValue = o6.b();
                        } else {
                            jArr2 = jArr4;
                            j4 = j8;
                            i6 = i11;
                            o.f(obj2, "null cannot be cast to non-null type Scope of androidx.compose.runtime.collection.ScopeMap");
                            zBooleanValue = ((Boolean) eVar.invoke(obj, obj2)).booleanValue();
                        }
                        if (zBooleanValue) {
                            n6.k(i12);
                        }
                        i7 = 8;
                    } else {
                        jArr2 = jArr4;
                        j4 = j8;
                        c6 = c7;
                        j6 = j9;
                        i6 = i11;
                        i7 = i9;
                    }
                    j8 = j4 >> i7;
                    i11 = i6 + 1;
                    i9 = i7;
                    c7 = c6;
                    j9 = j6;
                    jArr4 = jArr2;
                }
                jArr = jArr4;
                if (i10 != i9) {
                    return;
                }
            } else {
                jArr = jArr4;
            }
            if (i8 == length) {
                return;
            }
            i8++;
            jArr4 = jArr;
        }
    }

    /* JADX INFO: renamed from: removeScope-impl, reason: not valid java name */
    public static final void m192removeScopeimpl(N n6, Scope scope) {
        boolean zB;
        long[] jArr = n6.f21381a;
        int length = jArr.length - 2;
        if (length < 0) {
            return;
        }
        int i6 = 0;
        while (true) {
            long j4 = jArr[i6];
            if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i7 = 8 - ((~(i6 - length)) >>> 31);
                for (int i8 = 0; i8 < i7; i8++) {
                    if ((255 & j4) < 128) {
                        int i9 = (i6 << 3) + i8;
                        Object obj = n6.f21382b[i9];
                        Object obj2 = n6.f21383c[i9];
                        if (obj2 instanceof O) {
                            o.f(obj2, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap>");
                            O o6 = (O) obj2;
                            o6.l(scope);
                            zB = o6.b();
                        } else {
                            zB = obj2 == scope;
                        }
                        if (zB) {
                            n6.k(i9);
                        }
                    }
                    j4 >>= 8;
                }
                if (i7 != 8) {
                    return;
                }
            }
            if (i6 == length) {
                return;
            } else {
                i6++;
            }
        }
    }

    /* JADX INFO: renamed from: removeScopeIf-impl, reason: not valid java name */
    public static final void m193removeScopeIfimpl(N n6, c cVar) {
        long[] jArr;
        long[] jArr2;
        long j4;
        char c6;
        long j6;
        int i6;
        boolean zBooleanValue;
        O o6;
        long[] jArr3;
        int i7;
        O o7;
        long[] jArr4 = n6.f21381a;
        int length = jArr4.length - 2;
        if (length < 0) {
            return;
        }
        int i8 = 0;
        while (true) {
            long j7 = jArr4[i8];
            char c7 = 7;
            long j8 = -9187201950435737472L;
            if ((((~j7) << 7) & j7 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i9 = 8;
                int i10 = 8 - ((~(i8 - length)) >>> 31);
                int i11 = 0;
                while (i11 < i10) {
                    if ((j7 & 255) < 128) {
                        int i12 = (i8 << 3) + i11;
                        c6 = c7;
                        Object obj = n6.f21382b[i12];
                        Object obj2 = n6.f21383c[i12];
                        j6 = j8;
                        if (obj2 instanceof O) {
                            o.f(obj2, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap>");
                            O o8 = (O) obj2;
                            Object[] objArr = o8.f21389b;
                            long[] jArr5 = o8.f21388a;
                            int length2 = jArr5.length - 2;
                            if (length2 >= 0) {
                                int i13 = i9;
                                O o9 = o8;
                                int i14 = 0;
                                while (true) {
                                    long j9 = jArr5[i14];
                                    j4 = j7;
                                    if ((((~j9) << c6) & j9 & j6) != j6) {
                                        int i15 = 8 - ((~(i14 - length2)) >>> 31);
                                        int i16 = 0;
                                        while (i16 < i15) {
                                            if ((j9 & 255) < 128) {
                                                jArr3 = jArr4;
                                                int i17 = (i14 << 3) + i16;
                                                i7 = i16;
                                                if (((Boolean) cVar.invoke(objArr[i17])).booleanValue()) {
                                                    o7 = o9;
                                                    o7.m(i17);
                                                }
                                                j9 >>= i13;
                                                o9 = o7;
                                                i16 = i7 + 1;
                                                jArr4 = jArr3;
                                            } else {
                                                jArr3 = jArr4;
                                                i7 = i16;
                                            }
                                            o7 = o9;
                                            j9 >>= i13;
                                            o9 = o7;
                                            i16 = i7 + 1;
                                            jArr4 = jArr3;
                                        }
                                        jArr2 = jArr4;
                                        o6 = o9;
                                        if (i15 != i13) {
                                            break;
                                        }
                                    } else {
                                        jArr2 = jArr4;
                                        o6 = o9;
                                    }
                                    if (i14 == length2) {
                                        break;
                                    }
                                    i14++;
                                    o9 = o6;
                                    j7 = j4;
                                    jArr4 = jArr2;
                                    i13 = 8;
                                }
                            } else {
                                jArr2 = jArr4;
                                j4 = j7;
                                o6 = o8;
                            }
                            zBooleanValue = o6.b();
                        } else {
                            jArr2 = jArr4;
                            j4 = j7;
                            o.f(obj2, "null cannot be cast to non-null type Scope of androidx.compose.runtime.collection.ScopeMap");
                            zBooleanValue = ((Boolean) cVar.invoke(obj2)).booleanValue();
                        }
                        if (zBooleanValue) {
                            n6.k(i12);
                        }
                        i6 = 8;
                    } else {
                        jArr2 = jArr4;
                        j4 = j7;
                        c6 = c7;
                        j6 = j8;
                        i6 = i9;
                    }
                    j7 = j4 >> i6;
                    i11++;
                    i9 = i6;
                    c7 = c6;
                    j8 = j6;
                    jArr4 = jArr2;
                }
                jArr = jArr4;
                if (i10 != i9) {
                    return;
                }
            } else {
                jArr = jArr4;
            }
            if (i8 == length) {
                return;
            }
            i8++;
            jArr4 = jArr;
        }
    }

    /* JADX INFO: renamed from: set-impl, reason: not valid java name */
    public static final void m194setimpl(N n6, Key key, Scope scope) {
        n6.l(key, scope);
    }

    /* JADX INFO: renamed from: toString-impl, reason: not valid java name */
    public static String m195toStringimpl(N n6) {
        return "ScopeMap(map=" + n6 + ')';
    }

    public boolean equals(Object obj) {
        return m185equalsimpl(this.map, obj);
    }

    public final N getMap() {
        return this.map;
    }

    public int hashCode() {
        return m189hashCodeimpl(this.map);
    }

    public String toString() {
        return m195toStringimpl(this.map);
    }

    /* JADX INFO: renamed from: unbox-impl, reason: not valid java name */
    public final /* synthetic */ N m196unboximpl() {
        return this.map;
    }

    /* JADX INFO: renamed from: constructor-impl, reason: not valid java name */
    public static <Key, Scope> N m182constructorimpl(N n6) {
        return n6;
    }
}
