package o;

import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class J90 {
    public final OC a;
    public boolean c;
    public G1 h;
    public I90 i;
    public final AtomicReference b = new AtomicReference(null);
    public final C1825m2 d = new C1825m2(14, this);
    public final S1 e = new S1(21, this);
    public final C1479iR f = new C1479iR(new I90[16]);
    public final Object g = new Object();
    public long j = -1;

    public J90(OC oc) {
        this.a = oc;
    }

    public final void a() {
        synchronized (this.g) {
            C1479iR c1479iR = this.f;
            Object[] objArr = c1479iR.l;
            int i = c1479iR.n;
            for (int i2 = 0; i2 < i; i2++) {
                I90 i90 = (I90) objArr[i2];
                i90.e.a();
                i90.f.a();
                i90.k.a();
                i90.l.clear();
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final boolean b() {
        boolean z;
        Set set;
        Set set2;
        synchronized (this.g) {
            z = this.c;
        }
        if (z) {
            return false;
        }
        boolean z2 = false;
        while (true) {
            AtomicReference atomicReference = this.b;
            while (true) {
                Object obj = atomicReference.get();
                set = null;
                List list = null;
                List listSubList = null;
                if (obj == null) {
                    break;
                }
                if (obj instanceof Set) {
                    set2 = (Set) obj;
                } else {
                    if (!(obj instanceof List)) {
                        AbstractC0373Ok.d("Unexpected notification");
                        throw new C2170pj();
                    }
                    List list2 = (List) obj;
                    Set set3 = (Set) list2.get(0);
                    if (list2.size() == 2) {
                        listSubList = list2.get(1);
                    } else if (list2.size() > 2) {
                        listSubList = list2.subList(1, list2.size());
                    }
                    set2 = set3;
                    list = listSubList;
                }
                while (!atomicReference.compareAndSet(obj, list)) {
                    if (atomicReference.get() != obj) {
                        break;
                    }
                }
                set = set2;
                break;
            }
            if (set == null) {
                return z2;
            }
            synchronized (this.g) {
                C1479iR c1479iR = this.f;
                Object[] objArr = c1479iR.l;
                int i = c1479iR.n;
                for (int i2 = 0; i2 < i; i2++) {
                    z2 = ((I90) objArr[i2]).b(set) || z2;
                }
            }
        }
    }

    public final void c(Object obj, OC oc, NC nc) {
        Object obj2;
        I90 i90;
        synchronized (this.g) {
            C1479iR c1479iR = this.f;
            Object[] objArr = c1479iR.l;
            int i = c1479iR.n;
            int i2 = 0;
            while (true) {
                if (i2 >= i) {
                    obj2 = null;
                    break;
                }
                obj2 = objArr[i2];
                if (((I90) obj2).a == oc) {
                    break;
                } else {
                    i2++;
                }
            }
            i90 = (I90) obj2;
            if (i90 == null) {
                AbstractC1692kh0.l(1, oc);
                i90 = new I90(oc);
                c1479iR.b(i90);
            }
        }
        I90 i902 = this.i;
        long j = this.j;
        if (j != -1 && j != AbstractC2539te.v()) {
            AbstractC1102eY.a("Detected multithreaded access to SnapshotStateObserver: previousThreadId=" + j + "), currentThread={id=" + AbstractC2539te.v() + ", name=" + Thread.currentThread().getName() + "}. Note that observation on multiple threads in layout/draw is not supported. Make sure your measure/layout/draw for each Owner (AndroidComposeView) is executed on the same thread.");
        }
        try {
            this.i = i90;
            this.j = AbstractC2539te.v();
            i90.a(obj, this.e, nc);
        } finally {
            this.i = i902;
            this.j = j;
        }
    }

    public final void d() {
        C1825m2 c1825m2 = this.d;
        AbstractC2884x90.f(AbstractC2884x90.a);
        synchronized (AbstractC2884x90.c) {
            AbstractC2884x90.h = AbstractC3117zi.m0((List) AbstractC2884x90.h, c1825m2);
        }
        this.h = new G1(13, c1825m2);
    }
}
