package ῲ.ῲ.ʬ.K;

import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.StateSet;
import androidx.appcompat.resources.R$styleable;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.ʬ.ᕣ.AbstractC1713;
import ῲ.ῲ.ʬ.K.C1873;
import ῲ.ῲ.ʬ.K.C1885;
import ῲ.ῲ.㴹.C2012;
import ῲ.㴪.K.K.C2253;
import ῲ.㴪.K.K.C2261;
import ῲ.㴹.C2275;
import ῲ.㴹.C2276;
import K.K.K.ʬ.C2369;

@SuppressLint({"RestrictedAPI"})
/* renamed from: ῲ.ῲ.ʬ.K.K  reason: contains not printable characters */
/* compiled from: AnimatedStateListDrawableCompat */
public class C1877 extends C1885 implements AbstractC1713 {

    /* renamed from: ؿ  reason: contains not printable characters */
    public C1878 f6368;

    /* renamed from: ݜ  reason: contains not printable characters */
    public int f6369;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public AbstractC1881 f6370;

    /* renamed from: 㗽  reason: contains not printable characters */
    public int f6371;

    /* renamed from: 䀟  reason: contains not printable characters */
    public boolean f6372;

    /* renamed from: ῲ.ῲ.ʬ.K.K$ʬ  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static class C1878 extends C1885.C1886 {

        /* renamed from: ಯ  reason: contains not printable characters */
        public C2275<Long> f6373;

        /* renamed from: ጒ  reason: contains not printable characters */
        public C2276<Integer> f6374;

        public C1878(C1878 r1, C1877 k, Resources resources) {
            super(r1, k, resources);
            if (r1 != null) {
                this.f6373 = r1.f6373;
                this.f6374 = r1.f6374;
                return;
            }
            this.f6373 = new C2275<>();
            this.f6374 = new C2276<>(10);
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public static long m4856(int i, int i2) {
            return ((long) i2) | (((long) i) << 32);
        }

        @Override // ῲ.ῲ.ʬ.K.C1885.C1886
        public Drawable newDrawable() {
            return new C1877(this, null);
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public int m4858(int[] iArr) {
            int r1 = super.m4876(iArr);
            if (r1 >= 0) {
                return r1;
            }
            return super.m4876(StateSet.WILD_CARD);
        }

        /* renamed from: K  reason: contains not printable characters */
        public int m4859(int i, int i2, Drawable drawable, boolean z) {
            int r12 = super.m4845(drawable);
            long r0 = m4856(i, i2);
            long j = z ? 8589934592L : 0;
            long j2 = (long) r12;
            this.f6373.m5920(r0, Long.valueOf(j2 | j));
            if (z) {
                this.f6373.m5920(m4856(i2, i), Long.valueOf(4294967296L | j2 | j));
            }
            return r12;
        }

        @Override // ῲ.ῲ.ʬ.K.C1873.AbstractC1874, ῲ.ῲ.ʬ.K.C1885.C1886
        /* renamed from: 㸾  reason: contains not printable characters */
        public void m4860() {
            this.f6373 = this.f6373.clone();
            this.f6374 = this.f6374.clone();
        }

        @Override // ῲ.ῲ.ʬ.K.C1885.C1886
        public Drawable newDrawable(Resources resources) {
            return new C1877(this, resources);
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public int m4857(int i) {
            if (i < 0) {
                return 0;
            }
            return this.f6374.m5925(i, 0).intValue();
        }
    }

    /* renamed from: ῲ.ῲ.ʬ.K.K$ඓ  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static class C1879 extends AbstractC1881 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final boolean f6375;

        /* renamed from: K  reason: contains not printable characters */
        public final ObjectAnimator f6376;

        public C1879(AnimationDrawable animationDrawable, boolean z, boolean z2) {
            super(null);
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            int i = z ? numberOfFrames - 1 : 0;
            int i2 = z ? 0 : numberOfFrames - 1;
            C1883 r4 = new C1883(animationDrawable, z);
            ObjectAnimator ofInt = ObjectAnimator.ofInt(animationDrawable, "currentIndex", i, i2);
            int i3 = Build.VERSION.SDK_INT;
            ofInt.setAutoCancel(true);
            ofInt.setDuration((long) r4.f6378);
            ofInt.setInterpolator(r4);
            this.f6375 = z2;
            this.f6376 = ofInt;
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: ʬ  reason: contains not printable characters */
        public void m4861() {
            this.f6376.start();
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: ῲ  reason: contains not printable characters */
        public void m4862() {
            this.f6376.reverse();
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: K  reason: contains not printable characters */
        public boolean m4863() {
            return this.f6375;
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: 㸾  reason: contains not printable characters */
        public void m4864() {
            this.f6376.cancel();
        }
    }

    /* renamed from: ῲ.ῲ.ʬ.K.K$ῲ  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static class C1880 extends AbstractC1881 {

        /* renamed from: K  reason: contains not printable characters */
        public final Animatable f6377;

        public C1880(Animatable animatable) {
            super(null);
            this.f6377 = animatable;
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: ʬ  reason: contains not printable characters */
        public void m4865() {
            this.f6377.start();
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: 㸾  reason: contains not printable characters */
        public void m4866() {
            this.f6377.stop();
        }
    }

    /* renamed from: ῲ.ῲ.ʬ.K.K$ⁱ  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static abstract class AbstractC1881 {
        public /* synthetic */ AbstractC1881(C1882 k) {
        }

        /* renamed from: ʬ  reason: contains not printable characters */
        public abstract void m4867();

        /* renamed from: ῲ  reason: contains not printable characters */
        public void m4868() {
        }

        /* renamed from: K  reason: contains not printable characters */
        public boolean m4869() {
            return false;
        }

        /* renamed from: 㸾  reason: contains not printable characters */
        public abstract void m4870();
    }

    /* renamed from: ῲ.ῲ.ʬ.K.K$㴹  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static class C1883 implements TimeInterpolator {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f6378;

        /* renamed from: ῲ  reason: contains not printable characters */
        public int f6379;

        /* renamed from: K  reason: contains not printable characters */
        public int[] f6380;

        public C1883(AnimationDrawable animationDrawable, boolean z) {
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            this.f6379 = numberOfFrames;
            int[] iArr = this.f6380;
            if (iArr == null || iArr.length < numberOfFrames) {
                this.f6380 = new int[numberOfFrames];
            }
            int[] iArr2 = this.f6380;
            int i = 0;
            for (int i2 = 0; i2 < numberOfFrames; i2++) {
                int duration = animationDrawable.getDuration(z ? (numberOfFrames - i2) - 1 : i2);
                iArr2[i2] = duration;
                i += duration;
            }
            this.f6378 = i;
        }

        public float getInterpolation(float f) {
            int i = (int) ((f * ((float) this.f6378)) + 0.5f);
            int i2 = this.f6379;
            int[] iArr = this.f6380;
            int i3 = 0;
            while (i3 < i2 && i >= iArr[i3]) {
                i -= iArr[i3];
                i3++;
            }
            return (((float) i3) / ((float) i2)) + (i3 < i2 ? ((float) i) / ((float) this.f6378) : 0.0f);
        }
    }

    /* renamed from: ῲ.ῲ.ʬ.K.K$㸾  reason: contains not printable characters */
    /* compiled from: AnimatedStateListDrawableCompat */
    public static class C1884 extends AbstractC1881 {

        /* renamed from: K  reason: contains not printable characters */
        public final C2253 f6381;

        public C1884(C2253 r2) {
            super(null);
            this.f6381 = r2;
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: ʬ  reason: contains not printable characters */
        public void m4871() {
            this.f6381.start();
        }

        @Override // ῲ.ῲ.ʬ.K.C1877.AbstractC1881
        /* renamed from: 㸾  reason: contains not printable characters */
        public void m4872() {
            this.f6381.stop();
        }
    }

    public C1877() {
        this(null, null);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:69:0x01d1, code lost:
        throw new org.xmlpull.v1.XmlPullParserException(ඓ.K.K.K.C1293.m3415(r19, new java.lang.StringBuilder(), ": <transition> tag requires 'fromId' & 'toId' attributes"));
     */
    /* renamed from: K  reason: contains not printable characters */
    public static C1877 m4852(Context context, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws IOException, XmlPullParserException {
        int depth;
        int next;
        int next2;
        String name = xmlPullParser.getName();
        if (name.equals("animated-selector")) {
            Drawable drawable = null;
            C1877 k = new C1877(null, null);
            TypedArray r7 = C2369.m6305(resources, theme, attributeSet, R$styleable.AnimatedStateListDrawableCompat);
            int i = 1;
            k.setVisible(r7.getBoolean(R$styleable.AnimatedStateListDrawableCompat_android_visible, true), true);
            C1878 r8 = k.f6368;
            int i2 = Build.VERSION.SDK_INT;
            r8.f6361 |= r7.getChangingConfigurations();
            r8.f6346 = r7.getBoolean(R$styleable.AnimatedStateListDrawableCompat_android_variablePadding, r8.f6346);
            r8.f6353 = r7.getBoolean(R$styleable.AnimatedStateListDrawableCompat_android_constantSize, r8.f6353);
            r8.f6352 = r7.getInt(R$styleable.AnimatedStateListDrawableCompat_android_enterFadeDuration, r8.f6352);
            r8.f6356 = r7.getInt(R$styleable.AnimatedStateListDrawableCompat_android_exitFadeDuration, r8.f6356);
            k.setDither(r7.getBoolean(R$styleable.AnimatedStateListDrawableCompat_android_dither, r8.f6358));
            k.f6323.m4849(resources);
            r7.recycle();
            int depth2 = xmlPullParser.getDepth() + 1;
            while (true) {
                int next3 = xmlPullParser.next();
                if (next3 == i || ((depth = xmlPullParser.getDepth()) < depth2 && next3 == 3)) {
                    k.onStateChange(k.getState());
                } else if (next3 == 2 && depth <= depth2) {
                    if (xmlPullParser.getName().equals("item")) {
                        TypedArray r82 = C2369.m6305(resources, theme, attributeSet, R$styleable.AnimatedStateListDrawableItem);
                        int resourceId = r82.getResourceId(R$styleable.AnimatedStateListDrawableItem_android_id, 0);
                        int resourceId2 = r82.getResourceId(R$styleable.AnimatedStateListDrawableItem_android_drawable, -1);
                        if (resourceId2 > 0) {
                            drawable = C2012.m5203().m5206(context, resourceId2);
                        }
                        r82.recycle();
                        int attributeCount = attributeSet.getAttributeCount();
                        int[] iArr = new int[attributeCount];
                        int i3 = 0;
                        for (int i4 = 0; i4 < attributeCount; i4++) {
                            int attributeNameResource = attributeSet.getAttributeNameResource(i4);
                            if (!(attributeNameResource == 0 || attributeNameResource == 16842960 || attributeNameResource == 16843161)) {
                                int i5 = i3 + 1;
                                if (!attributeSet.getAttributeBooleanValue(i4, false)) {
                                    attributeNameResource = -attributeNameResource;
                                }
                                iArr[i3] = attributeNameResource;
                                i3 = i5;
                            }
                        }
                        int[] trimStateSet = StateSet.trimStateSet(iArr, i3);
                        if (drawable == null) {
                            do {
                                next2 = xmlPullParser.next();
                            } while (next2 == 4);
                            if (next2 != 2) {
                                throw new XmlPullParserException(C1293.m3415(xmlPullParser, new StringBuilder(), ": <item> tag requires a 'drawable' attribute or child tag defining a drawable"));
                            } else if (xmlPullParser.getName().equals("vector")) {
                                drawable = C2261.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
                            } else {
                                int i6 = Build.VERSION.SDK_INT;
                                drawable = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
                            }
                        }
                        if (drawable != null) {
                            C1878 r9 = k.f6368;
                            int r6 = r9.m4845(drawable);
                            r9.f6384[r6] = trimStateSet;
                            r9.f6374.m5922(r6, Integer.valueOf(resourceId));
                        } else {
                            throw new XmlPullParserException(C1293.m3415(xmlPullParser, new StringBuilder(), ": <item> tag requires a 'drawable' attribute or child tag defining a drawable"));
                        }
                    } else if (xmlPullParser.getName().equals("transition")) {
                        TypedArray r62 = C2369.m6305(resources, theme, attributeSet, R$styleable.AnimatedStateListDrawableTransition);
                        int resourceId3 = r62.getResourceId(R$styleable.AnimatedStateListDrawableTransition_android_fromId, -1);
                        int resourceId4 = r62.getResourceId(R$styleable.AnimatedStateListDrawableTransition_android_toId, -1);
                        int resourceId5 = r62.getResourceId(R$styleable.AnimatedStateListDrawableTransition_android_drawable, -1);
                        Drawable r12 = resourceId5 > 0 ? C2012.m5203().m5206(context, resourceId5) : null;
                        boolean z = r62.getBoolean(R$styleable.AnimatedStateListDrawableTransition_android_reversible, false);
                        r62.recycle();
                        if (r12 == null) {
                            do {
                                next = xmlPullParser.next();
                            } while (next == 4);
                            if (next != 2) {
                                throw new XmlPullParserException(C1293.m3415(xmlPullParser, new StringBuilder(), ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable"));
                            } else if (xmlPullParser.getName().equals("animated-vector")) {
                                r12 = C2253.m5876(context, resources, xmlPullParser, attributeSet, theme);
                            } else {
                                int i7 = Build.VERSION.SDK_INT;
                                r12 = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
                            }
                        }
                        if (r12 == null) {
                            throw new XmlPullParserException(C1293.m3415(xmlPullParser, new StringBuilder(), ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable"));
                        } else if (resourceId3 != -1 && resourceId4 != -1) {
                            k.f6368.m4859(resourceId3, resourceId4, r12, z);
                        }
                    }
                    drawable = null;
                    i = 1;
                }
            }
            k.onStateChange(k.getState());
            return k;
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid animated-selector tag " + name);
    }

    @Override // ῲ.ῲ.ʬ.K.C1885
    public boolean isStateful() {
        return true;
    }

    @Override // ῲ.ῲ.ʬ.K.C1873
    public void jumpToCurrentState() {
        super.jumpToCurrentState();
        AbstractC1881 r0 = this.f6370;
        if (r0 != null) {
            r0.m4870();
            this.f6370 = null;
            m4842(this.f6371);
            this.f6371 = -1;
            this.f6369 = -1;
        }
    }

    @Override // ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1873
    public Drawable mutate() {
        if (!this.f6372) {
            super.mutate();
            if (this == this) {
                this.f6368.m4860();
                this.f6372 = true;
            }
        }
        return this;
    }

    @Override // ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1873
    public boolean onStateChange(int[] iArr) {
        boolean z;
        AbstractC1881 r7;
        int r2 = this.f6368.m4858(iArr);
        int i = this.f6329;
        boolean z2 = false;
        if (r2 != i) {
            AbstractC1881 r6 = this.f6370;
            if (r6 != null) {
                if (r2 != this.f6371) {
                    if (r2 != this.f6369 || !r6.m4869()) {
                        i = this.f6371;
                        r6.m4870();
                    } else {
                        r6.m4868();
                        this.f6371 = this.f6369;
                        this.f6369 = r2;
                    }
                }
                z = true;
                if (z || m4842(r2)) {
                    z2 = true;
                }
            }
            this.f6370 = null;
            this.f6369 = -1;
            this.f6371 = -1;
            C1878 r62 = this.f6368;
            int r72 = r62.m4857(i);
            int r8 = r62.m4857(r2);
            if (!(r8 == 0 || r72 == 0)) {
                int longValue = (int) r62.f6373.m5915(C1878.m4856(r72, r8), -1L).longValue();
                if (longValue >= 0) {
                    boolean z3 = (r62.f6373.m5915(C1878.m4856(r72, r8), -1L).longValue() & 8589934592L) != 0;
                    m4842(longValue);
                    Drawable drawable = this.f6328;
                    if (drawable instanceof AnimationDrawable) {
                        r7 = new C1879((AnimationDrawable) drawable, (r62.f6373.m5915(C1878.m4856(r72, r8), -1L).longValue() & 4294967296L) != 0, z3);
                    } else if (drawable instanceof C2253) {
                        r7 = new C1884((C2253) drawable);
                    } else if (drawable instanceof Animatable) {
                        r7 = new C1880((Animatable) drawable);
                    }
                    r7.m4867();
                    this.f6370 = r7;
                    this.f6369 = i;
                    this.f6371 = r2;
                    z = true;
                    z2 = true;
                }
            }
            z = false;
            z2 = true;
        }
        Drawable drawable2 = this.f6328;
        return drawable2 != null ? z2 | drawable2.setState(iArr) : z2;
    }

    @Override // ῲ.ῲ.ʬ.K.C1873
    public boolean setVisible(boolean z, boolean z2) {
        boolean visible = super.setVisible(z, z2);
        if (this.f6370 != null && (visible || z2)) {
            if (z) {
                this.f6370.m4867();
            } else {
                jumpToCurrentState();
            }
        }
        return visible;
    }

    public C1877(C1878 r2, Resources resources) {
        super(null);
        this.f6371 = -1;
        this.f6369 = -1;
        C1878 r0 = new C1878(r2, this, resources);
        super.m4875(r0);
        this.f6368 = r0;
        onStateChange(getState());
        jumpToCurrentState();
    }

    @Override // ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1873
    /* renamed from: K  reason: contains not printable characters */
    public C1873.AbstractC1874 m4853() {
        return new C1878(this.f6368, this, null);
    }

    @Override // ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1873
    /* renamed from: K  reason: contains not printable characters */
    public C1885.C1886 m4854() {
        return new C1878(this.f6368, this, null);
    }

    @Override // ῲ.ῲ.ʬ.K.C1885, ῲ.ῲ.ʬ.K.C1873
    /* renamed from: K  reason: contains not printable characters */
    public void m4855(C1873.AbstractC1874 r2) {
        super.m4875(r2);
        if (r2 instanceof C1878) {
            this.f6368 = (C1878) r2;
        }
    }
}
