package com.google.android.material.datepicker;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.RippleDrawable;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Rect f22471a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final ColorStateList f22472b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ColorStateList f22473c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final ColorStateList f22474d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f22475e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final com.google.android.material.shape.s f22476f;

    public d(ColorStateList colorStateList, ColorStateList colorStateList2, ColorStateList colorStateList3, int i10, com.google.android.material.shape.s sVar, Rect rect) {
        p0.g.c(rect.left);
        p0.g.c(rect.top);
        p0.g.c(rect.right);
        p0.g.c(rect.bottom);
        this.f22471a = rect;
        this.f22472b = colorStateList2;
        this.f22473c = colorStateList;
        this.f22474d = colorStateList3;
        this.f22475e = i10;
        this.f22476f = sVar;
    }

    public static d a(Context context, int i10) {
        p0.g.a(i10 != 0, "Cannot create a CalendarItemStyle with a styleResId of 0");
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(i10, x8.m.MaterialCalendarItem);
        Rect rect = new Rect(typedArrayObtainStyledAttributes.getDimensionPixelOffset(x8.m.MaterialCalendarItem_android_insetLeft, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(x8.m.MaterialCalendarItem_android_insetTop, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(x8.m.MaterialCalendarItem_android_insetRight, 0), typedArrayObtainStyledAttributes.getDimensionPixelOffset(x8.m.MaterialCalendarItem_android_insetBottom, 0));
        ColorStateList colorStateList = q9.d.getColorStateList(context, typedArrayObtainStyledAttributes, x8.m.MaterialCalendarItem_itemFillColor);
        ColorStateList colorStateList2 = q9.d.getColorStateList(context, typedArrayObtainStyledAttributes, x8.m.MaterialCalendarItem_itemTextColor);
        ColorStateList colorStateList3 = q9.d.getColorStateList(context, typedArrayObtainStyledAttributes, x8.m.MaterialCalendarItem_itemStrokeColor);
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(x8.m.MaterialCalendarItem_itemStrokeWidth, 0);
        com.google.android.material.shape.s sVarA = com.google.android.material.shape.s.a(context, typedArrayObtainStyledAttributes.getResourceId(x8.m.MaterialCalendarItem_itemShapeAppearance, 0), typedArrayObtainStyledAttributes.getResourceId(x8.m.MaterialCalendarItem_itemShapeAppearanceOverlay, 0)).a();
        typedArrayObtainStyledAttributes.recycle();
        return new d(colorStateList, colorStateList2, colorStateList3, dimensionPixelSize, sVarA, rect);
    }

    public void styleItem(@NonNull TextView textView, @Nullable ColorStateList colorStateList, @Nullable ColorStateList colorStateList2) {
        com.google.android.material.shape.k kVar = new com.google.android.material.shape.k();
        com.google.android.material.shape.k kVar2 = new com.google.android.material.shape.k();
        com.google.android.material.shape.s sVar = this.f22476f;
        kVar.setShapeAppearanceModel(sVar);
        kVar2.setShapeAppearanceModel(sVar);
        if (colorStateList == null) {
            colorStateList = this.f22473c;
        }
        kVar.setFillColor(colorStateList);
        kVar.setStroke(this.f22475e, this.f22474d);
        ColorStateList colorStateList3 = this.f22472b;
        if (colorStateList2 == null) {
            colorStateList2 = colorStateList3;
        }
        textView.setTextColor(colorStateList2);
        RippleDrawable rippleDrawable = new RippleDrawable(colorStateList3.withAlpha(30), kVar, kVar2);
        Rect rect = this.f22471a;
        textView.setBackground(new InsetDrawable((Drawable) rippleDrawable, rect.left, rect.top, rect.right, rect.bottom));
    }
}
