package d2;

import d2.q;
import j2.b1;
import j2.p1;
import j2.q1;
import java.util.ArrayList;
import java.util.List;
import l1.i;

/* loaded from: classes.dex */
public final class j extends k {

    /* renamed from: c, reason: collision with root package name */
    private final i.c f15815c;

    /* renamed from: f, reason: collision with root package name */
    private h2.s f15818f;

    /* renamed from: g, reason: collision with root package name */
    private m f15819g;

    /* renamed from: h, reason: collision with root package name */
    private boolean f15820h;

    /* renamed from: d, reason: collision with root package name */
    private final e2.b f15816d = new e2.b();

    /* renamed from: e, reason: collision with root package name */
    private final androidx.collection.s f15817e = new androidx.collection.s(2);

    /* renamed from: i, reason: collision with root package name */
    private boolean f15821i = true;

    /* renamed from: j, reason: collision with root package name */
    private boolean f15822j = true;

    public j(i.c cVar) {
        this.f15815c = cVar;
    }

    private final void j() {
        this.f15817e.a();
        this.f15818f = null;
    }

    private final boolean m(m mVar, m mVar2) {
        if (mVar == null || mVar.c().size() != mVar2.c().size()) {
            return true;
        }
        int size = mVar2.c().size();
        for (int i10 = 0; i10 < size; i10++) {
            if (!r1.g.j(((y) mVar.c().get(i10)).h(), ((y) mVar2.c().get(i10)).h())) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0206  */
    /* JADX WARN: Type inference failed for: r10v0 */
    /* JADX WARN: Type inference failed for: r10v1 */
    /* JADX WARN: Type inference failed for: r10v10 */
    /* JADX WARN: Type inference failed for: r10v11 */
    /* JADX WARN: Type inference failed for: r10v2 */
    /* JADX WARN: Type inference failed for: r10v3, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r10v4 */
    /* JADX WARN: Type inference failed for: r10v5 */
    /* JADX WARN: Type inference failed for: r10v6, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r10v8 */
    /* JADX WARN: Type inference failed for: r10v9 */
    /* JADX WARN: Type inference failed for: r5v2, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r5v20 */
    /* JADX WARN: Type inference failed for: r5v21, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r5v22, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r5v23 */
    /* JADX WARN: Type inference failed for: r5v24 */
    /* JADX WARN: Type inference failed for: r5v25 */
    /* JADX WARN: Type inference failed for: r5v26 */
    /* JADX WARN: Type inference failed for: r5v27 */
    /* JADX WARN: Type inference failed for: r5v28 */
    /* JADX WARN: Type inference failed for: r5v3, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r6v9, types: [java.lang.Object] */
    @Override // d2.k
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean a(androidx.collection.s sVar, h2.s sVar2, g gVar, boolean z10) {
        y yVar;
        boolean z11;
        boolean z12;
        int f10;
        q.a aVar;
        boolean z13;
        int i10;
        int i11;
        y b10;
        List list;
        int i12;
        boolean a10 = super.a(sVar, sVar2, gVar, z10);
        if (!this.f15815c.O1()) {
            return true;
        }
        j2.m mVar = this.f15815c;
        int a11 = b1.a(16);
        ?? r10 = 0;
        while (mVar != 0) {
            if (mVar instanceof p1) {
                this.f15818f = q1.a((p1) mVar);
            } else if (((mVar.J1() & a11) != 0) && (mVar instanceof j2.m)) {
                i.c i22 = mVar.i2();
                int i13 = 0;
                mVar = mVar;
                r10 = r10;
                while (i22 != null) {
                    if ((i22.J1() & a11) != 0) {
                        i13++;
                        r10 = r10;
                        if (i13 == 1) {
                            mVar = i22;
                        } else {
                            if (r10 == 0) {
                                r10 = new a1.b(new i.c[16], 0);
                            }
                            if (mVar != 0) {
                                r10.c(mVar);
                                mVar = 0;
                            }
                            r10.c(i22);
                        }
                    }
                    i22 = i22.F1();
                    mVar = mVar;
                    r10 = r10;
                }
                if (i13 == 1) {
                }
            }
            mVar = j2.k.g(r10);
        }
        int n10 = sVar.n();
        int i14 = 0;
        while (i14 < n10) {
            long i15 = sVar.i(i14);
            y yVar2 = (y) sVar.o(i14);
            if (this.f15816d.d(i15)) {
                long k10 = yVar2.k();
                i11 = i14;
                long h10 = yVar2.h();
                if (r1.g.p(k10) && r1.g.p(h10)) {
                    ArrayList arrayList = new ArrayList(yVar2.e().size());
                    List e10 = yVar2.e();
                    int size = e10.size();
                    i10 = n10;
                    int i16 = 0;
                    while (i16 < size) {
                        e eVar = (e) e10.get(i16);
                        boolean z14 = a10;
                        long b11 = eVar.b();
                        if (r1.g.p(b11)) {
                            list = e10;
                            long c10 = eVar.c();
                            i12 = size;
                            h2.s sVar3 = this.f15818f;
                            kotlin.jvm.internal.t.d(sVar3);
                            arrayList.add(new e(c10, sVar3.B(sVar2, b11), eVar.a(), null));
                        } else {
                            list = e10;
                            i12 = size;
                        }
                        i16++;
                        e10 = list;
                        size = i12;
                        a10 = z14;
                    }
                    z13 = a10;
                    androidx.collection.s sVar4 = this.f15817e;
                    h2.s sVar5 = this.f15818f;
                    kotlin.jvm.internal.t.d(sVar5);
                    long B = sVar5.B(sVar2, k10);
                    h2.s sVar6 = this.f15818f;
                    kotlin.jvm.internal.t.d(sVar6);
                    b10 = yVar2.b((r34 & 1) != 0 ? yVar2.f15884a : 0L, (r34 & 2) != 0 ? yVar2.f15885b : 0L, (r34 & 4) != 0 ? yVar2.f15886c : sVar6.B(sVar2, h10), (r34 & 8) != 0 ? yVar2.f15887d : false, (r34 & 16) != 0 ? yVar2.f15889f : 0L, (r34 & 32) != 0 ? yVar2.f15890g : B, (r34 & 64) != 0 ? yVar2.f15891h : false, (r34 & 128) != 0 ? yVar2.f15892i : 0, arrayList, (r34 & 512) != 0 ? yVar2.f15893j : 0L);
                    sVar4.j(i15, b10);
                } else {
                    z13 = a10;
                    i10 = n10;
                }
            } else {
                z13 = a10;
                i10 = n10;
                i11 = i14;
            }
            i14 = i11 + 1;
            n10 = i10;
            a10 = z13;
        }
        boolean z15 = a10;
        if (this.f15817e.h()) {
            this.f15816d.c();
            g().k();
            return true;
        }
        for (int f11 = this.f15816d.f() - 1; -1 < f11; f11--) {
            if (!sVar.c(this.f15816d.e(f11))) {
                this.f15816d.j(f11);
            }
        }
        ArrayList arrayList2 = new ArrayList(this.f15817e.n());
        int n11 = this.f15817e.n();
        for (int i17 = 0; i17 < n11; i17++) {
            arrayList2.add(this.f15817e.o(i17));
        }
        m mVar2 = new m(arrayList2, gVar);
        List c11 = mVar2.c();
        int size2 = c11.size();
        int i18 = 0;
        while (true) {
            if (i18 >= size2) {
                yVar = null;
                break;
            }
            ?? r62 = c11.get(i18);
            if (gVar.a(((y) r62).f())) {
                yVar = r62;
                break;
            }
            i18++;
        }
        y yVar3 = yVar;
        if (yVar3 != null) {
            if (z10) {
                z11 = false;
                if (!this.f15821i && (yVar3.i() || yVar3.l())) {
                    kotlin.jvm.internal.t.d(this.f15818f);
                    z12 = true;
                    this.f15821i = !n.e(yVar3, r3.g());
                    if (this.f15821i != this.f15820h) {
                        int f12 = mVar2.f();
                        q.a aVar2 = q.f15839a;
                        if (q.i(f12, aVar2.c()) || q.i(mVar2.f(), aVar2.a()) || q.i(mVar2.f(), aVar2.b())) {
                            mVar2.g(this.f15821i ? aVar2.a() : aVar2.b());
                        }
                    }
                    f10 = mVar2.f();
                    aVar = q.f15839a;
                    if (!q.i(f10, aVar.a()) && this.f15820h && !this.f15822j) {
                        mVar2.g(aVar.c());
                    } else if (q.i(mVar2.f(), aVar.b()) && this.f15821i && yVar3.i()) {
                        mVar2.g(aVar.c());
                    }
                }
            } else {
                z11 = false;
                this.f15821i = false;
            }
            z12 = true;
            if (this.f15821i != this.f15820h) {
            }
            f10 = mVar2.f();
            aVar = q.f15839a;
            if (!q.i(f10, aVar.a())) {
            }
            if (q.i(mVar2.f(), aVar.b())) {
                mVar2.g(aVar.c());
            }
        } else {
            z11 = false;
            z12 = true;
        }
        boolean z16 = (z15 || !q.i(mVar2.f(), q.f15839a.c()) || m(this.f15819g, mVar2)) ? z12 : z11;
        this.f15819g = mVar2;
        return z16;
    }

    @Override // d2.k
    public void b(g gVar) {
        super.b(gVar);
        m mVar = this.f15819g;
        if (mVar == null) {
            return;
        }
        this.f15820h = this.f15821i;
        List c10 = mVar.c();
        int size = c10.size();
        for (int i10 = 0; i10 < size; i10++) {
            y yVar = (y) c10.get(i10);
            boolean z10 = true;
            boolean z11 = !yVar.i();
            boolean z12 = !gVar.a(yVar.f());
            boolean z13 = !this.f15821i;
            if ((!z11 || !z12) && (!z11 || !z13)) {
                z10 = false;
            }
            if (z10) {
                this.f15816d.i(yVar.f());
            }
        }
        this.f15821i = false;
        this.f15822j = q.i(mVar.f(), q.f15839a.b());
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r5v0 */
    /* JADX WARN: Type inference failed for: r5v1 */
    /* JADX WARN: Type inference failed for: r5v10 */
    /* JADX WARN: Type inference failed for: r5v11 */
    /* JADX WARN: Type inference failed for: r5v12 */
    /* JADX WARN: Type inference failed for: r5v13 */
    /* JADX WARN: Type inference failed for: r5v2 */
    /* JADX WARN: Type inference failed for: r5v3, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r5v4 */
    /* JADX WARN: Type inference failed for: r5v5 */
    /* JADX WARN: Type inference failed for: r5v6, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r9v1, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r9v10 */
    /* JADX WARN: Type inference failed for: r9v11 */
    /* JADX WARN: Type inference failed for: r9v12 */
    /* JADX WARN: Type inference failed for: r9v2, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r9v4 */
    /* JADX WARN: Type inference failed for: r9v5, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r9v6, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r9v7 */
    /* JADX WARN: Type inference failed for: r9v8 */
    /* JADX WARN: Type inference failed for: r9v9 */
    @Override // d2.k
    public void d() {
        a1.b g10 = g();
        int q10 = g10.q();
        if (q10 > 0) {
            Object[] p10 = g10.p();
            int i10 = 0;
            do {
                ((j) p10[i10]).d();
                i10++;
            } while (i10 < q10);
        }
        j2.m mVar = this.f15815c;
        int a10 = b1.a(16);
        ?? r52 = 0;
        while (mVar != 0) {
            if (mVar instanceof p1) {
                ((p1) mVar).q0();
            } else {
                if (((mVar.J1() & a10) != 0) && (mVar instanceof j2.m)) {
                    i.c i22 = mVar.i2();
                    int i11 = 0;
                    r52 = r52;
                    mVar = mVar;
                    while (i22 != null) {
                        if ((i22.J1() & a10) != 0) {
                            i11++;
                            r52 = r52;
                            if (i11 == 1) {
                                mVar = i22;
                            } else {
                                if (r52 == 0) {
                                    r52 = new a1.b(new i.c[16], 0);
                                }
                                if (mVar != 0) {
                                    r52.c(mVar);
                                    mVar = 0;
                                }
                                r52.c(i22);
                            }
                        }
                        i22 = i22.F1();
                        r52 = r52;
                        mVar = mVar;
                    }
                    if (i11 == 1) {
                    }
                }
            }
            mVar = j2.k.g(r52);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r4v0, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r4v1, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r4v10 */
    /* JADX WARN: Type inference failed for: r4v11 */
    /* JADX WARN: Type inference failed for: r4v3 */
    /* JADX WARN: Type inference failed for: r4v4, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r4v5, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r4v6 */
    /* JADX WARN: Type inference failed for: r4v7 */
    /* JADX WARN: Type inference failed for: r4v8 */
    /* JADX WARN: Type inference failed for: r4v9 */
    /* JADX WARN: Type inference failed for: r8v0 */
    /* JADX WARN: Type inference failed for: r8v1 */
    /* JADX WARN: Type inference failed for: r8v10 */
    /* JADX WARN: Type inference failed for: r8v11 */
    /* JADX WARN: Type inference failed for: r8v2 */
    /* JADX WARN: Type inference failed for: r8v3, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r8v4 */
    /* JADX WARN: Type inference failed for: r8v5 */
    /* JADX WARN: Type inference failed for: r8v6, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r8v8 */
    /* JADX WARN: Type inference failed for: r8v9 */
    @Override // d2.k
    public boolean e(g gVar) {
        a1.b g10;
        int q10;
        boolean z10 = false;
        int i10 = 0;
        z10 = false;
        if (!this.f15817e.h() && this.f15815c.O1()) {
            m mVar = this.f15819g;
            kotlin.jvm.internal.t.d(mVar);
            h2.s sVar = this.f15818f;
            kotlin.jvm.internal.t.d(sVar);
            long g11 = sVar.g();
            j2.m mVar2 = this.f15815c;
            int a10 = b1.a(16);
            ?? r82 = 0;
            while (mVar2 != 0) {
                if (mVar2 instanceof p1) {
                    ((p1) mVar2).d0(mVar, o.Final, g11);
                } else {
                    if (((mVar2.J1() & a10) != 0) && (mVar2 instanceof j2.m)) {
                        i.c i22 = mVar2.i2();
                        int i11 = 0;
                        mVar2 = mVar2;
                        r82 = r82;
                        while (i22 != null) {
                            if ((i22.J1() & a10) != 0) {
                                i11++;
                                r82 = r82;
                                if (i11 == 1) {
                                    mVar2 = i22;
                                } else {
                                    if (r82 == 0) {
                                        r82 = new a1.b(new i.c[16], 0);
                                    }
                                    if (mVar2 != 0) {
                                        r82.c(mVar2);
                                        mVar2 = 0;
                                    }
                                    r82.c(i22);
                                }
                            }
                            i22 = i22.F1();
                            mVar2 = mVar2;
                            r82 = r82;
                        }
                        if (i11 == 1) {
                        }
                    }
                }
                mVar2 = j2.k.g(r82);
            }
            if (this.f15815c.O1() && (q10 = (g10 = g()).q()) > 0) {
                Object[] p10 = g10.p();
                do {
                    ((j) p10[i10]).e(gVar);
                    i10++;
                } while (i10 < q10);
            }
            z10 = true;
        }
        b(gVar);
        j();
        return z10;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r11v1, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r11v10 */
    /* JADX WARN: Type inference failed for: r11v11 */
    /* JADX WARN: Type inference failed for: r11v12 */
    /* JADX WARN: Type inference failed for: r11v2, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r11v4 */
    /* JADX WARN: Type inference failed for: r11v5, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r11v6, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r11v7 */
    /* JADX WARN: Type inference failed for: r11v8 */
    /* JADX WARN: Type inference failed for: r11v9 */
    /* JADX WARN: Type inference failed for: r15v1 */
    /* JADX WARN: Type inference failed for: r15v10 */
    /* JADX WARN: Type inference failed for: r15v11 */
    /* JADX WARN: Type inference failed for: r15v12 */
    /* JADX WARN: Type inference failed for: r15v2 */
    /* JADX WARN: Type inference failed for: r15v3 */
    /* JADX WARN: Type inference failed for: r15v4, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r15v5 */
    /* JADX WARN: Type inference failed for: r15v6 */
    /* JADX WARN: Type inference failed for: r15v7, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r15v9 */
    /* JADX WARN: Type inference failed for: r2v0, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r2v1, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r2v20 */
    /* JADX WARN: Type inference failed for: r2v21, types: [l1.i$c] */
    /* JADX WARN: Type inference failed for: r2v22, types: [java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v23 */
    /* JADX WARN: Type inference failed for: r2v24 */
    /* JADX WARN: Type inference failed for: r2v25 */
    /* JADX WARN: Type inference failed for: r2v26 */
    /* JADX WARN: Type inference failed for: r2v27 */
    /* JADX WARN: Type inference failed for: r2v28 */
    /* JADX WARN: Type inference failed for: r6v0 */
    /* JADX WARN: Type inference failed for: r6v1 */
    /* JADX WARN: Type inference failed for: r6v11 */
    /* JADX WARN: Type inference failed for: r6v12, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r6v13 */
    /* JADX WARN: Type inference failed for: r6v14 */
    /* JADX WARN: Type inference failed for: r6v15, types: [a1.b] */
    /* JADX WARN: Type inference failed for: r6v17 */
    /* JADX WARN: Type inference failed for: r6v18 */
    /* JADX WARN: Type inference failed for: r6v19 */
    /* JADX WARN: Type inference failed for: r6v20 */
    @Override // d2.k
    public boolean f(androidx.collection.s sVar, h2.s sVar2, g gVar, boolean z10) {
        a1.b g10;
        int q10;
        if (this.f15817e.h() || !this.f15815c.O1()) {
            return false;
        }
        m mVar = this.f15819g;
        kotlin.jvm.internal.t.d(mVar);
        h2.s sVar3 = this.f15818f;
        kotlin.jvm.internal.t.d(sVar3);
        long g11 = sVar3.g();
        j2.m mVar2 = this.f15815c;
        int a10 = b1.a(16);
        ?? r62 = 0;
        while (mVar2 != 0) {
            if (mVar2 instanceof p1) {
                ((p1) mVar2).d0(mVar, o.Initial, g11);
            } else {
                if (((mVar2.J1() & a10) != 0) && (mVar2 instanceof j2.m)) {
                    i.c i22 = mVar2.i2();
                    int i10 = 0;
                    mVar2 = mVar2;
                    r62 = r62;
                    while (i22 != null) {
                        if ((i22.J1() & a10) != 0) {
                            i10++;
                            r62 = r62;
                            if (i10 == 1) {
                                mVar2 = i22;
                            } else {
                                if (r62 == 0) {
                                    r62 = new a1.b(new i.c[16], 0);
                                }
                                if (mVar2 != 0) {
                                    r62.c(mVar2);
                                    mVar2 = 0;
                                }
                                r62.c(i22);
                            }
                        }
                        i22 = i22.F1();
                        mVar2 = mVar2;
                        r62 = r62;
                    }
                    if (i10 == 1) {
                    }
                }
            }
            mVar2 = j2.k.g(r62);
        }
        if (this.f15815c.O1() && (q10 = (g10 = g()).q()) > 0) {
            Object[] p10 = g10.p();
            int i11 = 0;
            do {
                j jVar = (j) p10[i11];
                androidx.collection.s sVar4 = this.f15817e;
                h2.s sVar5 = this.f15818f;
                kotlin.jvm.internal.t.d(sVar5);
                jVar.f(sVar4, sVar5, gVar, z10);
                i11++;
            } while (i11 < q10);
        }
        if (this.f15815c.O1()) {
            j2.m mVar3 = this.f15815c;
            int a11 = b1.a(16);
            ?? r15 = 0;
            while (mVar3 != 0) {
                if (mVar3 instanceof p1) {
                    ((p1) mVar3).d0(mVar, o.Main, g11);
                } else {
                    if (((mVar3.J1() & a11) != 0) && (mVar3 instanceof j2.m)) {
                        i.c i23 = mVar3.i2();
                        int i12 = 0;
                        mVar3 = mVar3;
                        r15 = r15;
                        while (i23 != null) {
                            if ((i23.J1() & a11) != 0) {
                                i12++;
                                r15 = r15;
                                if (i12 == 1) {
                                    mVar3 = i23;
                                } else {
                                    if (r15 == 0) {
                                        r15 = new a1.b(new i.c[16], 0);
                                    }
                                    if (mVar3 != 0) {
                                        r15.c(mVar3);
                                        mVar3 = 0;
                                    }
                                    r15.c(i23);
                                }
                            }
                            i23 = i23.F1();
                            mVar3 = mVar3;
                            r15 = r15;
                        }
                        if (i12 == 1) {
                        }
                    }
                }
                mVar3 = j2.k.g(r15);
            }
        }
        return true;
    }

    @Override // d2.k
    public void i(long j10, androidx.collection.e0 e0Var) {
        if (this.f15816d.d(j10) && !e0Var.a(this)) {
            this.f15816d.h(j10);
            this.f15817e.k(j10);
        }
        a1.b g10 = g();
        int q10 = g10.q();
        if (q10 > 0) {
            Object[] p10 = g10.p();
            int i10 = 0;
            do {
                ((j) p10[i10]).i(j10, e0Var);
                i10++;
            } while (i10 < q10);
        }
    }

    public final i.c k() {
        return this.f15815c;
    }

    public final e2.b l() {
        return this.f15816d;
    }

    public final void n() {
        this.f15821i = true;
    }

    public String toString() {
        return "Node(pointerInputFilter=" + this.f15815c + ", children=" + g() + ", pointerIds=" + this.f15816d + ')';
    }
}
