package z0;

import P.I;
import P.Q;
import P.V;
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import m.C0863j;
import r.AbstractC0969h;
import r.C0966e;
import r.C0968g;
import s.AbstractC0996a;

/* JADX INFO: renamed from: z0.p, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC1147p implements Cloneable {

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

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public static final C0863j f11019F = new C0863j();

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

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public b5.a f11023C;

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

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

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

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public TimeInterpolator f11028n = null;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final ArrayList f11029o = new ArrayList();
    public final ArrayList p = new ArrayList();
    public com.google.firebase.messaging.w q = new com.google.firebase.messaging.w(21);

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public com.google.firebase.messaging.w f11030r = new com.google.firebase.messaging.w(21);

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public C1152u f11031s = null;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final int[] f11032t = f11018E;

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

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

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

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

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

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

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public C0863j f11024D = f11019F;

    public static void c(com.google.firebase.messaging.w wVar, View view, C1154w c1154w) {
        ((C0966e) wVar.f5943k).put(view, c1154w);
        int id = view.getId();
        if (id >= 0) {
            SparseArray sparseArray = (SparseArray) wVar.f5944l;
            if (sparseArray.indexOfKey(id) >= 0) {
                sparseArray.put(id, null);
            } else {
                sparseArray.put(id, view);
            }
        }
        Field field = Q.f2392a;
        String strF = I.f(view);
        if (strF != null) {
            C0966e c0966e = (C0966e) wVar.f5946n;
            if (c0966e.containsKey(strF)) {
                c0966e.put(strF, null);
            } else {
                c0966e.put(strF, view);
            }
        }
        if (view.getParent() instanceof ListView) {
            ListView listView = (ListView) view.getParent();
            if (listView.getAdapter().hasStableIds()) {
                long itemIdAtPosition = listView.getItemIdAtPosition(listView.getPositionForView(view));
                C0968g c0968g = (C0968g) wVar.f5945m;
                if (c0968g.f9603k) {
                    int i = c0968g.f9606n;
                    long[] jArr = c0968g.f9604l;
                    Object[] objArr = c0968g.f9605m;
                    int i5 = 0;
                    for (int i6 = 0; i6 < i; i6++) {
                        Object obj = objArr[i6];
                        if (obj != AbstractC0969h.f9607a) {
                            if (i6 != i5) {
                                jArr[i5] = jArr[i6];
                                objArr[i5] = obj;
                                objArr[i6] = null;
                            }
                            i5++;
                        }
                    }
                    c0968g.f9603k = false;
                    c0968g.f9606n = i5;
                }
                if (AbstractC0996a.b(c0968g.f9604l, c0968g.f9606n, itemIdAtPosition) < 0) {
                    view.setHasTransientState(true);
                    c0968g.d(view, itemIdAtPosition);
                    return;
                }
                View view2 = (View) c0968g.b(itemIdAtPosition);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                    c0968g.d(null, itemIdAtPosition);
                }
            }
        }
    }

    public static C0966e p() {
        ThreadLocal threadLocal = f11020G;
        C0966e c0966e = (C0966e) threadLocal.get();
        if (c0966e != null) {
            return c0966e;
        }
        C0966e c0966e2 = new C0966e(0);
        threadLocal.set(c0966e2);
        return c0966e2;
    }

    public static boolean u(C1154w c1154w, C1154w c1154w2, String str) {
        Object obj = c1154w.f11051a.get(str);
        Object obj2 = c1154w2.f11051a.get(str);
        if (obj == null && obj2 == null) {
            return false;
        }
        if (obj == null || obj2 == null) {
            return true;
        }
        return !obj.equals(obj2);
    }

    public void A(long j5) {
        this.f11027m = j5;
    }

    public void B(b5.a aVar) {
        this.f11023C = aVar;
    }

    public void C(TimeInterpolator timeInterpolator) {
        this.f11028n = timeInterpolator;
    }

    public void D(C0863j c0863j) {
        if (c0863j == null) {
            this.f11024D = f11019F;
        } else {
            this.f11024D = c0863j;
        }
    }

    public void F(long j5) {
        this.f11026l = j5;
    }

    public final void G() {
        if (this.f11036x == 0) {
            ArrayList arrayList = this.f11021A;
            if (arrayList != null && arrayList.size() > 0) {
                ArrayList arrayList2 = (ArrayList) this.f11021A.clone();
                int size = arrayList2.size();
                for (int i = 0; i < size; i++) {
                    ((InterfaceC1146o) arrayList2.get(i)).d(this);
                }
            }
            this.f11038z = false;
        }
        this.f11036x++;
    }

    public String H(String str) {
        StringBuilder sbB = u.e.b(str);
        sbB.append(getClass().getSimpleName());
        sbB.append("@");
        sbB.append(Integer.toHexString(hashCode()));
        sbB.append(": ");
        String string = sbB.toString();
        if (this.f11027m != -1) {
            string = string + "dur(" + this.f11027m + ") ";
        }
        if (this.f11026l != -1) {
            string = string + "dly(" + this.f11026l + ") ";
        }
        if (this.f11028n != null) {
            string = string + "interp(" + this.f11028n + ") ";
        }
        ArrayList arrayList = this.f11029o;
        int size = arrayList.size();
        ArrayList arrayList2 = this.p;
        if (size <= 0 && arrayList2.size() <= 0) {
            return string;
        }
        String strC = s0.c.c(string, "tgts(");
        if (arrayList.size() > 0) {
            for (int i = 0; i < arrayList.size(); i++) {
                if (i > 0) {
                    strC = s0.c.c(strC, ", ");
                }
                StringBuilder sbB2 = u.e.b(strC);
                sbB2.append(arrayList.get(i));
                strC = sbB2.toString();
            }
        }
        if (arrayList2.size() > 0) {
            for (int i5 = 0; i5 < arrayList2.size(); i5++) {
                if (i5 > 0) {
                    strC = s0.c.c(strC, ", ");
                }
                StringBuilder sbB3 = u.e.b(strC);
                sbB3.append(arrayList2.get(i5));
                strC = sbB3.toString();
            }
        }
        return s0.c.c(strC, ")");
    }

    public void a(InterfaceC1146o interfaceC1146o) {
        if (this.f11021A == null) {
            this.f11021A = new ArrayList();
        }
        this.f11021A.add(interfaceC1146o);
    }

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

    public void d() {
        ArrayList arrayList = this.f11035w;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            ((Animator) arrayList.get(size)).cancel();
        }
        ArrayList arrayList2 = this.f11021A;
        if (arrayList2 == null || arrayList2.size() <= 0) {
            return;
        }
        ArrayList arrayList3 = (ArrayList) this.f11021A.clone();
        int size2 = arrayList3.size();
        for (int i = 0; i < size2; i++) {
            ((InterfaceC1146o) arrayList3.get(i)).c();
        }
    }

    public abstract void e(C1154w c1154w);

    public final void f(View view, boolean z5) {
        if (view == null) {
            return;
        }
        view.getId();
        if (view.getParent() instanceof ViewGroup) {
            C1154w c1154w = new C1154w(view);
            if (z5) {
                h(c1154w);
            } else {
                e(c1154w);
            }
            c1154w.f11053c.add(this);
            g(c1154w);
            if (z5) {
                c(this.q, view, c1154w);
            } else {
                c(this.f11030r, view, c1154w);
            }
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                f(viewGroup.getChildAt(i), z5);
            }
        }
    }

    public abstract void h(C1154w c1154w);

    public final void i(ViewGroup viewGroup, boolean z5) {
        j(z5);
        ArrayList arrayList = this.f11029o;
        int size = arrayList.size();
        ArrayList arrayList2 = this.p;
        if (size <= 0 && arrayList2.size() <= 0) {
            f(viewGroup, z5);
            return;
        }
        for (int i = 0; i < arrayList.size(); i++) {
            View viewFindViewById = viewGroup.findViewById(((Integer) arrayList.get(i)).intValue());
            if (viewFindViewById != null) {
                C1154w c1154w = new C1154w(viewFindViewById);
                if (z5) {
                    h(c1154w);
                } else {
                    e(c1154w);
                }
                c1154w.f11053c.add(this);
                g(c1154w);
                if (z5) {
                    c(this.q, viewFindViewById, c1154w);
                } else {
                    c(this.f11030r, viewFindViewById, c1154w);
                }
            }
        }
        for (int i5 = 0; i5 < arrayList2.size(); i5++) {
            View view = (View) arrayList2.get(i5);
            C1154w c1154w2 = new C1154w(view);
            if (z5) {
                h(c1154w2);
            } else {
                e(c1154w2);
            }
            c1154w2.f11053c.add(this);
            g(c1154w2);
            if (z5) {
                c(this.q, view, c1154w2);
            } else {
                c(this.f11030r, view, c1154w2);
            }
        }
    }

    public final void j(boolean z5) {
        if (z5) {
            ((C0966e) this.q.f5943k).clear();
            ((SparseArray) this.q.f5944l).clear();
            ((C0968g) this.q.f5945m).a();
        } else {
            ((C0966e) this.f11030r.f5943k).clear();
            ((SparseArray) this.f11030r.f5944l).clear();
            ((C0968g) this.f11030r.f5945m).a();
        }
    }

    @Override // 
    /* JADX INFO: renamed from: k, reason: merged with bridge method [inline-methods] */
    public AbstractC1147p clone() {
        try {
            AbstractC1147p abstractC1147p = (AbstractC1147p) super.clone();
            abstractC1147p.f11022B = new ArrayList();
            abstractC1147p.q = new com.google.firebase.messaging.w(21);
            abstractC1147p.f11030r = new com.google.firebase.messaging.w(21);
            abstractC1147p.f11033u = null;
            abstractC1147p.f11034v = null;
            return abstractC1147p;
        } catch (CloneNotSupportedException unused) {
            return null;
        }
    }

    public Animator l(ViewGroup viewGroup, C1154w c1154w, C1154w c1154w2) {
        return null;
    }

    public void m(ViewGroup viewGroup, com.google.firebase.messaging.w wVar, com.google.firebase.messaging.w wVar2, ArrayList arrayList, ArrayList arrayList2) {
        Animator animatorL;
        int i;
        int i5;
        View view;
        C1154w c1154w;
        Animator animator;
        C1154w c1154w2;
        C0966e c0966eP = p();
        SparseIntArray sparseIntArray = new SparseIntArray();
        int size = arrayList.size();
        int i6 = 0;
        while (i6 < size) {
            C1154w c1154w3 = (C1154w) arrayList.get(i6);
            C1154w c1154w4 = (C1154w) arrayList2.get(i6);
            if (c1154w3 != null && !c1154w3.f11053c.contains(this)) {
                c1154w3 = null;
            }
            if (c1154w4 != null && !c1154w4.f11053c.contains(this)) {
                c1154w4 = null;
            }
            if (!(c1154w3 == null && c1154w4 == null) && ((c1154w3 == null || c1154w4 == null || s(c1154w3, c1154w4)) && (animatorL = l(viewGroup, c1154w3, c1154w4)) != null)) {
                String str = this.f11025k;
                if (c1154w4 != null) {
                    String[] strArrQ = q();
                    view = c1154w4.f11052b;
                    if (strArrQ != null && strArrQ.length > 0) {
                        c1154w2 = new C1154w(view);
                        C1154w c1154w5 = (C1154w) ((C0966e) wVar2.f5943k).get(view);
                        i = size;
                        if (c1154w5 != null) {
                            int i7 = 0;
                            while (i7 < strArrQ.length) {
                                HashMap map = c1154w2.f11051a;
                                int i8 = i6;
                                String str2 = strArrQ[i7];
                                map.put(str2, c1154w5.f11051a.get(str2));
                                i7++;
                                i6 = i8;
                            }
                        }
                        i5 = i6;
                        int i9 = c0966eP.f9618m;
                        int i10 = 0;
                        while (true) {
                            if (i10 >= i9) {
                                animator = animatorL;
                                break;
                            }
                            C1145n c1145n = (C1145n) c0966eP.get((Animator) c0966eP.f(i10));
                            if (c1145n.f11015c != null && c1145n.f11013a == view && c1145n.f11014b.equals(str) && c1145n.f11015c.equals(c1154w2)) {
                                animator = null;
                                break;
                            }
                            i10++;
                        }
                    } else {
                        i = size;
                        i5 = i6;
                        animator = animatorL;
                        c1154w2 = null;
                    }
                    animatorL = animator;
                    c1154w = c1154w2;
                } else {
                    i = size;
                    i5 = i6;
                    view = c1154w3.f11052b;
                    c1154w = null;
                }
                if (animatorL != null) {
                    y yVar = x.f11054a;
                    C1131D c1131d = new C1131D(viewGroup);
                    C1145n c1145n2 = new C1145n();
                    c1145n2.f11013a = view;
                    c1145n2.f11014b = str;
                    c1145n2.f11015c = c1154w;
                    c1145n2.f11016d = c1131d;
                    c1145n2.f11017e = this;
                    c0966eP.put(animatorL, c1145n2);
                    this.f11022B.add(animatorL);
                }
            } else {
                i = size;
                i5 = i6;
            }
            i6 = i5 + 1;
            size = i;
        }
        if (sparseIntArray.size() != 0) {
            for (int i11 = 0; i11 < sparseIntArray.size(); i11++) {
                Animator animator2 = (Animator) this.f11022B.get(sparseIntArray.keyAt(i11));
                animator2.setStartDelay(animator2.getStartDelay() + (((long) sparseIntArray.valueAt(i11)) - Long.MAX_VALUE));
            }
        }
    }

    public final void n() {
        int i = this.f11036x - 1;
        this.f11036x = i;
        if (i == 0) {
            ArrayList arrayList = this.f11021A;
            if (arrayList != null && arrayList.size() > 0) {
                ArrayList arrayList2 = (ArrayList) this.f11021A.clone();
                int size = arrayList2.size();
                for (int i5 = 0; i5 < size; i5++) {
                    ((InterfaceC1146o) arrayList2.get(i5)).e(this);
                }
            }
            for (int i6 = 0; i6 < ((C0968g) this.q.f5945m).e(); i6++) {
                View view = (View) ((C0968g) this.q.f5945m).f(i6);
                if (view != null) {
                    Field field = Q.f2392a;
                    view.setHasTransientState(false);
                }
            }
            for (int i7 = 0; i7 < ((C0968g) this.f11030r.f5945m).e(); i7++) {
                View view2 = (View) ((C0968g) this.f11030r.f5945m).f(i7);
                if (view2 != null) {
                    Field field2 = Q.f2392a;
                    view2.setHasTransientState(false);
                }
            }
            this.f11038z = 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.f11034v;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0033, code lost:
    
        r5 = r4.f11033u;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x003b, code lost:
    
        return (z0.C1154w) 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.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final z0.C1154w o(android.view.View r5, boolean r6) {
        /*
            r4 = this;
            z0.u r0 = r4.f11031s
            if (r0 == 0) goto L9
            z0.w r5 = r0.o(r5, r6)
            return r5
        L9:
            if (r6 == 0) goto Le
            java.util.ArrayList r0 = r4.f11033u
            goto L10
        Le:
            java.util.ArrayList r0 = r4.f11034v
        L10:
            if (r0 != 0) goto L13
            goto L3c
        L13:
            int r1 = r0.size()
            r2 = 0
        L18:
            if (r2 >= r1) goto L2b
            java.lang.Object r3 = r0.get(r2)
            z0.w r3 = (z0.C1154w) r3
            if (r3 != 0) goto L23
            goto L3c
        L23:
            android.view.View r3 = r3.f11052b
            if (r3 != r5) goto L28
            goto L2c
        L28:
            int r2 = r2 + 1
            goto L18
        L2b:
            r2 = -1
        L2c:
            if (r2 < 0) goto L3c
            if (r6 == 0) goto L33
            java.util.ArrayList r5 = r4.f11034v
            goto L35
        L33:
            java.util.ArrayList r5 = r4.f11033u
        L35:
            java.lang.Object r5 = r5.get(r2)
            z0.w r5 = (z0.C1154w) r5
            return r5
        L3c:
            r5 = 0
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: z0.AbstractC1147p.o(android.view.View, boolean):z0.w");
    }

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

    public final C1154w r(View view, boolean z5) {
        C1152u c1152u = this.f11031s;
        if (c1152u != null) {
            return c1152u.r(view, z5);
        }
        return (C1154w) ((C0966e) (z5 ? this.q : this.f11030r).f5943k).get(view);
    }

    public boolean s(C1154w c1154w, C1154w c1154w2) {
        if (c1154w != null && c1154w2 != null) {
            String[] strArrQ = q();
            if (strArrQ != null) {
                for (String str : strArrQ) {
                    if (u(c1154w, c1154w2, str)) {
                        return true;
                    }
                }
            } else {
                Iterator it = c1154w.f11051a.keySet().iterator();
                while (it.hasNext()) {
                    if (u(c1154w, c1154w2, (String) it.next())) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

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

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

    public void v(ViewGroup viewGroup) {
        if (this.f11038z) {
            return;
        }
        ArrayList arrayList = this.f11035w;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            ((Animator) arrayList.get(size)).pause();
        }
        ArrayList arrayList2 = this.f11021A;
        if (arrayList2 != null && arrayList2.size() > 0) {
            ArrayList arrayList3 = (ArrayList) this.f11021A.clone();
            int size2 = arrayList3.size();
            for (int i = 0; i < size2; i++) {
                ((InterfaceC1146o) arrayList3.get(i)).a();
            }
        }
        this.f11037y = true;
    }

    public void w(InterfaceC1146o interfaceC1146o) {
        ArrayList arrayList = this.f11021A;
        if (arrayList == null) {
            return;
        }
        arrayList.remove(interfaceC1146o);
        if (this.f11021A.size() == 0) {
            this.f11021A = null;
        }
    }

    public void x(View view) {
        this.p.remove(view);
    }

    public void y(View view) {
        if (this.f11037y) {
            if (!this.f11038z) {
                ArrayList arrayList = this.f11035w;
                for (int size = arrayList.size() - 1; size >= 0; size--) {
                    ((Animator) arrayList.get(size)).resume();
                }
                ArrayList arrayList2 = this.f11021A;
                if (arrayList2 != null && arrayList2.size() > 0) {
                    ArrayList arrayList3 = (ArrayList) this.f11021A.clone();
                    int size2 = arrayList3.size();
                    for (int i = 0; i < size2; i++) {
                        ((InterfaceC1146o) arrayList3.get(i)).b();
                    }
                }
            }
            this.f11037y = false;
        }
    }

    public void z() {
        G();
        C0966e c0966eP = p();
        for (Animator animator : this.f11022B) {
            if (c0966eP.containsKey(animator)) {
                G();
                if (animator != null) {
                    animator.addListener(new V(this, c0966eP));
                    long j5 = this.f11027m;
                    if (j5 >= 0) {
                        animator.setDuration(j5);
                    }
                    long j6 = this.f11026l;
                    if (j6 >= 0) {
                        animator.setStartDelay(animator.getStartDelay() + j6);
                    }
                    TimeInterpolator timeInterpolator = this.f11028n;
                    if (timeInterpolator != null) {
                        animator.setInterpolator(timeInterpolator);
                    }
                    animator.addListener(new T1.a(3, this));
                    animator.start();
                }
            }
        }
        this.f11022B.clear();
        n();
    }

    public void E() {
    }

    public void g(C1154w c1154w) {
    }
}
