package p9;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import com.google.android.material.internal.q0;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f31786a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f31787b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public float f31788c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f31789d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int[] f31790e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f31791f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f31792g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f31793h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f31794i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f31795j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f31796k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f31797l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f31798m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public float f31799n;

    public d(@NonNull Context context, @Nullable AttributeSet attributeSet, @AttrRes int i10, @StyleRes int i11) {
        this.f31790e = new int[0];
        int dimensionPixelSize = context.getResources().getDimensionPixelSize(x8.e.mtrl_progress_track_thickness);
        TypedArray typedArrayC = q0.c(context, attributeSet, x8.m.BaseProgressIndicator, i10, i11, new int[0]);
        this.f31786a = q9.d.a(context, typedArrayC, x8.m.BaseProgressIndicator_trackThickness, dimensionPixelSize);
        TypedValue typedValuePeekValue = typedArrayC.peekValue(x8.m.BaseProgressIndicator_trackCornerRadius);
        if (typedValuePeekValue != null) {
            int i12 = typedValuePeekValue.type;
            if (i12 == 5) {
                this.f31787b = Math.min(TypedValue.complexToDimensionPixelSize(typedValuePeekValue.data, typedArrayC.getResources().getDisplayMetrics()), this.f31786a / 2);
                this.f31789d = false;
            } else if (i12 == 6) {
                this.f31788c = Math.min(typedValuePeekValue.getFraction(1.0f, 1.0f), 0.5f);
                this.f31789d = true;
            }
        }
        this.f31792g = typedArrayC.getInt(x8.m.BaseProgressIndicator_showAnimationBehavior, 0);
        this.f31793h = typedArrayC.getInt(x8.m.BaseProgressIndicator_hideAnimationBehavior, 0);
        this.f31794i = typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_indicatorTrackGapSize, 0);
        int iAbs = Math.abs(typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_wavelength, 0));
        this.f31795j = Math.abs(typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_wavelengthDeterminate, iAbs));
        this.f31796k = Math.abs(typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_wavelengthIndeterminate, iAbs));
        this.f31797l = Math.abs(typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_waveAmplitude, 0));
        this.f31798m = typedArrayC.getDimensionPixelSize(x8.m.BaseProgressIndicator_waveSpeed, 0);
        this.f31799n = typedArrayC.getFloat(x8.m.BaseProgressIndicator_indeterminateAnimatorDurationScale, 1.0f);
        int i13 = x8.m.BaseProgressIndicator_indicatorColor;
        if (!typedArrayC.hasValue(i13)) {
            this.f31790e = new int[]{h9.a.c(context, d.a.colorPrimary, -1)};
        } else if (typedArrayC.peekValue(i13).type != 1) {
            this.f31790e = new int[]{typedArrayC.getColor(i13, -1)};
        } else {
            int[] intArray = context.getResources().getIntArray(typedArrayC.getResourceId(i13, -1));
            this.f31790e = intArray;
            if (intArray.length == 0) {
                throw new IllegalArgumentException("indicatorColors cannot be empty when indicatorColor is not used.");
            }
        }
        int i14 = x8.m.BaseProgressIndicator_trackColor;
        if (typedArrayC.hasValue(i14)) {
            this.f31791f = typedArrayC.getColor(i14, -1);
        } else {
            this.f31791f = this.f31790e[0];
            TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.disabledAlpha});
            float f10 = typedArrayObtainStyledAttributes.getFloat(0, 0.2f);
            typedArrayObtainStyledAttributes.recycle();
            this.f31791f = h9.a.a(this.f31791f, (int) (f10 * 255.0f));
        }
        typedArrayC.recycle();
    }

    public final int a() {
        return this.f31789d ? (int) (this.f31786a * this.f31788c) : this.f31787b;
    }

    public final boolean b(boolean z10) {
        return this.f31797l > 0 && ((!z10 && this.f31796k > 0) || (z10 && this.f31795j > 0));
    }

    public boolean c() {
        return this.f31789d && this.f31788c == 0.5f;
    }

    public void d() {
        if (this.f31794i < 0) {
            throw new IllegalArgumentException("indicatorTrackGapSize must be >= 0.");
        }
    }
}
