package N1;

import a.AbstractC0386a;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import h3.AbstractC1031a;
import java.lang.reflect.Field;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.PriorityQueue;
import n.C1228p;
import x0.AbstractC1709a;
import x3.C1713a;

/* JADX INFO: renamed from: N1.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0198b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f4504a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object f4505b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f4506c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f4507d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f4508e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f4509f;

    public C0198b(View view) {
        C1228p c1228p;
        this.f4504a = -1;
        this.f4505b = view;
        PorterDuff.Mode mode = C1228p.f14915b;
        synchronized (C1228p.class) {
            try {
                if (C1228p.f14916c == null) {
                    C1228p.c();
                }
                c1228p = C1228p.f14916c;
            } catch (Throwable th) {
                throw th;
            }
        }
        this.f4506c = c1228p;
    }

    public static C0198b f(Context context, int i) {
        AbstractC0386a.f("Cannot create a CalendarItemStyle with a styleResId of 0", i != 0);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(i, AbstractC1031a.f13408o);
        Rect rect = new Rect(typedArrayObtainStyledAttributes.getDimensionPixelOffset(0, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(2, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(1, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(3, 0));
        ColorStateList colorStateListQ = s7.d.q(context, typedArrayObtainStyledAttributes, 4);
        ColorStateList colorStateListQ2 = s7.d.q(context, typedArrayObtainStyledAttributes, 9);
        ColorStateList colorStateListQ3 = s7.d.q(context, typedArrayObtainStyledAttributes, 7);
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(8, 0);
        x3.k kVarA = x3.k.a(context, typedArrayObtainStyledAttributes.getResourceId(5, 0), typedArrayObtainStyledAttributes.getResourceId(6, 0), new C1713a(0)).a();
        typedArrayObtainStyledAttributes.recycle();
        return new C0198b(colorStateListQ, colorStateListQ2, colorStateListQ3, dimensionPixelSize, kVarA, rect);
    }

    /* JADX WARN: Code restructure failed: missing block: B:9:0x001f, code lost:
    
        if (r8 < r0.f18877r) goto L32;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void a(long j8, x0.o oVar) {
        int i = this.f4504a;
        if (i != 0) {
            PriorityQueue priorityQueue = (PriorityQueue) this.f4508e;
            if (i != -1 && priorityQueue.size() >= this.f4504a) {
                y0.r rVar = (y0.r) priorityQueue.peek();
                int i5 = x0.v.f18553a;
            }
            ArrayDeque arrayDeque = (ArrayDeque) this.f4506c;
            x0.o oVar2 = arrayDeque.isEmpty() ? new x0.o() : (x0.o) arrayDeque.pop();
            oVar2.C(oVar.a());
            System.arraycopy(oVar.f18539a, oVar.f18540b, oVar2.f18539a, 0, oVar2.a());
            y0.r rVar2 = (y0.r) this.f4509f;
            if (rVar2 != null && j8 == rVar2.f18877r) {
                rVar2.f18876q.add(oVar2);
                return;
            }
            ArrayDeque arrayDeque2 = (ArrayDeque) this.f4507d;
            y0.r rVar3 = arrayDeque2.isEmpty() ? new y0.r() : (y0.r) arrayDeque2.pop();
            rVar3.getClass();
            AbstractC1709a.d(j8 != -9223372036854775807L);
            ArrayList arrayList = rVar3.f18876q;
            AbstractC1709a.j(arrayList.isEmpty());
            rVar3.f18877r = j8;
            arrayList.add(oVar2);
            priorityQueue.add(rVar3);
            this.f4509f = rVar3;
            int i8 = this.f4504a;
            if (i8 != -1) {
                j(i8);
                return;
            }
            return;
        }
        ((y0.s) this.f4505b).f(j8, oVar);
    }

    public void b() {
        View view = (View) this.f4505b;
        Drawable background = view.getBackground();
        if (background != null) {
            if (((k7.i) this.f4507d) != null) {
                if (((k7.i) this.f4509f) == null) {
                    this.f4509f = new k7.i();
                }
                k7.i iVar = (k7.i) this.f4509f;
                iVar.f14082c = null;
                iVar.f14081b = false;
                iVar.f14083d = null;
                iVar.f14080a = false;
                Field field = M.J.f4065a;
                ColorStateList colorStateListC = M.B.c(view);
                if (colorStateListC != null) {
                    iVar.f14081b = true;
                    iVar.f14082c = colorStateListC;
                }
                PorterDuff.Mode modeD = M.B.d(view);
                if (modeD != null) {
                    iVar.f14080a = true;
                    iVar.f14083d = modeD;
                }
                if (iVar.f14081b || iVar.f14080a) {
                    C1228p.d(background, iVar, view.getDrawableState());
                    return;
                }
            }
            k7.i iVar2 = (k7.i) this.f4508e;
            if (iVar2 != null) {
                C1228p.d(background, iVar2, view.getDrawableState());
                return;
            }
            k7.i iVar3 = (k7.i) this.f4507d;
            if (iVar3 != null) {
                C1228p.d(background, iVar3, view.getDrawableState());
            }
        }
    }

    public boolean c(int i) {
        ArrayList arrayList = (ArrayList) this.f4507d;
        int size = arrayList.size();
        for (int i5 = 0; i5 < size; i5++) {
            C0196a c0196a = (C0196a) arrayList.get(i5);
            int i8 = c0196a.f4500a;
            if (i8 != 8) {
                if (i8 == 1) {
                    int i9 = c0196a.f4501b;
                    int i10 = c0196a.f4503d + i9;
                    while (i9 < i10) {
                        if (i(i9, i5 + 1) == i) {
                            return true;
                        }
                        i9++;
                    }
                } else {
                    continue;
                }
            } else {
                if (i(c0196a.f4503d, i5 + 1) == i) {
                    return true;
                }
            }
        }
        return false;
    }

    public void d() {
        ArrayList arrayList = (ArrayList) this.f4507d;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            ((S) this.f4508e).b((C0196a) arrayList.get(i));
        }
        t(arrayList);
        this.f4504a = 0;
    }

    public void e() {
        d();
        ArrayList arrayList = (ArrayList) this.f4506c;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            C0196a c0196a = (C0196a) arrayList.get(i);
            int i5 = c0196a.f4500a;
            S s8 = (S) this.f4508e;
            if (i5 == 1) {
                s8.b(c0196a);
                s8.e(c0196a.f4501b, c0196a.f4503d);
            } else if (i5 == 2) {
                s8.b(c0196a);
                int i8 = c0196a.f4501b;
                int i9 = c0196a.f4503d;
                RecyclerView recyclerView = s8.f4489q;
                recyclerView.U(i8, i9, true);
                recyclerView.f9018B0 = true;
                recyclerView.f9087y0.f4616c += i9;
            } else if (i5 == 4) {
                s8.b(c0196a);
                s8.d(c0196a.f4501b, c0196a.f4503d, c0196a.f4502c);
            } else if (i5 == 8) {
                s8.b(c0196a);
                s8.f(c0196a.f4501b, c0196a.f4503d);
            }
        }
        t(arrayList);
        this.f4504a = 0;
    }

    public void g(C0196a c0196a) {
        int i;
        L.b bVar;
        int i5 = c0196a.f4500a;
        if (i5 == 1 || i5 == 8) {
            throw new IllegalArgumentException("should not dispatch add or move for pre layout");
        }
        int iX = x(c0196a.f4501b, i5);
        int i8 = c0196a.f4501b;
        int i9 = c0196a.f4500a;
        if (i9 == 2) {
            i = 0;
        } else {
            if (i9 != 4) {
                throw new IllegalArgumentException("op should be remove or update." + c0196a);
            }
            i = 1;
        }
        int i10 = 1;
        int i11 = 1;
        while (true) {
            int i12 = c0196a.f4503d;
            bVar = (L.b) this.f4505b;
            if (i10 >= i12) {
                break;
            }
            int iX2 = x((i * i10) + c0196a.f4501b, c0196a.f4500a);
            int i13 = c0196a.f4500a;
            if (i13 == 2 ? iX2 != iX : !(i13 == 4 && iX2 == iX + 1)) {
                C0196a c0196aO = o(c0196a.f4502c, i13, iX, i11);
                h(c0196aO, i8);
                c0196aO.f4502c = null;
                bVar.c(c0196aO);
                if (c0196a.f4500a == 4) {
                    i8 += i11;
                }
                i11 = 1;
                iX = iX2;
            } else {
                i11++;
            }
            i10++;
        }
        Object obj = c0196a.f4502c;
        c0196a.f4502c = null;
        bVar.c(c0196a);
        if (i11 > 0) {
            C0196a c0196aO2 = o(obj, c0196a.f4500a, iX, i11);
            h(c0196aO2, i8);
            c0196aO2.f4502c = null;
            bVar.c(c0196aO2);
        }
    }

    public void h(C0196a c0196a, int i) {
        S s8 = (S) this.f4508e;
        s8.b(c0196a);
        int i5 = c0196a.f4500a;
        if (i5 != 2) {
            if (i5 != 4) {
                throw new IllegalArgumentException("only remove and update ops can be dispatched in first pass");
            }
            s8.d(i, c0196a.f4503d, c0196a.f4502c);
        } else {
            int i8 = c0196a.f4503d;
            RecyclerView recyclerView = s8.f4489q;
            recyclerView.U(i, i8, true);
            recyclerView.f9018B0 = true;
            recyclerView.f9087y0.f4616c += i8;
        }
    }

    public int i(int i, int i5) {
        ArrayList arrayList = (ArrayList) this.f4507d;
        int size = arrayList.size();
        while (i5 < size) {
            C0196a c0196a = (C0196a) arrayList.get(i5);
            int i8 = c0196a.f4500a;
            if (i8 == 8) {
                int i9 = c0196a.f4501b;
                if (i9 == i) {
                    i = c0196a.f4503d;
                } else {
                    if (i9 < i) {
                        i--;
                    }
                    if (c0196a.f4503d <= i) {
                        i++;
                    }
                }
            } else {
                int i10 = c0196a.f4501b;
                if (i10 > i) {
                    continue;
                } else if (i8 == 2) {
                    int i11 = c0196a.f4503d;
                    if (i < i10 + i11) {
                        return -1;
                    }
                    i -= i11;
                } else if (i8 == 1) {
                    i += c0196a.f4503d;
                }
            }
            i5++;
        }
        return i;
    }

    public void j(int i) {
        ArrayList arrayList;
        while (true) {
            PriorityQueue priorityQueue = (PriorityQueue) this.f4508e;
            if (priorityQueue.size() <= i) {
                return;
            }
            y0.r rVar = (y0.r) priorityQueue.poll();
            int i5 = x0.v.f18553a;
            int i8 = 0;
            while (true) {
                int size = rVar.f18876q.size();
                arrayList = rVar.f18876q;
                if (i8 >= size) {
                    break;
                }
                ((y0.s) this.f4505b).f(rVar.f18877r, (x0.o) arrayList.get(i8));
                ((ArrayDeque) this.f4506c).push((x0.o) arrayList.get(i8));
                i8++;
            }
            arrayList.clear();
            y0.r rVar2 = (y0.r) this.f4509f;
            if (rVar2 != null && rVar2.f18877r == rVar.f18877r) {
                this.f4509f = null;
            }
            ((ArrayDeque) this.f4507d).push(rVar);
        }
    }

    public ColorStateList k() {
        k7.i iVar = (k7.i) this.f4508e;
        if (iVar != null) {
            return (ColorStateList) iVar.f14082c;
        }
        return null;
    }

    public PorterDuff.Mode l() {
        k7.i iVar = (k7.i) this.f4508e;
        if (iVar != null) {
            return (PorterDuff.Mode) iVar.f14083d;
        }
        return null;
    }

    public boolean m() {
        return ((ArrayList) this.f4506c).size() > 0;
    }

    public void n(AttributeSet attributeSet, int i) {
        ColorStateList colorStateListI;
        View view = (View) this.f4505b;
        Context context = view.getContext();
        int[] iArr = h.a.f13024u;
        com.google.android.material.datepicker.c cVarZ = com.google.android.material.datepicker.c.z(context, attributeSet, iArr, i);
        TypedArray typedArray = (TypedArray) cVarZ.f10220s;
        View view2 = (View) this.f4505b;
        M.J.i(view2, view2.getContext(), iArr, attributeSet, (TypedArray) cVarZ.f10220s, i);
        try {
            if (typedArray.hasValue(0)) {
                this.f4504a = typedArray.getResourceId(0, -1);
                C1228p c1228p = (C1228p) this.f4506c;
                Context context2 = view.getContext();
                int i5 = this.f4504a;
                synchronized (c1228p) {
                    colorStateListI = c1228p.f14917a.i(context2, i5);
                }
                if (colorStateListI != null) {
                    u(colorStateListI);
                }
            }
            if (typedArray.hasValue(1)) {
                M.B.h(view, cVarZ.t(1));
            }
            if (typedArray.hasValue(2)) {
                M.B.i(view, n.S.b(typedArray.getInt(2, -1), null));
            }
            cVarZ.B();
        } catch (Throwable th) {
            cVarZ.B();
            throw th;
        }
    }

    public C0196a o(Object obj, int i, int i5, int i8) {
        C0196a c0196a = (C0196a) ((L.b) this.f4505b).a();
        if (c0196a != null) {
            c0196a.f4500a = i;
            c0196a.f4501b = i5;
            c0196a.f4503d = i8;
            c0196a.f4502c = obj;
            return c0196a;
        }
        C0196a c0196a2 = new C0196a();
        c0196a2.f4500a = i;
        c0196a2.f4501b = i5;
        c0196a2.f4503d = i8;
        c0196a2.f4502c = obj;
        return c0196a2;
    }

    public void p() {
        this.f4504a = -1;
        u(null);
        b();
    }

    public void q(int i) {
        ColorStateList colorStateListI;
        this.f4504a = i;
        C1228p c1228p = (C1228p) this.f4506c;
        if (c1228p != null) {
            Context context = ((View) this.f4505b).getContext();
            synchronized (c1228p) {
                colorStateListI = c1228p.f14917a.i(context, i);
            }
        } else {
            colorStateListI = null;
        }
        u(colorStateListI);
        b();
    }

    public void r(C0196a c0196a) {
        ((ArrayList) this.f4507d).add(c0196a);
        int i = c0196a.f4500a;
        S s8 = (S) this.f4508e;
        if (i == 1) {
            s8.e(c0196a.f4501b, c0196a.f4503d);
            return;
        }
        if (i == 2) {
            int i5 = c0196a.f4501b;
            int i8 = c0196a.f4503d;
            RecyclerView recyclerView = s8.f4489q;
            recyclerView.U(i5, i8, false);
            recyclerView.f9018B0 = true;
            return;
        }
        if (i == 4) {
            s8.d(c0196a.f4501b, c0196a.f4503d, c0196a.f4502c);
        } else if (i == 8) {
            s8.f(c0196a.f4501b, c0196a.f4503d);
        } else {
            throw new IllegalArgumentException("Unknown update op type for " + c0196a);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:184:0x00aa A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:185:0x0135 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:188:0x0121 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:202:0x000d A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:30:0x006f  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0074  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0090  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0094  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00a5  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void s() {
        byte b8;
        int i;
        boolean z8;
        byte b9;
        C0196a c0196aO;
        int i5;
        int i8;
        C0196a c0196aO2;
        boolean z9;
        boolean z10;
        C0196a c0196aO3;
        ArrayList arrayList = (ArrayList) this.f4506c;
        K4.c cVar = (K4.c) this.f4509f;
        cVar.getClass();
        while (true) {
            int size = arrayList.size() - 1;
            boolean z11 = false;
            while (true) {
                b8 = -1;
                i = 8;
                if (size < 0) {
                    size = -1;
                    break;
                }
                if (((C0196a) arrayList.get(size)).f4500a != 8) {
                    z11 = true;
                } else if (z11) {
                    break;
                }
                size--;
            }
            if (size == -1) {
                break;
            }
            int i9 = size + 1;
            C0196a c0196a = (C0196a) arrayList.get(size);
            C0196a c0196a2 = (C0196a) arrayList.get(i9);
            int i10 = c0196a2.f4500a;
            if (i10 != 1) {
                C0198b c0198b = (C0198b) cVar.f3604r;
                if (i10 == 2) {
                    int i11 = c0196a.f4501b;
                    int i12 = c0196a.f4503d;
                    if (i11 < i12) {
                        z10 = c0196a2.f4501b == i11 && c0196a2.f4503d == i12 - i11;
                        z9 = false;
                    } else if (c0196a2.f4501b == i12 + 1 && c0196a2.f4503d == i11 - i12) {
                        z10 = true;
                        z9 = true;
                    } else {
                        z9 = true;
                        z10 = false;
                    }
                    int i13 = c0196a2.f4501b;
                    if (i12 < i13) {
                        c0196a2.f4501b = i13 - 1;
                    } else {
                        int i14 = c0196a2.f4503d;
                        if (i12 < i13 + i14) {
                            c0196a2.f4503d = i14 - 1;
                            c0196a.f4500a = 2;
                            c0196a.f4503d = 1;
                            if (c0196a2.f4503d == 0) {
                                arrayList.remove(i9);
                                c0198b.getClass();
                                c0196a2.f4502c = null;
                                ((L.b) c0198b.f4505b).c(c0196a2);
                            }
                        }
                    }
                    int i15 = c0196a.f4501b;
                    int i16 = c0196a2.f4501b;
                    if (i15 <= i16) {
                        c0196a2.f4501b = i16 + 1;
                    } else {
                        int i17 = i16 + c0196a2.f4503d;
                        if (i15 < i17) {
                            c0196aO3 = c0198b.o(null, 2, i15 + 1, i17 - i15);
                            c0196a2.f4503d = c0196a.f4501b - c0196a2.f4501b;
                        }
                        if (z10) {
                            if (z9) {
                                if (c0196aO3 != null) {
                                    int i18 = c0196a.f4501b;
                                    if (i18 > c0196aO3.f4501b) {
                                        c0196a.f4501b = i18 - c0196aO3.f4503d;
                                    }
                                    int i19 = c0196a.f4503d;
                                    if (i19 > c0196aO3.f4501b) {
                                        c0196a.f4503d = i19 - c0196aO3.f4503d;
                                    }
                                }
                                int i20 = c0196a.f4501b;
                                if (i20 > c0196a2.f4501b) {
                                    c0196a.f4501b = i20 - c0196a2.f4503d;
                                }
                                int i21 = c0196a.f4503d;
                                if (i21 > c0196a2.f4501b) {
                                    c0196a.f4503d = i21 - c0196a2.f4503d;
                                }
                            } else {
                                if (c0196aO3 != null) {
                                    int i22 = c0196a.f4501b;
                                    if (i22 >= c0196aO3.f4501b) {
                                        c0196a.f4501b = i22 - c0196aO3.f4503d;
                                    }
                                    int i23 = c0196a.f4503d;
                                    if (i23 >= c0196aO3.f4501b) {
                                        c0196a.f4503d = i23 - c0196aO3.f4503d;
                                    }
                                }
                                int i24 = c0196a.f4501b;
                                if (i24 >= c0196a2.f4501b) {
                                    c0196a.f4501b = i24 - c0196a2.f4503d;
                                }
                                int i25 = c0196a.f4503d;
                                if (i25 >= c0196a2.f4501b) {
                                    c0196a.f4503d = i25 - c0196a2.f4503d;
                                }
                            }
                            arrayList.set(size, c0196a2);
                            if (c0196a.f4501b != c0196a.f4503d) {
                                arrayList.set(i9, c0196a);
                            } else {
                                arrayList.remove(i9);
                            }
                            if (c0196aO3 != null) {
                                arrayList.add(size, c0196aO3);
                            }
                        } else {
                            arrayList.set(size, c0196a2);
                            arrayList.remove(i9);
                            c0198b.getClass();
                            c0196a.f4502c = null;
                            ((L.b) c0198b.f4505b).c(c0196a);
                        }
                    }
                    c0196aO3 = null;
                    if (z10) {
                    }
                } else if (i10 == 4) {
                    int i26 = c0196a.f4503d;
                    int i27 = c0196a2.f4501b;
                    if (i26 < i27) {
                        c0196a2.f4501b = i27 - 1;
                    } else {
                        int i28 = c0196a2.f4503d;
                        if (i26 < i27 + i28) {
                            c0196a2.f4503d = i28 - 1;
                            c0196aO = c0198b.o(c0196a2.f4502c, 4, c0196a.f4501b, 1);
                        }
                        i5 = c0196a.f4501b;
                        i8 = c0196a2.f4501b;
                        if (i5 > i8) {
                            c0196a2.f4501b = i8 + 1;
                        } else {
                            int i29 = i8 + c0196a2.f4503d;
                            if (i5 < i29) {
                                int i30 = i29 - i5;
                                c0196aO2 = c0198b.o(c0196a2.f4502c, 4, i5 + 1, i30);
                                c0196a2.f4503d -= i30;
                            }
                            arrayList.set(i9, c0196a);
                            if (c0196a2.f4503d > 0) {
                                arrayList.set(size, c0196a2);
                            } else {
                                arrayList.remove(size);
                                c0198b.getClass();
                                c0196a2.f4502c = null;
                                ((L.b) c0198b.f4505b).c(c0196a2);
                            }
                            if (c0196aO != null) {
                                arrayList.add(size, c0196aO);
                            }
                            if (c0196aO2 != null) {
                                arrayList.add(size, c0196aO2);
                            }
                        }
                        c0196aO2 = null;
                        arrayList.set(i9, c0196a);
                        if (c0196a2.f4503d > 0) {
                        }
                        if (c0196aO != null) {
                        }
                        if (c0196aO2 != null) {
                        }
                    }
                    c0196aO = null;
                    i5 = c0196a.f4501b;
                    i8 = c0196a2.f4501b;
                    if (i5 > i8) {
                    }
                    c0196aO2 = null;
                    arrayList.set(i9, c0196a);
                    if (c0196a2.f4503d > 0) {
                    }
                    if (c0196aO != null) {
                    }
                    if (c0196aO2 != null) {
                    }
                }
            } else {
                int i31 = c0196a.f4503d;
                int i32 = c0196a2.f4501b;
                int i33 = i31 < i32 ? -1 : 0;
                int i34 = c0196a.f4501b;
                if (i34 < i32) {
                    i33++;
                }
                if (i32 <= i34) {
                    c0196a.f4501b = i34 + c0196a2.f4503d;
                }
                int i35 = c0196a2.f4501b;
                if (i35 <= i31) {
                    c0196a.f4503d = i31 + c0196a2.f4503d;
                }
                c0196a2.f4501b = i35 + i33;
                arrayList.set(size, c0196a2);
                arrayList.set(i9, c0196a);
            }
        }
        int size2 = arrayList.size();
        int i36 = 0;
        while (i36 < size2) {
            C0196a c0196aO4 = (C0196a) arrayList.get(i36);
            int i37 = c0196aO4.f4500a;
            if (i37 != 1) {
                L.b bVar = (L.b) this.f4505b;
                S s8 = (S) this.f4508e;
                if (i37 == 2) {
                    int i38 = c0196aO4.f4501b;
                    int i39 = c0196aO4.f4503d + i38;
                    int i40 = i38;
                    int i41 = 0;
                    byte b10 = -1;
                    while (i40 < i39) {
                        if (s8.c(i40) != null || c(i40)) {
                            if (b10 == 0) {
                                g(o(null, 2, i38, i41));
                                z8 = true;
                            } else {
                                z8 = false;
                            }
                            b9 = 1;
                        } else {
                            if (b10 == 1) {
                                r(o(null, 2, i38, i41));
                                z8 = true;
                            } else {
                                z8 = false;
                            }
                            b9 = 0;
                        }
                        if (z8) {
                            i40 -= i41;
                            i39 -= i41;
                            i41 = 1;
                        } else {
                            i41++;
                        }
                        i40++;
                        b10 = b9;
                    }
                    if (i41 != c0196aO4.f4503d) {
                        c0196aO4.f4502c = null;
                        bVar.c(c0196aO4);
                        c0196aO4 = o(null, 2, i38, i41);
                    }
                    if (b10 == 0) {
                        g(c0196aO4);
                    } else {
                        r(c0196aO4);
                    }
                } else if (i37 == 4) {
                    int i42 = c0196aO4.f4501b;
                    int i43 = c0196aO4.f4503d + i42;
                    byte b11 = b8;
                    int i44 = i42;
                    int i45 = 0;
                    while (i42 < i43) {
                        if (s8.c(i42) != null || c(i42)) {
                            if (b11 == 0) {
                                g(o(c0196aO4.f4502c, 4, i44, i45));
                                i44 = i42;
                                i45 = 0;
                            }
                            b11 = 1;
                        } else {
                            if (b11 == 1) {
                                r(o(c0196aO4.f4502c, 4, i44, i45));
                                i44 = i42;
                                i45 = 0;
                            }
                            b11 = 0;
                        }
                        i45++;
                        i42++;
                    }
                    if (i45 != c0196aO4.f4503d) {
                        Object obj = c0196aO4.f4502c;
                        c0196aO4.f4502c = null;
                        bVar.c(c0196aO4);
                        c0196aO4 = o(obj, 4, i44, i45);
                    }
                    if (b11 == 0) {
                        g(c0196aO4);
                    } else {
                        r(c0196aO4);
                    }
                } else if (i37 == i) {
                    r(c0196aO4);
                }
            } else {
                r(c0196aO4);
            }
            i36++;
            b8 = -1;
            i = 8;
        }
        arrayList.clear();
    }

    public void t(ArrayList arrayList) {
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            C0196a c0196a = (C0196a) arrayList.get(i);
            c0196a.f4502c = null;
            ((L.b) this.f4505b).c(c0196a);
        }
        arrayList.clear();
    }

    public void u(ColorStateList colorStateList) {
        if (colorStateList != null) {
            if (((k7.i) this.f4507d) == null) {
                this.f4507d = new k7.i();
            }
            k7.i iVar = (k7.i) this.f4507d;
            iVar.f14082c = colorStateList;
            iVar.f14081b = true;
        } else {
            this.f4507d = null;
        }
        b();
    }

    public void v(ColorStateList colorStateList) {
        if (((k7.i) this.f4508e) == null) {
            this.f4508e = new k7.i();
        }
        k7.i iVar = (k7.i) this.f4508e;
        iVar.f14082c = colorStateList;
        iVar.f14081b = true;
        b();
    }

    public void w(PorterDuff.Mode mode) {
        if (((k7.i) this.f4508e) == null) {
            this.f4508e = new k7.i();
        }
        k7.i iVar = (k7.i) this.f4508e;
        iVar.f14083d = mode;
        iVar.f14080a = true;
        b();
    }

    public int x(int i, int i5) {
        int i8;
        int i9;
        ArrayList arrayList = (ArrayList) this.f4507d;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            C0196a c0196a = (C0196a) arrayList.get(size);
            int i10 = c0196a.f4500a;
            if (i10 == 8) {
                int i11 = c0196a.f4501b;
                int i12 = c0196a.f4503d;
                if (i11 < i12) {
                    i9 = i11;
                    i8 = i12;
                } else {
                    i8 = i11;
                    i9 = i12;
                }
                if (i < i9 || i > i8) {
                    if (i < i11) {
                        if (i5 == 1) {
                            c0196a.f4501b = i11 + 1;
                            c0196a.f4503d = i12 + 1;
                        } else if (i5 == 2) {
                            c0196a.f4501b = i11 - 1;
                            c0196a.f4503d = i12 - 1;
                        }
                    }
                } else if (i9 == i11) {
                    if (i5 == 1) {
                        c0196a.f4503d = i12 + 1;
                    } else if (i5 == 2) {
                        c0196a.f4503d = i12 - 1;
                    }
                    i++;
                } else {
                    if (i5 == 1) {
                        c0196a.f4501b = i11 + 1;
                    } else if (i5 == 2) {
                        c0196a.f4501b = i11 - 1;
                    }
                    i--;
                }
            } else {
                int i13 = c0196a.f4501b;
                if (i13 <= i) {
                    if (i10 == 1) {
                        i -= c0196a.f4503d;
                    } else if (i10 == 2) {
                        i += c0196a.f4503d;
                    }
                } else if (i5 == 1) {
                    c0196a.f4501b = i13 + 1;
                } else if (i5 == 2) {
                    c0196a.f4501b = i13 - 1;
                }
            }
        }
        for (int size2 = arrayList.size() - 1; size2 >= 0; size2--) {
            C0196a c0196a2 = (C0196a) arrayList.get(size2);
            int i14 = c0196a2.f4500a;
            L.b bVar = (L.b) this.f4505b;
            if (i14 == 8) {
                int i15 = c0196a2.f4503d;
                if (i15 == c0196a2.f4501b || i15 < 0) {
                    arrayList.remove(size2);
                    c0196a2.f4502c = null;
                    bVar.c(c0196a2);
                }
            } else if (c0196a2.f4503d <= 0) {
                arrayList.remove(size2);
                c0196a2.f4502c = null;
                bVar.c(c0196a2);
            }
        }
        return i;
    }

    public C0198b(y0.s sVar) {
        this.f4505b = sVar;
        this.f4506c = new ArrayDeque();
        this.f4507d = new ArrayDeque();
        this.f4508e = new PriorityQueue();
        this.f4504a = -1;
    }

    public C0198b(ColorStateList colorStateList, ColorStateList colorStateList2, ColorStateList colorStateList3, int i, x3.k kVar, Rect rect) {
        AbstractC0386a.i(rect.left);
        AbstractC0386a.i(rect.top);
        AbstractC0386a.i(rect.right);
        AbstractC0386a.i(rect.bottom);
        this.f4505b = rect;
        this.f4506c = colorStateList2;
        this.f4507d = colorStateList;
        this.f4508e = colorStateList3;
        this.f4504a = i;
        this.f4509f = kVar;
    }

    public C0198b(S s8) {
        this.f4505b = new L.b(30);
        this.f4506c = new ArrayList();
        this.f4507d = new ArrayList();
        this.f4504a = 0;
        this.f4508e = s8;
        this.f4509f = new K4.c(26, this);
    }

    public C0198b(int[] iArr, L0.n0[] n0VarArr, int[] iArr2, int[][][] iArr3, L0.n0 n0Var) {
        this.f4505b = iArr;
        this.f4506c = n0VarArr;
        this.f4508e = iArr3;
        this.f4507d = iArr2;
        this.f4509f = n0Var;
        this.f4504a = iArr.length;
    }
}
