package i2;

import j2.b1;
import j2.g0;
import j2.j1;
import j2.m;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import kotlin.jvm.internal.v;
import l1.i;
import rm.n0;

/* loaded from: classes.dex */
public final class f {

    /* renamed from: a, reason: collision with root package name */
    private final j1 f22294a;

    /* renamed from: b, reason: collision with root package name */
    private final a1.b f22295b = new a1.b(new j2.c[16], 0);

    /* renamed from: c, reason: collision with root package name */
    private final a1.b f22296c = new a1.b(new c[16], 0);

    /* renamed from: d, reason: collision with root package name */
    private final a1.b f22297d = new a1.b(new g0[16], 0);

    /* renamed from: e, reason: collision with root package name */
    private final a1.b f22298e = new a1.b(new c[16], 0);

    /* renamed from: f, reason: collision with root package name */
    private boolean f22299f;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends v implements dn.a {
        a() {
            super(0);
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m261invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m261invoke() {
            f.this.e();
        }
    }

    public f(j1 j1Var) {
        this.f22294a = j1Var;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v0 */
    /* JADX WARN: Type inference failed for: r6v1, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r6v10 */
    /* JADX WARN: Type inference failed for: r6v11 */
    /* JADX WARN: Type inference failed for: r6v12 */
    /* JADX WARN: Type inference failed for: r6v13 */
    /* JADX WARN: Type inference failed for: r6v14 */
    /* JADX WARN: Type inference failed for: r6v6 */
    /* JADX WARN: Type inference failed for: r6v7, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r6v8, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r6v9 */
    /* JADX WARN: Type inference failed for: r7v0 */
    /* JADX WARN: Type inference failed for: r7v1 */
    /* JADX WARN: Type inference failed for: r7v10 */
    /* JADX WARN: Type inference failed for: r7v11 */
    /* JADX WARN: Type inference failed for: r7v2 */
    /* JADX WARN: Type inference failed for: r7v3, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r7v4 */
    /* JADX WARN: Type inference failed for: r7v5 */
    /* JADX WARN: Type inference failed for: r7v6, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r7v8 */
    /* JADX WARN: Type inference failed for: r7v9 */
    private final void c(i.c cVar, c cVar2, Set set) {
        boolean z10;
        int a10 = b1.a(32);
        if (!cVar.P0().O1()) {
            g2.a.b("visitSubtreeIf called on an unattached node");
        }
        a1.b bVar = new a1.b(new i.c[16], 0);
        i.c F1 = cVar.P0().F1();
        if (F1 == null) {
            j2.k.c(bVar, cVar.P0());
        } else {
            bVar.c(F1);
        }
        while (bVar.t()) {
            i.c cVar3 = (i.c) bVar.z(bVar.q() - 1);
            if ((cVar3.E1() & a10) != 0) {
                for (i.c cVar4 = cVar3; cVar4 != null; cVar4 = cVar4.F1()) {
                    if ((cVar4.J1() & a10) != 0) {
                        m mVar = cVar4;
                        ?? r72 = 0;
                        while (true) {
                            if (mVar == 0) {
                                z10 = true;
                                break;
                            }
                            if (mVar instanceof h) {
                                h hVar = (h) mVar;
                                if (hVar instanceof j2.c) {
                                    j2.c cVar5 = (j2.c) hVar;
                                    if ((cVar5.h2() instanceof d) && cVar5.i2().contains(cVar2)) {
                                        set.add(hVar);
                                    }
                                }
                                if (!(!hVar.D0().a(cVar2))) {
                                    z10 = false;
                                    break;
                                }
                            } else if (((mVar.J1() & a10) != 0) && (mVar instanceof m)) {
                                i.c i22 = mVar.i2();
                                int i10 = 0;
                                mVar = mVar;
                                r72 = r72;
                                while (i22 != null) {
                                    if ((i22.J1() & a10) != 0) {
                                        i10++;
                                        r72 = r72;
                                        if (i10 == 1) {
                                            mVar = i22;
                                        } else {
                                            if (r72 == 0) {
                                                r72 = new a1.b(new i.c[16], 0);
                                            }
                                            if (mVar != 0) {
                                                r72.c(mVar);
                                                mVar = 0;
                                            }
                                            r72.c(i22);
                                        }
                                    }
                                    i22 = i22.F1();
                                    mVar = mVar;
                                    r72 = r72;
                                }
                                if (i10 == 1) {
                                }
                            }
                            mVar = j2.k.g(r72);
                        }
                        if (z10) {
                        }
                    }
                }
            }
            j2.k.c(bVar, cVar3);
        }
    }

    public final void a(j2.c cVar, c cVar2) {
        this.f22295b.c(cVar);
        this.f22296c.c(cVar2);
        b();
    }

    public final void b() {
        if (this.f22299f) {
            return;
        }
        this.f22299f = true;
        this.f22294a.B(new a());
    }

    public final void d(j2.c cVar, c cVar2) {
        this.f22297d.c(j2.k.m(cVar));
        this.f22298e.c(cVar2);
        b();
    }

    public final void e() {
        int i10 = 0;
        this.f22299f = false;
        HashSet hashSet = new HashSet();
        a1.b bVar = this.f22297d;
        int q10 = bVar.q();
        if (q10 > 0) {
            Object[] p10 = bVar.p();
            int i11 = 0;
            do {
                g0 g0Var = (g0) p10[i11];
                c cVar = (c) this.f22298e.p()[i11];
                if (g0Var.k0().k().O1()) {
                    c(g0Var.k0().k(), cVar, hashSet);
                }
                i11++;
            } while (i11 < q10);
        }
        this.f22297d.k();
        this.f22298e.k();
        a1.b bVar2 = this.f22295b;
        int q11 = bVar2.q();
        if (q11 > 0) {
            Object[] p11 = bVar2.p();
            do {
                j2.c cVar2 = (j2.c) p11[i10];
                c cVar3 = (c) this.f22296c.p()[i10];
                if (cVar2.O1()) {
                    c(cVar2, cVar3, hashSet);
                }
                i10++;
            } while (i10 < q11);
        }
        this.f22295b.k();
        this.f22296c.k();
        Iterator it = hashSet.iterator();
        while (it.hasNext()) {
            ((j2.c) it.next()).n2();
        }
    }

    public final void f(j2.c cVar, c cVar2) {
        this.f22295b.c(cVar);
        this.f22296c.c(cVar2);
        b();
    }
}
