package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.widget.TextView;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class A8 {
    public final TextView a;
    public C1794ll b;
    public C1794ll c;
    public C1794ll d;
    public C1794ll e;
    public C1794ll f;
    public C1794ll g;
    public C1794ll h;
    public final J8 i;
    public int j = 0;
    public int k = -1;
    public Typeface l;
    public boolean m;

    public A8(TextView textView) {
        this.a = textView;
        this.i = new J8(textView);
    }

    public static C1794ll c(Context context, V7 v7, int i) {
        ColorStateList colorStateListF;
        synchronized (v7) {
            colorStateListF = v7.a.f(context, i);
        }
        if (colorStateListF == null) {
            return null;
        }
        C1794ll c1794ll = new C1794ll();
        c1794ll.b = true;
        c1794ll.c = colorStateListF;
        return c1794ll;
    }

    public final void a(Drawable drawable, C1794ll c1794ll) {
        if (drawable == null || c1794ll == null) {
            return;
        }
        V7.e(drawable, c1794ll, this.a.getDrawableState());
    }

    public final void b() {
        C1794ll c1794ll = this.b;
        TextView textView = this.a;
        if (c1794ll != null || this.c != null || this.d != null || this.e != null) {
            Drawable[] compoundDrawables = textView.getCompoundDrawables();
            a(compoundDrawables[0], this.b);
            a(compoundDrawables[1], this.c);
            a(compoundDrawables[2], this.d);
            a(compoundDrawables[3], this.e);
        }
        if (this.f == null && this.g == null) {
            return;
        }
        Drawable[] compoundDrawablesRelative = textView.getCompoundDrawablesRelative();
        a(compoundDrawablesRelative[0], this.f);
        a(compoundDrawablesRelative[2], this.g);
    }

    public final ColorStateList d() {
        C1794ll c1794ll = this.h;
        if (c1794ll != null) {
            return (ColorStateList) c1794ll.c;
        }
        return null;
    }

    public final PorterDuff.Mode e() {
        C1794ll c1794ll = this.h;
        if (c1794ll != null) {
            return (PorterDuff.Mode) c1794ll.d;
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:227:0x03a1  */
    /* JADX WARN: Removed duplicated region for block: B:229:0x03a6  */
    /* JADX WARN: Removed duplicated region for block: B:232:0x03ad  */
    /* JADX WARN: Removed duplicated region for block: B:242:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void f(android.util.AttributeSet r26, int r27) {
        /*
            Method dump skipped, instructions count: 978
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.A8.f(android.util.AttributeSet, int):void");
    }

    public final void g(Context context, int i) {
        String string;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(i, YZ.v);
        C70 c70 = new C70(context, typedArrayObtainStyledAttributes);
        boolean zHasValue = typedArrayObtainStyledAttributes.hasValue(14);
        TextView textView = this.a;
        if (zHasValue) {
            textView.setAllCaps(typedArrayObtainStyledAttributes.getBoolean(14, false));
        }
        int i2 = Build.VERSION.SDK_INT;
        if (typedArrayObtainStyledAttributes.hasValue(0) && typedArrayObtainStyledAttributes.getDimensionPixelSize(0, -1) == 0) {
            textView.setTextSize(0, 0.0f);
        }
        m(context, c70);
        if (i2 >= 26 && typedArrayObtainStyledAttributes.hasValue(13) && (string = typedArrayObtainStyledAttributes.getString(13)) != null) {
            AbstractC2976y8.d(textView, string);
        }
        c70.t();
        Typeface typeface = this.l;
        if (typeface != null) {
            textView.setTypeface(typeface, this.j);
        }
    }

    public final void h(int i, int i2, int i3, int i4) {
        J8 j8 = this.i;
        if (j8.i()) {
            DisplayMetrics displayMetrics = j8.j.getResources().getDisplayMetrics();
            j8.j(TypedValue.applyDimension(i4, i, displayMetrics), TypedValue.applyDimension(i4, i2, displayMetrics), TypedValue.applyDimension(i4, i3, displayMetrics));
            if (j8.g()) {
                j8.a();
            }
        }
    }

    public final void i(int[] iArr, int i) {
        J8 j8 = this.i;
        if (j8.i()) {
            int length = iArr.length;
            if (length > 0) {
                int[] iArrCopyOf = new int[length];
                if (i == 0) {
                    iArrCopyOf = Arrays.copyOf(iArr, length);
                } else {
                    DisplayMetrics displayMetrics = j8.j.getResources().getDisplayMetrics();
                    for (int i2 = 0; i2 < length; i2++) {
                        iArrCopyOf[i2] = Math.round(TypedValue.applyDimension(i, iArr[i2], displayMetrics));
                    }
                }
                j8.f = J8.b(iArrCopyOf);
                if (!j8.h()) {
                    throw new IllegalArgumentException("None of the preset sizes is valid: " + Arrays.toString(iArr));
                }
            } else {
                j8.g = false;
            }
            if (j8.g()) {
                j8.a();
            }
        }
    }

    public final void j(int i) {
        J8 j8 = this.i;
        if (j8.i()) {
            if (i == 0) {
                j8.a = 0;
                j8.d = -1.0f;
                j8.e = -1.0f;
                j8.c = -1.0f;
                j8.f = new int[0];
                j8.b = false;
                return;
            }
            if (i != 1) {
                throw new IllegalArgumentException(AbstractC0126Ew.j(i, "Unknown auto-size text type: "));
            }
            DisplayMetrics displayMetrics = j8.j.getResources().getDisplayMetrics();
            j8.j(TypedValue.applyDimension(2, 12.0f, displayMetrics), TypedValue.applyDimension(2, 112.0f, displayMetrics), 1.0f);
            if (j8.g()) {
                j8.a();
            }
        }
    }

    public final void k(ColorStateList colorStateList) {
        if (this.h == null) {
            this.h = new C1794ll();
        }
        C1794ll c1794ll = this.h;
        c1794ll.c = colorStateList;
        c1794ll.b = colorStateList != null;
        this.b = c1794ll;
        this.c = c1794ll;
        this.d = c1794ll;
        this.e = c1794ll;
        this.f = c1794ll;
        this.g = c1794ll;
    }

    public final void l(PorterDuff.Mode mode) {
        if (this.h == null) {
            this.h = new C1794ll();
        }
        C1794ll c1794ll = this.h;
        c1794ll.d = mode;
        c1794ll.a = mode != null;
        this.b = c1794ll;
        this.c = c1794ll;
        this.d = c1794ll;
        this.e = c1794ll;
        this.f = c1794ll;
        this.g = c1794ll;
    }

    public final void m(Context context, C70 c70) {
        String string;
        int i = this.j;
        TypedArray typedArray = (TypedArray) c70.n;
        this.j = typedArray.getInt(2, i);
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 28) {
            int i3 = typedArray.getInt(11, -1);
            this.k = i3;
            if (i3 != -1) {
                this.j &= 2;
            }
        }
        if (!typedArray.hasValue(10) && !typedArray.hasValue(12)) {
            if (typedArray.hasValue(1)) {
                this.m = false;
                int i4 = typedArray.getInt(1, 1);
                if (i4 == 1) {
                    this.l = Typeface.SANS_SERIF;
                    return;
                } else if (i4 == 2) {
                    this.l = Typeface.SERIF;
                    return;
                } else {
                    if (i4 != 3) {
                        return;
                    }
                    this.l = Typeface.MONOSPACE;
                    return;
                }
            }
            return;
        }
        this.l = null;
        int i5 = typedArray.hasValue(12) ? 12 : 10;
        int i6 = this.k;
        int i7 = this.j;
        if (!context.isRestricted()) {
            try {
                Typeface typefaceO = c70.o(i5, this.j, new C2691v8(this, i6, i7, new WeakReference(this.a)));
                if (typefaceO != null) {
                    if (i2 < 28 || this.k == -1) {
                        this.l = typefaceO;
                    } else {
                        this.l = AbstractC3071z8.a(Typeface.create(typefaceO, 0), this.k, (this.j & 2) != 0);
                    }
                }
                this.m = this.l == null;
            } catch (Resources.NotFoundException | UnsupportedOperationException unused) {
            }
        }
        if (this.l != null || (string = typedArray.getString(i5)) == null) {
            return;
        }
        if (Build.VERSION.SDK_INT < 28 || this.k == -1) {
            this.l = Typeface.create(string, this.j);
        } else {
            this.l = AbstractC3071z8.a(Typeface.create(string, 0), this.k, (this.j & 2) != 0);
        }
    }
}
