package com.google.android.material.shape;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;

/* JADX INFO: loaded from: classes2.dex */
public class s {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final o f23150m = new o(0.5f);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public com.bumptech.glide.h f23151a = new p();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public com.bumptech.glide.h f23152b = new p();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public com.bumptech.glide.h f23153c = new p();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public com.bumptech.glide.h f23154d = new p();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public d f23155e = new a(0.0f);

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public d f23156f = new a(0.0f);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public d f23157g = new a(0.0f);

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public d f23158h = new a(0.0f);

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public f f23159i = new f();

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public f f23160j = new f();

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public f f23161k = new f();

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public f f23162l = new f();

    public static q a(Context context, int i10, int i11) {
        return b(context, i10, i11, new a(0));
    }

    public static q b(Context context, int i10, int i11, d dVar) {
        ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, i10);
        if (i11 != 0) {
            contextThemeWrapper.getTheme().applyStyle(i11, true);
        }
        TypedArray typedArrayObtainStyledAttributes = contextThemeWrapper.obtainStyledAttributes(x8.m.ShapeAppearance);
        try {
            int i12 = typedArrayObtainStyledAttributes.getInt(x8.m.ShapeAppearance_cornerFamily, 0);
            int i13 = typedArrayObtainStyledAttributes.getInt(x8.m.ShapeAppearance_cornerFamilyTopLeft, i12);
            int i14 = typedArrayObtainStyledAttributes.getInt(x8.m.ShapeAppearance_cornerFamilyTopRight, i12);
            int i15 = typedArrayObtainStyledAttributes.getInt(x8.m.ShapeAppearance_cornerFamilyBottomRight, i12);
            int i16 = typedArrayObtainStyledAttributes.getInt(x8.m.ShapeAppearance_cornerFamilyBottomLeft, i12);
            d dVarE = e(typedArrayObtainStyledAttributes, x8.m.ShapeAppearance_cornerSize, dVar);
            d dVarE2 = e(typedArrayObtainStyledAttributes, x8.m.ShapeAppearance_cornerSizeTopLeft, dVarE);
            d dVarE3 = e(typedArrayObtainStyledAttributes, x8.m.ShapeAppearance_cornerSizeTopRight, dVarE);
            d dVarE4 = e(typedArrayObtainStyledAttributes, x8.m.ShapeAppearance_cornerSizeBottomRight, dVarE);
            d dVarE5 = e(typedArrayObtainStyledAttributes, x8.m.ShapeAppearance_cornerSizeBottomLeft, dVarE);
            q qVar = new q();
            com.bumptech.glide.h hVarB = com.bumptech.glide.f.b(i13);
            qVar.f23134a = hVarB;
            q.b(hVarB);
            qVar.f23138e = dVarE2;
            com.bumptech.glide.h hVarB2 = com.bumptech.glide.f.b(i14);
            qVar.f23135b = hVarB2;
            q.b(hVarB2);
            qVar.f23139f = dVarE3;
            com.bumptech.glide.h hVarB3 = com.bumptech.glide.f.b(i15);
            qVar.f23136c = hVarB3;
            q.b(hVarB3);
            qVar.f23140g = dVarE4;
            com.bumptech.glide.h hVarB4 = com.bumptech.glide.f.b(i16);
            qVar.f23137d = hVarB4;
            q.b(hVarB4);
            qVar.f23141h = dVarE5;
            return qVar;
        } finally {
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    public static q c(Context context, AttributeSet attributeSet, int i10, int i11) {
        return d(context, attributeSet, i10, i11, new a(0));
    }

    public static q d(Context context, AttributeSet attributeSet, int i10, int i11, d dVar) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, x8.m.MaterialShape, i10, i11);
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(x8.m.MaterialShape_shapeAppearance, 0);
        int resourceId2 = typedArrayObtainStyledAttributes.getResourceId(x8.m.MaterialShape_shapeAppearanceOverlay, 0);
        typedArrayObtainStyledAttributes.recycle();
        return b(context, resourceId, resourceId2, dVar);
    }

    public static d e(TypedArray typedArray, int i10, d dVar) {
        TypedValue typedValuePeekValue = typedArray.peekValue(i10);
        if (typedValuePeekValue == null) {
            return dVar;
        }
        int i11 = typedValuePeekValue.type;
        return i11 == 5 ? new a(TypedValue.complexToDimensionPixelSize(typedValuePeekValue.data, typedArray.getResources().getDisplayMetrics())) : i11 == 6 ? new o(typedValuePeekValue.getFraction(1.0f, 1.0f)) : dVar;
    }

    public final boolean f() {
        return (this.f23152b instanceof p) && (this.f23151a instanceof p) && (this.f23153c instanceof p) && (this.f23154d instanceof p);
    }

    public final boolean g(RectF rectF) {
        boolean z10 = this.f23162l.getClass().equals(f.class) && this.f23160j.getClass().equals(f.class) && this.f23159i.getClass().equals(f.class) && this.f23161k.getClass().equals(f.class);
        float fA = this.f23155e.a(rectF);
        return z10 && ((this.f23156f.a(rectF) > fA ? 1 : (this.f23156f.a(rectF) == fA ? 0 : -1)) == 0 && (this.f23158h.a(rectF) > fA ? 1 : (this.f23158h.a(rectF) == fA ? 0 : -1)) == 0 && (this.f23157g.a(rectF) > fA ? 1 : (this.f23157g.a(rectF) == fA ? 0 : -1)) == 0) && f();
    }

    public final q h() {
        q qVar = new q();
        qVar.f23134a = this.f23151a;
        qVar.f23135b = this.f23152b;
        qVar.f23136c = this.f23153c;
        qVar.f23137d = this.f23154d;
        qVar.f23138e = this.f23155e;
        qVar.f23139f = this.f23156f;
        qVar.f23140g = this.f23157g;
        qVar.f23141h = this.f23158h;
        qVar.f23142i = this.f23159i;
        qVar.f23143j = this.f23160j;
        qVar.f23144k = this.f23161k;
        qVar.f23145l = this.f23162l;
        return qVar;
    }

    public final s i(r rVar) {
        q qVarH = h();
        qVarH.f23138e = rVar.b(this.f23155e);
        qVarH.f23139f = rVar.b(this.f23156f);
        qVarH.f23141h = rVar.b(this.f23158h);
        qVarH.f23140g = rVar.b(this.f23157g);
        return qVarH.a();
    }

    public final String toString() {
        return "[" + this.f23155e + ", " + this.f23156f + ", " + this.f23157g + ", " + this.f23158h + "]";
    }
}
