package androidx.compose.runtime.snapshots; import androidx.compose.runtime.external.kotlinx.collections.immutable.ImmutableSet; import androidx.compose.runtime.external.kotlinx.collections.immutable.PersistentMap; import androidx.compose.runtime.snapshots.SnapshotStateMap; import androidx.exifinterface.media.ExifInterface; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import kotlin.KotlinNothingValueException; import kotlin.Metadata; import kotlin.Pair; import kotlin.TuplesKt; import kotlin.Unit; import kotlin.collections.CollectionsKt; import kotlin.collections.MapsKt; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.TypeIntrinsics; import kotlin.ranges.RangesKt; /* compiled from: SnapshotStateMap.kt */ @Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010'\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0001\n\u0002\b\u0003\n\u0002\u0010\u001e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010)\n\u0002\b\u0004\b\u0002\u0018\u0000*\u0004\b\u0000\u0010\u0001*\u0004\b\u0001\u0010\u00022 \u0012\u0004\u0012\u0002H\u0001\u0012\u0004\u0012\u0002H\u0002\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u0002H\u0001\u0012\u0004\u0012\u0002H\u00020\u00040\u0003B\u0019\u0012\u0012\u0010\u0005\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u0006¢\u0006\u0002\u0010\u0007J\u001c\u0010\b\u001a\u00020\t2\u0012\u0010\n\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u0004H\u0016J\"\u0010\u000b\u001a\u00020\t2\u0018\u0010\f\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u00040\rH\u0016J\u001d\u0010\u000e\u001a\u00020\u000f2\u0012\u0010\n\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u0004H\u0096\u0002J\"\u0010\u0010\u001a\u00020\u000f2\u0018\u0010\f\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u00040\rH\u0016J\u001b\u0010\u0011\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u00040\u0012H\u0096\u0002J\u001c\u0010\u0013\u001a\u00020\u000f2\u0012\u0010\n\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u0004H\u0016J\"\u0010\u0014\u001a\u00020\u000f2\u0018\u0010\f\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u00040\rH\u0016J\"\u0010\u0015\u001a\u00020\u000f2\u0018\u0010\f\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\u00040\rH\u0016¨\u0006\u0016"}, d2 = {"Landroidx/compose/runtime/snapshots/SnapshotMapEntrySet;", "K", ExifInterface.GPS_MEASUREMENT_INTERRUPTED, "Landroidx/compose/runtime/snapshots/SnapshotMapSet;", "", "map", "Landroidx/compose/runtime/snapshots/SnapshotStateMap;", "(Landroidx/compose/runtime/snapshots/SnapshotStateMap;)V", "add", "", "element", "addAll", "elements", "", "contains", "", "containsAll", "iterator", "", "remove", "removeAll", "retainAll", "runtime_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ final class SnapshotMapEntrySet extends SnapshotMapSet> { @Override // java.util.Set, java.util.Collection public /* bridge */ /* synthetic */ boolean add(Object obj) { return ((Boolean) add((Map.Entry) obj)).booleanValue(); } @Override // java.util.Set, java.util.Collection public /* bridge */ /* synthetic */ boolean addAll(Collection collection) { return ((Boolean) addAll(collection)).booleanValue(); } @Override // java.util.Set, java.util.Collection public final /* bridge */ boolean contains(Object obj) { if (TypeIntrinsics.isMutableMapEntry(obj)) { return contains((Map.Entry) obj); } return false; } @Override // java.util.Set, java.util.Collection public final /* bridge */ boolean remove(Object obj) { if (TypeIntrinsics.isMutableMapEntry(obj)) { return remove((Map.Entry) obj); } return false; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public SnapshotMapEntrySet(SnapshotStateMap map) { super(map); Intrinsics.checkNotNullParameter(map, "map"); } public Void add(Map.Entry element) { Intrinsics.checkNotNullParameter(element, "element"); SnapshotStateMapKt.unsupported(); throw new KotlinNothingValueException(); } @Override // java.util.Set, java.util.Collection public Void addAll(Collection> elements) { Intrinsics.checkNotNullParameter(elements, "elements"); SnapshotStateMapKt.unsupported(); throw new KotlinNothingValueException(); } @Override // java.util.Set, java.util.Collection, java.lang.Iterable public Iterator> iterator() { return new StateMapMutableEntriesIterator(getMap(), ((ImmutableSet) getMap().getReadable$runtime_release().getMap$runtime_release().entrySet()).iterator()); } public boolean remove(Map.Entry element) { Intrinsics.checkNotNullParameter(element, "element"); return getMap().remove(element.getKey()) != null; } @Override // java.util.Set, java.util.Collection public boolean removeAll(Collection elements) { Intrinsics.checkNotNullParameter(elements, "elements"); Iterator it = elements.iterator(); while (true) { boolean z = false; while (it.hasNext()) { if (getMap().remove(((Map.Entry) it.next()).getKey()) != null || z) { z = true; } } return z; } } /* JADX WARN: Multi-variable type inference failed */ @Override // java.util.Set, java.util.Collection public boolean retainAll(Collection elements) { Object obj; PersistentMap map$runtime_release; int modification; boolean z; Snapshot current; Object obj2; Intrinsics.checkNotNullParameter(elements, "elements"); Collection collection = elements; LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(collection, 10)), 16)); Iterator it = collection.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Pair pair = TuplesKt.to(entry.getKey(), entry.getValue()); linkedHashMap.put(pair.getFirst(), pair.getSecond()); } SnapshotStateMap map = getMap(); boolean z2 = false; do { obj = SnapshotStateMapKt.sync; synchronized (obj) { StateRecord firstStateRecord = map.getFirstStateRecord(); Intrinsics.checkNotNull(firstStateRecord, "null cannot be cast to non-null type androidx.compose.runtime.snapshots.SnapshotStateMap.StateMapStateRecord"); SnapshotStateMap.StateMapStateRecord stateMapStateRecord = (SnapshotStateMap.StateMapStateRecord) SnapshotKt.current((SnapshotStateMap.StateMapStateRecord) firstStateRecord); map$runtime_release = stateMapStateRecord.getMap$runtime_release(); modification = stateMapStateRecord.getModification(); Unit unit = Unit.INSTANCE; } Intrinsics.checkNotNull(map$runtime_release); PersistentMap.Builder builder2 = map$runtime_release.builder2(); PersistentMap.Builder builder = builder2; Iterator> it2 = map.entrySet().iterator(); while (true) { z = true; if (!it2.hasNext()) { break; } Map.Entry next = it2.next(); if (!linkedHashMap.containsKey(next.getKey()) || !Intrinsics.areEqual(linkedHashMap.get(next.getKey()), next.getValue())) { builder.remove(next.getKey()); z2 = true; } } Unit unit2 = Unit.INSTANCE; PersistentMap build2 = builder2.build2(); if (Intrinsics.areEqual(build2, map$runtime_release)) { break; } StateRecord firstStateRecord2 = map.getFirstStateRecord(); Intrinsics.checkNotNull(firstStateRecord2, "null cannot be cast to non-null type androidx.compose.runtime.snapshots.SnapshotStateMap.StateMapStateRecord"); SnapshotStateMap.StateMapStateRecord stateMapStateRecord2 = (SnapshotStateMap.StateMapStateRecord) firstStateRecord2; SnapshotKt.getSnapshotInitializer(); synchronized (SnapshotKt.getLock()) { current = Snapshot.INSTANCE.getCurrent(); SnapshotStateMap.StateMapStateRecord stateMapStateRecord3 = (SnapshotStateMap.StateMapStateRecord) SnapshotKt.writableRecord(stateMapStateRecord2, map, current); obj2 = SnapshotStateMapKt.sync; synchronized (obj2) { if (stateMapStateRecord3.getModification() == modification) { stateMapStateRecord3.setMap$runtime_release(build2); stateMapStateRecord3.setModification$runtime_release(stateMapStateRecord3.getModification() + 1); } else { z = false; } } } SnapshotKt.notifyWrite(current, map); } while (!z); return z2; } public boolean contains(Map.Entry element) { Intrinsics.checkNotNullParameter(element, "element"); return Intrinsics.areEqual(getMap().get(element.getKey()), element.getValue()); } @Override // java.util.Set, java.util.Collection public boolean containsAll(Collection elements) { Intrinsics.checkNotNullParameter(elements, "elements"); Collection collection = elements; if (collection.isEmpty()) { return true; } Iterator it = collection.iterator(); while (it.hasNext()) { if (!contains(it.next())) { return false; } } return true; } }