package ῲ.ῲ.㴹;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
import androidx.appcompat.resources.R$drawable;
import java.lang.ref.WeakReference;
import java.util.WeakHashMap;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ῲ.ᨨ.ῲ.C1806;
import ῲ.ῲ.ʬ.K.C1877;
import ῲ.ῲ.㴹.C2044;
import ῲ.㴪.K.K.C2253;
import ῲ.㴪.K.K.C2261;
import ῲ.㴹.C2275;
import ῲ.㴹.C2276;
import ῲ.㴹.C2286;
import ῲ.㴹.C2287;
import ῲ.㴹.C2288;
import K.K.K.ʬ.C2369;

/* renamed from: ῲ.ῲ.㴹.ᑓ  reason: contains not printable characters */
/* compiled from: ResourceManagerInternal */
public final class C2012 {

    /* renamed from: ᨨ  reason: contains not printable characters */
    public static C2012 f6835;

    /* renamed from: 㳳  reason: contains not printable characters */
    public static final C2013 f6836 = new C2013(6);

    /* renamed from: 㿎  reason: contains not printable characters */
    public static final PorterDuff.Mode f6837 = PorterDuff.Mode.SRC_IN;

    /* renamed from: ʬ  reason: contains not printable characters */
    public C2276<String> f6838;

    /* renamed from: ඓ  reason: contains not printable characters */
    public TypedValue f6839;

    /* renamed from: ῲ  reason: contains not printable characters */
    public C2288<String, AbstractC2018> f6840;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public AbstractC2014 f6841;

    /* renamed from: K  reason: contains not printable characters */
    public WeakHashMap<Context, C2276<ColorStateList>> f6842;

    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean f6843;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final WeakHashMap<Context, C2275<WeakReference<Drawable.ConstantState>>> f6844 = new WeakHashMap<>(0);

    /* renamed from: ῲ.ῲ.㴹.ᑓ$ඓ  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public interface AbstractC2014 {
    }

    /* renamed from: ῲ.ῲ.㴹.ᑓ$ῲ  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public static class C2015 implements AbstractC2018 {
        @Override // ῲ.ῲ.㴹.C2012.AbstractC2018
        /* renamed from: K  reason: contains not printable characters */
        public Drawable m5218(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
            try {
                Resources resources = context.getResources();
                C2253 r2 = new C2253(context, null, null);
                r2.inflate(resources, xmlPullParser, attributeSet, theme);
                return r2;
            } catch (Exception e) {
                Log.e("AvdcInflateDelegate", "Exception while inflating <animated-vector>", e);
                return null;
            }
        }
    }

    /* renamed from: ῲ.ῲ.㴹.ᑓ$K  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public static class C2016 implements AbstractC2018 {
        @Override // ῲ.ῲ.㴹.C2012.AbstractC2018
        /* renamed from: K  reason: contains not printable characters */
        public Drawable m5219(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
            try {
                return C1877.m4852(context, context.getResources(), xmlPullParser, attributeSet, theme);
            } catch (Exception e) {
                Log.e("AsldcInflateDelegate", "Exception while inflating <animated-selector>", e);
                return null;
            }
        }
    }

    /* renamed from: ῲ.ῲ.㴹.ᑓ$㴹  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public static class C2017 implements AbstractC2018 {
        @Override // ῲ.ῲ.㴹.C2012.AbstractC2018
        /* renamed from: K  reason: contains not printable characters */
        public Drawable m5220(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) {
            try {
                return C2261.createFromXmlInner(context.getResources(), xmlPullParser, attributeSet, theme);
            } catch (Exception e) {
                Log.e("VdcInflateDelegate", "Exception while inflating <vector>", e);
                return null;
            }
        }
    }

    /* renamed from: ῲ.ῲ.㴹.ᑓ$㸾  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public interface AbstractC2018 {
        /* renamed from: K  reason: contains not printable characters */
        Drawable m5221(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static synchronized C2012 m5203() {
        C2012 r1;
        synchronized (C2012.class) {
            if (f6835 == null) {
                f6835 = new C2012();
                C2012 r12 = f6835;
                if (Build.VERSION.SDK_INT < 24) {
                    r12.m5212("vector", new C2017());
                    r12.m5212("animated-vector", new C2015());
                    r12.m5212("animated-selector", new C2016());
                }
            }
            r1 = f6835;
        }
        return r1;
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public synchronized ColorStateList m5205(Context context, int i) {
        ColorStateList colorStateList;
        C2276<ColorStateList> r0;
        WeakHashMap<Context, C2276<ColorStateList>> weakHashMap = this.f6842;
        ColorStateList colorStateList2 = null;
        if (weakHashMap == null || (r0 = weakHashMap.get(context)) == null) {
            colorStateList = null;
        } else {
            colorStateList = r0.m5925(i, null);
        }
        if (colorStateList == null) {
            if (this.f6841 != null) {
                colorStateList2 = ((C2044.C2045) this.f6841).m5319(context, i);
            }
            colorStateList = colorStateList2;
            if (colorStateList != null) {
                if (this.f6842 == null) {
                    this.f6842 = new WeakHashMap<>();
                }
                C2276<ColorStateList> r1 = this.f6842.get(context);
                if (r1 == null) {
                    r1 = new C2276<>(10);
                    this.f6842.put(context, r1);
                }
                r1.m5928(i, colorStateList);
            }
        }
        return colorStateList;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public synchronized Drawable m5206(Context context, int i) {
        return m5208(context, i, false);
    }

    /* JADX WARNING: Removed duplicated region for block: B:30:0x007b A[Catch:{ Exception -> 0x00a9 }] */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00a1 A[Catch:{ Exception -> 0x00a9 }] */
    /* renamed from: 㸾  reason: contains not printable characters */
    public final Drawable m5215(Context context, int i) {
        int next;
        C2288<String, AbstractC2018> r0 = this.f6840;
        if (r0 == null || r0.isEmpty()) {
            return null;
        }
        C2276<String> r02 = this.f6838;
        if (r02 != null) {
            String r03 = r02.m5925(i, null);
            if ("appcompat_skip_skip".equals(r03) || (r03 != null && this.f6840.getOrDefault(r03, null) == null)) {
                return null;
            }
        } else {
            this.f6838 = new C2276<>(10);
        }
        if (this.f6839 == null) {
            this.f6839 = new TypedValue();
        }
        TypedValue typedValue = this.f6839;
        Resources resources = context.getResources();
        resources.getValue(i, typedValue, true);
        long j = (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
        Drawable r6 = m5210(context, j);
        if (r6 != null) {
            return r6;
        }
        CharSequence charSequence = typedValue.string;
        if (charSequence != null && charSequence.toString().endsWith(".xml")) {
            try {
                XmlResourceParser xml = resources.getXml(i);
                AttributeSet asAttributeSet = Xml.asAttributeSet(xml);
                while (true) {
                    next = xml.next();
                    if (next == 2 || next == 1) {
                        if (next != 2) {
                            String name = xml.getName();
                            this.f6838.m5928(i, name);
                            AbstractC2018 r3 = this.f6840.get(name);
                            if (r3 != null) {
                                r6 = r3.m5221(context, xml, asAttributeSet, context.getTheme());
                            }
                            if (r6 != null) {
                                r6.setChangingConfigurations(typedValue.changingConfigurations);
                                m5214(context, j, r6);
                            }
                        } else {
                            throw new XmlPullParserException("No start tag found");
                        }
                    }
                }
                if (next != 2) {
                }
            } catch (Exception e) {
                Log.e("ResourceManagerInternal", "Exception while inflating drawable", e);
            }
        }
        if (r6 == null) {
            this.f6838.m5928(i, "appcompat_skip_skip");
        }
        return r6;
    }

    /* renamed from: ῲ.ῲ.㴹.ᑓ$ʬ  reason: contains not printable characters */
    /* compiled from: ResourceManagerInternal */
    public static class C2013 extends C2286<Integer, PorterDuffColorFilter> {
        public C2013(int i) {
            super(i);
        }

        /* renamed from: K  reason: contains not printable characters */
        public PorterDuffColorFilter m5216(int i, PorterDuff.Mode mode) {
            return (PorterDuffColorFilter) m5962(Integer.valueOf(mode.hashCode() + ((i + 31) * 31)));
        }

        /* renamed from: K  reason: contains not printable characters */
        public PorterDuffColorFilter m5217(int i, PorterDuff.Mode mode, PorterDuffColorFilter porterDuffColorFilter) {
            return (PorterDuffColorFilter) m5963(Integer.valueOf(mode.hashCode() + ((i + 31) * 31)), porterDuffColorFilter);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m5213(AbstractC2014 r1) {
        this.f6841 = r1;
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized void m5211(Context context) {
        C2275<WeakReference<Drawable.ConstantState>> r2 = this.f6844.get(context);
        if (r2 != null) {
            r2.m5919();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final Drawable m5207(Context context, int i) {
        Drawable drawable;
        if (this.f6839 == null) {
            this.f6839 = new TypedValue();
        }
        TypedValue typedValue = this.f6839;
        context.getResources().getValue(i, typedValue, true);
        long j = (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
        Drawable r3 = m5210(context, j);
        if (r3 != null) {
            return r3;
        }
        AbstractC2014 r32 = this.f6841;
        if (r32 == null) {
            drawable = null;
        } else {
            drawable = ((C2044.C2045) r32).m5323(this, context, i);
        }
        if (drawable != null) {
            drawable.setChangingConfigurations(typedValue.changingConfigurations);
            m5214(context, j, drawable);
        }
        return drawable;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final Drawable m5209(Context context, int i, boolean z, Drawable drawable) {
        ColorStateList r0 = m5205(context, i);
        PorterDuff.Mode mode = null;
        if (r0 != null) {
            if (C2021.m5243(drawable)) {
                drawable = drawable.mutate();
            }
            Drawable r6 = C2369.m6273(drawable);
            int i2 = Build.VERSION.SDK_INT;
            r6.setTintList(r0);
            AbstractC2014 r3 = this.f6841;
            if (r3 != null) {
                mode = ((C2044.C2045) r3).m5322(i);
            }
            if (mode == null) {
                return r6;
            }
            int i3 = Build.VERSION.SDK_INT;
            r6.setTintMode(mode);
            return r6;
        }
        AbstractC2014 r02 = this.f6841;
        if (r02 != null && ((C2044.C2045) r02).m5325(context, i, drawable)) {
            return drawable;
        }
        AbstractC2014 r03 = this.f6841;
        if ((r03 != null && ((C2044.C2045) r03).m5320(context, i, drawable)) || !z) {
            return drawable;
        }
        return null;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final synchronized Drawable m5210(Context context, long j) {
        Object[] objArr;
        Object obj;
        C2275<WeakReference<Drawable.ConstantState>> r0 = this.f6844.get(context);
        if (r0 == null) {
            return null;
        }
        WeakReference<Drawable.ConstantState> r2 = r0.m5915(j, null);
        if (r2 != null) {
            Drawable.ConstantState constantState = r2.get();
            if (constantState != null) {
                return constantState.newDrawable(context.getResources());
            }
            int r4 = C2287.m5969(r0.f7866, r0.f7867, j);
            if (r4 >= 0 && (objArr = r0.f7869)[r4] != (obj = C2275.f7865)) {
                objArr[r4] = obj;
                r0.f7868 = true;
            }
        }
        return null;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final synchronized boolean m5214(Context context, long j, Drawable drawable) {
        Drawable.ConstantState constantState = drawable.getConstantState();
        if (constantState == null) {
            return false;
        }
        C2275<WeakReference<Drawable.ConstantState>> r0 = this.f6844.get(context);
        if (r0 == null) {
            r0 = new C2275<>();
            this.f6844.put(context, r0);
        }
        r0.m5914(j, new WeakReference<>(constantState));
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m5212(String str, AbstractC2018 r3) {
        if (this.f6840 == null) {
            this.f6840 = new C2288<>();
        }
        this.f6840.put(str, r3);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5204(Drawable drawable, C2029 r4, int[] iArr) {
        if (!C2021.m5243(drawable) || drawable.mutate() == drawable) {
            if (r4.f6877 || r4.f6874) {
                PorterDuffColorFilter porterDuffColorFilter = null;
                ColorStateList colorStateList = r4.f6877 ? r4.f6876 : null;
                PorterDuff.Mode mode = r4.f6874 ? r4.f6875 : f6837;
                if (!(colorStateList == null || mode == null)) {
                    porterDuffColorFilter = m5202(colorStateList.getColorForState(iArr, 0), mode);
                }
                drawable.setColorFilter(porterDuffColorFilter);
            } else {
                drawable.clearColorFilter();
            }
            if (Build.VERSION.SDK_INT <= 23) {
                drawable.invalidateSelf();
                return;
            }
            return;
        }
        Log.d("ResourceManagerInternal", "Mutated drawable is not the same instance as the input.");
    }

    /* renamed from: K  reason: contains not printable characters */
    public static synchronized PorterDuffColorFilter m5202(int i, PorterDuff.Mode mode) {
        PorterDuffColorFilter r1;
        synchronized (C2012.class) {
            r1 = f6836.m5216(i, mode);
            if (r1 == null) {
                r1 = new PorterDuffColorFilter(i, mode);
                f6836.m5217(i, mode, r1);
            }
        }
        return r1;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0028, code lost:
        if (r0 != false) goto L_0x002a;
     */
    /* renamed from: K  reason: contains not printable characters */
    public synchronized Drawable m5208(Context context, int i, boolean z) {
        Drawable r0;
        if (!this.f6843) {
            boolean z2 = true;
            this.f6843 = true;
            Drawable r1 = m5206(context, R$drawable.abc_vector_test);
            if (r1 != null) {
                if (!(r1 instanceof C2261)) {
                    if (!"android.graphics.drawable.VectorDrawable".equals(r1.getClass().getName())) {
                        z2 = false;
                    }
                }
            }
            this.f6843 = false;
            throw new IllegalStateException("This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.");
        }
        r0 = m5215(context, i);
        if (r0 == null) {
            r0 = m5207(context, i);
        }
        if (r0 == null) {
            r0 = C1806.m4683(context, i);
        }
        if (r0 != null) {
            r0 = m5209(context, i, z, r0);
        }
        if (r0 != null) {
            C2021.m5241(r0);
        }
        return r0;
    }
}
