package v2;

import C0.J;
import F1.AbstractC0195y;
import F1.F;
import F1.N;
import android.animation.Animator;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowId;
import android.widget.ListView;
import androidx.navigation.C1134i;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import n.C2578e;
import n.C2592t;
import n2.AbstractC2613d;

/* JADX INFO: renamed from: v2.q, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC3118q implements Cloneable {
    public ArrayList l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public ArrayList f25364m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public InterfaceC3116o[] f25365n;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public AbstractC2613d f25374w;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final Animator[] f25354y = new Animator[0];

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final int[] f25355z = {2, 1, 3, 4};

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final C1134i f25352A = new C1134i(22);

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public static final ThreadLocal f25353B = new ThreadLocal();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f25356a = getClass().getName();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f25357b = -1;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList f25358c = new ArrayList();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final ArrayList f25359d = new ArrayList();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public J f25360e = new J(17);

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public J f25361f = new J(17);

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public C3124w f25362j = null;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final int[] f25363k = f25355z;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final ArrayList f25366o = new ArrayList();

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public Animator[] f25367p = f25354y;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f25368q = 0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f25369r = false;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f25370s = false;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public AbstractC3118q f25371t = null;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public ArrayList f25372u = null;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public ArrayList f25373v = new ArrayList();

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public C1134i f25375x = f25352A;

    public static void c(J j4, View view, C3126y c3126y) {
        ((C2578e) j4.f533b).put(view, c3126y);
        int id = view.getId();
        if (id >= 0) {
            SparseArray sparseArray = (SparseArray) j4.f534c;
            if (sparseArray.indexOfKey(id) >= 0) {
                sparseArray.put(id, null);
            } else {
                sparseArray.put(id, view);
            }
        }
        Field field = F.f1367a;
        String strB = AbstractC0195y.b(view);
        if (strB != null) {
            C2578e c2578e = (C2578e) j4.f536e;
            if (c2578e.containsKey(strB)) {
                c2578e.put(strB, null);
            } else {
                c2578e.put(strB, view);
            }
        }
        if (view.getParent() instanceof ListView) {
            ListView listView = (ListView) view.getParent();
            if (listView.getAdapter().hasStableIds()) {
                long itemIdAtPosition = listView.getItemIdAtPosition(listView.getPositionForView(view));
                C2592t c2592t = (C2592t) j4.f535d;
                if (c2592t.c(itemIdAtPosition) < 0) {
                    view.setHasTransientState(true);
                    c2592t.e(itemIdAtPosition, view);
                    return;
                }
                View view2 = (View) c2592t.b(itemIdAtPosition);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                    c2592t.e(itemIdAtPosition, null);
                }
            }
        }
    }

    public static C2578e q() {
        ThreadLocal threadLocal = f25353B;
        C2578e c2578e = (C2578e) threadLocal.get();
        if (c2578e != null) {
            return c2578e;
        }
        C2578e c2578e2 = new C2578e(0);
        threadLocal.set(c2578e2);
        return c2578e2;
    }

    public static boolean v(C3126y c3126y, C3126y c3126y2, String str) {
        Object obj = c3126y.f25391a.get(str);
        Object obj2 = c3126y2.f25391a.get(str);
        if (obj == null && obj2 == null) {
            return false;
        }
        if (obj == null || obj2 == null) {
            return true;
        }
        return !obj.equals(obj2);
    }

    public void A(View view) {
        if (this.f25369r) {
            if (!this.f25370s) {
                ArrayList arrayList = this.f25366o;
                int size = arrayList.size();
                Animator[] animatorArr = (Animator[]) arrayList.toArray(this.f25367p);
                this.f25367p = f25354y;
                for (int i6 = size - 1; i6 >= 0; i6--) {
                    Animator animator = animatorArr[i6];
                    animatorArr[i6] = null;
                    animator.resume();
                }
                this.f25367p = animatorArr;
                w(this, InterfaceC3117p.f25351e);
            }
            this.f25369r = false;
        }
    }

    public void B() {
        H();
        C2578e c2578eQ = q();
        for (Animator animator : this.f25373v) {
            if (c2578eQ.containsKey(animator)) {
                H();
                if (animator != null) {
                    animator.addListener(new N(this, c2578eQ));
                    long j4 = this.f25357b;
                    if (j4 >= 0) {
                        animator.setStartDelay(animator.getStartDelay() + j4);
                    }
                    animator.addListener(new C3114m(this));
                    animator.start();
                }
            }
        }
        this.f25373v.clear();
        n();
    }

    public void C(AbstractC2613d abstractC2613d) {
        this.f25374w = abstractC2613d;
    }

    public void E(C1134i c1134i) {
        if (c1134i == null) {
            this.f25375x = f25352A;
        } else {
            this.f25375x = c1134i;
        }
    }

    public void G(long j4) {
        this.f25357b = j4;
    }

    public final void H() {
        if (this.f25368q == 0) {
            w(this, InterfaceC3117p.f25347a);
            this.f25370s = false;
        }
        this.f25368q++;
    }

    public String I(String str) {
        StringBuilder sb = new StringBuilder(str);
        sb.append(getClass().getSimpleName());
        sb.append("@");
        sb.append(Integer.toHexString(hashCode()));
        sb.append(": ");
        if (this.f25357b != -1) {
            sb.append("dly(");
            sb.append(this.f25357b);
            sb.append(") ");
        }
        ArrayList arrayList = this.f25358c;
        int size = arrayList.size();
        ArrayList arrayList2 = this.f25359d;
        if (size > 0 || arrayList2.size() > 0) {
            sb.append("tgts(");
            if (arrayList.size() > 0) {
                for (int i6 = 0; i6 < arrayList.size(); i6++) {
                    if (i6 > 0) {
                        sb.append(", ");
                    }
                    sb.append(arrayList.get(i6));
                }
            }
            if (arrayList2.size() > 0) {
                for (int i7 = 0; i7 < arrayList2.size(); i7++) {
                    if (i7 > 0) {
                        sb.append(", ");
                    }
                    sb.append(arrayList2.get(i7));
                }
            }
            sb.append(")");
        }
        return sb.toString();
    }

    public void a(InterfaceC3116o interfaceC3116o) {
        if (this.f25372u == null) {
            this.f25372u = new ArrayList();
        }
        this.f25372u.add(interfaceC3116o);
    }

    public void b(View view) {
        this.f25359d.add(view);
    }

    public void cancel() {
        ArrayList arrayList = this.f25366o;
        int size = arrayList.size();
        Animator[] animatorArr = (Animator[]) arrayList.toArray(this.f25367p);
        this.f25367p = f25354y;
        for (int i6 = size - 1; i6 >= 0; i6--) {
            Animator animator = animatorArr[i6];
            animatorArr[i6] = null;
            animator.cancel();
        }
        this.f25367p = animatorArr;
        w(this, InterfaceC3117p.f25349c);
    }

    public abstract void d(C3126y c3126y);

    public final void e(View view, boolean z6) {
        if (view == null) {
            return;
        }
        view.getId();
        if (view.getParent() instanceof ViewGroup) {
            C3126y c3126y = new C3126y(view);
            if (z6) {
                h(c3126y);
            } else {
                d(c3126y);
            }
            c3126y.f25393c.add(this);
            f(c3126y);
            if (z6) {
                c(this.f25360e, view, c3126y);
            } else {
                c(this.f25361f, view, c3126y);
            }
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i6 = 0; i6 < viewGroup.getChildCount(); i6++) {
                e(viewGroup.getChildAt(i6), z6);
            }
        }
    }

    public abstract void h(C3126y c3126y);

    public final void i(ViewGroup viewGroup, boolean z6) {
        j(z6);
        ArrayList arrayList = this.f25358c;
        int size = arrayList.size();
        ArrayList arrayList2 = this.f25359d;
        if (size <= 0 && arrayList2.size() <= 0) {
            e(viewGroup, z6);
            return;
        }
        for (int i6 = 0; i6 < arrayList.size(); i6++) {
            View viewFindViewById = viewGroup.findViewById(((Integer) arrayList.get(i6)).intValue());
            if (viewFindViewById != null) {
                C3126y c3126y = new C3126y(viewFindViewById);
                if (z6) {
                    h(c3126y);
                } else {
                    d(c3126y);
                }
                c3126y.f25393c.add(this);
                f(c3126y);
                if (z6) {
                    c(this.f25360e, viewFindViewById, c3126y);
                } else {
                    c(this.f25361f, viewFindViewById, c3126y);
                }
            }
        }
        for (int i7 = 0; i7 < arrayList2.size(); i7++) {
            View view = (View) arrayList2.get(i7);
            C3126y c3126y2 = new C3126y(view);
            if (z6) {
                h(c3126y2);
            } else {
                d(c3126y2);
            }
            c3126y2.f25393c.add(this);
            f(c3126y2);
            if (z6) {
                c(this.f25360e, view, c3126y2);
            } else {
                c(this.f25361f, view, c3126y2);
            }
        }
    }

    public final void j(boolean z6) {
        if (z6) {
            ((C2578e) this.f25360e.f533b).clear();
            ((SparseArray) this.f25360e.f534c).clear();
            ((C2592t) this.f25360e.f535d).a();
        } else {
            ((C2578e) this.f25361f.f533b).clear();
            ((SparseArray) this.f25361f.f534c).clear();
            ((C2592t) this.f25361f.f535d).a();
        }
    }

    @Override // 
    /* JADX INFO: renamed from: k, reason: merged with bridge method [inline-methods] */
    public AbstractC3118q clone() {
        try {
            AbstractC3118q abstractC3118q = (AbstractC3118q) super.clone();
            abstractC3118q.f25373v = new ArrayList();
            abstractC3118q.f25360e = new J(17);
            abstractC3118q.f25361f = new J(17);
            abstractC3118q.l = null;
            abstractC3118q.f25364m = null;
            abstractC3118q.f25371t = this;
            abstractC3118q.f25372u = null;
            return abstractC3118q;
        } catch (CloneNotSupportedException e6) {
            throw new RuntimeException(e6);
        }
    }

    public Animator l(ViewGroup viewGroup, C3126y c3126y, C3126y c3126y2) {
        return null;
    }

    public void m(ViewGroup viewGroup, J j4, J j6, ArrayList arrayList, ArrayList arrayList2) {
        int i6;
        int i7;
        View view;
        C3126y c3126y;
        Animator animator;
        C3126y c3126y2;
        C2578e c2578eQ = q();
        SparseIntArray sparseIntArray = new SparseIntArray();
        int size = arrayList.size();
        p().getClass();
        int i8 = 0;
        while (i8 < size) {
            C3126y c3126y3 = (C3126y) arrayList.get(i8);
            C3126y c3126y4 = (C3126y) arrayList2.get(i8);
            if (c3126y3 != null && !c3126y3.f25393c.contains(this)) {
                c3126y3 = null;
            }
            if (c3126y4 != null && !c3126y4.f25393c.contains(this)) {
                c3126y4 = null;
            }
            if ((c3126y3 != null || c3126y4 != null) && (c3126y3 == null || c3126y4 == null || t(c3126y3, c3126y4))) {
                Animator animatorL = l(viewGroup, c3126y3, c3126y4);
                if (animatorL != null) {
                    String str = this.f25356a;
                    if (c3126y4 != null) {
                        String[] strArrR = r();
                        view = c3126y4.f25392b;
                        if (strArrR != null && strArrR.length > 0) {
                            c3126y2 = new C3126y(view);
                            C3126y c3126y5 = (C3126y) ((C2578e) j6.f533b).get(view);
                            i6 = size;
                            if (c3126y5 != null) {
                                int i9 = 0;
                                while (i9 < strArrR.length) {
                                    HashMap map = c3126y2.f25391a;
                                    int i10 = i8;
                                    String str2 = strArrR[i9];
                                    map.put(str2, c3126y5.f25391a.get(str2));
                                    i9++;
                                    i8 = i10;
                                }
                            }
                            i7 = i8;
                            int i11 = c2578eQ.f21416c;
                            int i12 = 0;
                            while (true) {
                                if (i12 >= i11) {
                                    animator = animatorL;
                                    break;
                                }
                                C3115n c3115n = (C3115n) c2578eQ.get((Animator) c2578eQ.g(i12));
                                if (c3115n.f25343c != null && c3115n.f25341a == view && c3115n.f25342b.equals(str) && c3115n.f25343c.equals(c3126y2)) {
                                    animator = null;
                                    break;
                                }
                                i12++;
                            }
                        } else {
                            i6 = size;
                            i7 = i8;
                            animator = animatorL;
                            c3126y2 = null;
                        }
                        animatorL = animator;
                        c3126y = c3126y2;
                    } else {
                        i6 = size;
                        i7 = i8;
                        view = c3126y3.f25392b;
                        c3126y = null;
                    }
                    if (animatorL != null) {
                        WindowId windowId = viewGroup.getWindowId();
                        C3115n c3115n2 = new C3115n();
                        c3115n2.f25341a = view;
                        c3115n2.f25342b = str;
                        c3115n2.f25343c = c3126y;
                        c3115n2.f25344d = windowId;
                        c3115n2.f25345e = this;
                        c3115n2.f25346f = animatorL;
                        c2578eQ.put(animatorL, c3115n2);
                        this.f25373v.add(animatorL);
                    }
                }
                i8 = i7 + 1;
                size = i6;
            }
            i6 = size;
            i7 = i8;
            i8 = i7 + 1;
            size = i6;
        }
        if (sparseIntArray.size() != 0) {
            for (int i13 = 0; i13 < sparseIntArray.size(); i13++) {
                C3115n c3115n3 = (C3115n) c2578eQ.get((Animator) this.f25373v.get(sparseIntArray.keyAt(i13)));
                c3115n3.f25346f.setStartDelay(c3115n3.f25346f.getStartDelay() + (((long) sparseIntArray.valueAt(i13)) - Long.MAX_VALUE));
            }
        }
    }

    public final void n() {
        int i6 = this.f25368q - 1;
        this.f25368q = i6;
        if (i6 == 0) {
            w(this, InterfaceC3117p.f25348b);
            for (int i7 = 0; i7 < ((C2592t) this.f25360e.f535d).h(); i7++) {
                View view = (View) ((C2592t) this.f25360e.f535d).i(i7);
                if (view != null) {
                    view.setHasTransientState(false);
                }
            }
            for (int i8 = 0; i8 < ((C2592t) this.f25361f.f535d).h(); i8++) {
                View view2 = (View) ((C2592t) this.f25361f.f535d).i(i8);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                }
            }
            this.f25370s = true;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x002c, code lost:
    
        if (r2 < 0) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x002e, code lost:
    
        if (r6 == false) goto L24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0030, code lost:
    
        r5 = r4.f25364m;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0033, code lost:
    
        r5 = r4.l;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x003b, code lost:
    
        return (v2.C3126y) r5.get(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x003c, code lost:
    
        return null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3126y o(View view, boolean z6) {
        C3124w c3124w = this.f25362j;
        if (c3124w != null) {
            return c3124w.o(view, z6);
        }
        ArrayList arrayList = z6 ? this.l : this.f25364m;
        if (arrayList == null) {
            return null;
        }
        int size = arrayList.size();
        int i6 = 0;
        while (true) {
            if (i6 >= size) {
                i6 = -1;
                break;
            }
            C3126y c3126y = (C3126y) arrayList.get(i6);
            if (c3126y == null) {
                return null;
            }
            if (c3126y.f25392b == view) {
                break;
            }
            i6++;
        }
    }

    public final AbstractC3118q p() {
        C3124w c3124w = this.f25362j;
        return c3124w != null ? c3124w.p() : this;
    }

    public String[] r() {
        return null;
    }

    public final C3126y s(View view, boolean z6) {
        C3124w c3124w = this.f25362j;
        if (c3124w != null) {
            return c3124w.s(view, z6);
        }
        return (C3126y) ((C2578e) (z6 ? this.f25360e : this.f25361f).f533b).get(view);
    }

    public boolean t(C3126y c3126y, C3126y c3126y2) {
        if (c3126y != null && c3126y2 != null) {
            String[] strArrR = r();
            if (strArrR != null) {
                for (String str : strArrR) {
                    if (v(c3126y, c3126y2, str)) {
                        return true;
                    }
                }
            } else {
                Iterator it = c3126y.f25391a.keySet().iterator();
                while (it.hasNext()) {
                    if (v(c3126y, c3126y2, (String) it.next())) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public final String toString() {
        return I("");
    }

    public final boolean u(View view) {
        int id = view.getId();
        ArrayList arrayList = this.f25358c;
        int size = arrayList.size();
        ArrayList arrayList2 = this.f25359d;
        return (size == 0 && arrayList2.size() == 0) || arrayList.contains(Integer.valueOf(id)) || arrayList2.contains(view);
    }

    public final void w(AbstractC3118q abstractC3118q, InterfaceC3117p interfaceC3117p) {
        AbstractC3118q abstractC3118q2 = this.f25371t;
        if (abstractC3118q2 != null) {
            abstractC3118q2.w(abstractC3118q, interfaceC3117p);
        }
        ArrayList arrayList = this.f25372u;
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        int size = this.f25372u.size();
        InterfaceC3116o[] interfaceC3116oArr = this.f25365n;
        if (interfaceC3116oArr == null) {
            interfaceC3116oArr = new InterfaceC3116o[size];
        }
        this.f25365n = null;
        InterfaceC3116o[] interfaceC3116oArr2 = (InterfaceC3116o[]) this.f25372u.toArray(interfaceC3116oArr);
        for (int i6 = 0; i6 < size; i6++) {
            interfaceC3117p.a(interfaceC3116oArr2[i6], abstractC3118q);
            interfaceC3116oArr2[i6] = null;
        }
        this.f25365n = interfaceC3116oArr2;
    }

    public void x(ViewGroup viewGroup) {
        if (this.f25370s) {
            return;
        }
        ArrayList arrayList = this.f25366o;
        int size = arrayList.size();
        Animator[] animatorArr = (Animator[]) arrayList.toArray(this.f25367p);
        this.f25367p = f25354y;
        for (int i6 = size - 1; i6 >= 0; i6--) {
            Animator animator = animatorArr[i6];
            animatorArr[i6] = null;
            animator.pause();
        }
        this.f25367p = animatorArr;
        w(this, InterfaceC3117p.f25350d);
        this.f25369r = true;
    }

    public AbstractC3118q y(InterfaceC3116o interfaceC3116o) {
        AbstractC3118q abstractC3118q;
        ArrayList arrayList = this.f25372u;
        if (arrayList != null) {
            if (!arrayList.remove(interfaceC3116o) && (abstractC3118q = this.f25371t) != null) {
                abstractC3118q.y(interfaceC3116o);
            }
            if (this.f25372u.size() == 0) {
                this.f25372u = null;
            }
        }
        return this;
    }

    public void z(View view) {
        this.f25359d.remove(view);
    }

    public void D() {
    }

    public void F() {
    }

    public void f(C3126y c3126y) {
    }
}
