package X6FRs_4.KQgRr5e_0.LGe8pk_15;

import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ScaleDrawable;
import android.os.Build;
import android.util.Log;
import com.google.android.material.internal.DrawableUtils;
import java.lang.reflect.Field;
/* compiled from: DrawableUtils.java */
/* loaded from: classes.dex */
public class YghfZG_14 {
    public static final Rect KQgRr5e_0 = new Rect();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static Class<?> f785KQgRr5e_0;

    static {
        if (Build.VERSION.SDK_INT >= 18) {
            try {
                f785KQgRr5e_0 = Class.forName("android.graphics.Insets");
            } catch (ClassNotFoundException unused) {
            }
        }
    }

    public static Rect KQgRr5e_0(Drawable drawable) {
        Field[] fields;
        if (f785KQgRr5e_0 != null) {
            try {
                Drawable m291KQgRr5e_0 = X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.KQgRr5e_0.m291KQgRr5e_0(drawable);
                Object invoke = m291KQgRr5e_0.getClass().getMethod("getOpticalInsets", new Class[0]).invoke(m291KQgRr5e_0, new Object[0]);
                if (invoke != null) {
                    Rect rect = new Rect();
                    for (Field field : f785KQgRr5e_0.getFields()) {
                        String name = field.getName();
                        char c = 65535;
                        switch (name.hashCode()) {
                            case -1383228885:
                                if (name.equals("bottom")) {
                                    c = 3;
                                    break;
                                }
                                break;
                            case 115029:
                                if (name.equals("top")) {
                                    c = 1;
                                    break;
                                }
                                break;
                            case 3317767:
                                if (name.equals("left")) {
                                    c = 0;
                                    break;
                                }
                                break;
                            case 108511772:
                                if (name.equals("right")) {
                                    c = 2;
                                    break;
                                }
                                break;
                        }
                        if (c == 0) {
                            rect.left = field.getInt(invoke);
                        } else if (c == 1) {
                            rect.top = field.getInt(invoke);
                        } else if (c == 2) {
                            rect.right = field.getInt(invoke);
                        } else if (c == 3) {
                            rect.bottom = field.getInt(invoke);
                        }
                    }
                    return rect;
                }
            } catch (Exception unused) {
                Log.e(DrawableUtils.LOG_TAG, "Couldn't obtain the optical insets. Ignoring.");
            }
        }
        return KQgRr5e_0;
    }

    public static void QxJ9d_1(Drawable drawable) {
        int[] state = drawable.getState();
        if (state != null && state.length != 0) {
            drawable.setState(G83uNX_24.f3157X6FRs_4);
        } else {
            drawable.setState(G83uNX_24.f3156Mqv2r_3);
        }
        drawable.setState(state);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static void m446KQgRr5e_0(Drawable drawable) {
        if (Build.VERSION.SDK_INT == 21 && "android.graphics.drawable.VectorDrawable".equals(drawable.getClass().getName())) {
            QxJ9d_1(drawable);
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m447KQgRr5e_0(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 15 || !(drawable instanceof InsetDrawable)) {
            if (Build.VERSION.SDK_INT >= 15 || !(drawable instanceof GradientDrawable)) {
                if (Build.VERSION.SDK_INT >= 17 || !(drawable instanceof LayerDrawable)) {
                    if (drawable instanceof DrawableContainer) {
                        Drawable.ConstantState constantState = drawable.getConstantState();
                        if (constantState instanceof DrawableContainer.DrawableContainerState) {
                            for (Drawable drawable2 : ((DrawableContainer.DrawableContainerState) constantState).getChildren()) {
                                if (!m447KQgRr5e_0(drawable2)) {
                                    return false;
                                }
                            }
                            return true;
                        }
                        return true;
                    } else if (drawable instanceof X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.PGPF6hQ_2) {
                        return m447KQgRr5e_0(((X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.PGPF6hQ_2) drawable).KQgRr5e_0());
                    } else {
                        if (drawable instanceof X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2) {
                            return m447KQgRr5e_0(((X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2) drawable).getWrappedDrawable());
                        }
                        if (drawable instanceof ScaleDrawable) {
                            return m447KQgRr5e_0(((ScaleDrawable) drawable).getDrawable());
                        }
                        return true;
                    }
                }
                return false;
            }
            return false;
        }
        return false;
    }

    public static PorterDuff.Mode KQgRr5e_0(int i, PorterDuff.Mode mode) {
        if (i != 3) {
            if (i != 5) {
                if (i != 9) {
                    switch (i) {
                        case 14:
                            return PorterDuff.Mode.MULTIPLY;
                        case 15:
                            return PorterDuff.Mode.SCREEN;
                        case 16:
                            return PorterDuff.Mode.ADD;
                        default:
                            return mode;
                    }
                }
                return PorterDuff.Mode.SRC_ATOP;
            }
            return PorterDuff.Mode.SRC_IN;
        }
        return PorterDuff.Mode.SRC_OVER;
    }
}
