package com.google.android.material.button; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.RippleDrawable; import androidx.core.view.n0; import c3.j; import n3.b; import p3.g; import p3.k; import p3.n; import r.c; /* loaded from: classes2.dex */ class a { /* renamed from: s, reason: collision with root package name */ private static final boolean f4380s = true; /* renamed from: a, reason: collision with root package name */ private final MaterialButton f4381a; /* renamed from: b, reason: collision with root package name */ private k f4382b; /* renamed from: c, reason: collision with root package name */ private int f4383c; /* renamed from: d, reason: collision with root package name */ private int f4384d; /* renamed from: e, reason: collision with root package name */ private int f4385e; /* renamed from: f, reason: collision with root package name */ private int f4386f; /* renamed from: g, reason: collision with root package name */ private int f4387g; /* renamed from: h, reason: collision with root package name */ private int f4388h; /* renamed from: i, reason: collision with root package name */ private PorterDuff.Mode f4389i; /* renamed from: j, reason: collision with root package name */ private ColorStateList f4390j; /* renamed from: k, reason: collision with root package name */ private ColorStateList f4391k; /* renamed from: l, reason: collision with root package name */ private ColorStateList f4392l; /* renamed from: m, reason: collision with root package name */ private Drawable f4393m; /* renamed from: n, reason: collision with root package name */ private boolean f4394n = false; /* renamed from: o, reason: collision with root package name */ private boolean f4395o = false; /* renamed from: p, reason: collision with root package name */ private boolean f4396p = false; /* renamed from: q, reason: collision with root package name */ private boolean f4397q; /* renamed from: r, reason: collision with root package name */ private LayerDrawable f4398r; a(MaterialButton materialButton, k kVar) { this.f4381a = materialButton; this.f4382b = kVar; } private void A(k kVar) { if (d() != null) { d().setShapeAppearanceModel(kVar); } if (l() != null) { l().setShapeAppearanceModel(kVar); } if (c() != null) { c().setShapeAppearanceModel(kVar); } } private void C() { g d10 = d(); g l10 = l(); if (d10 != null) { d10.W(this.f4388h, this.f4391k); if (l10 != null) { l10.V(this.f4388h, this.f4394n ? g3.a.c(this.f4381a, c3.a.f3454j) : 0); } } } private InsetDrawable D(Drawable drawable) { return new InsetDrawable(drawable, this.f4383c, this.f4385e, this.f4384d, this.f4386f); } private Drawable a() { g gVar = new g(this.f4382b); gVar.J(this.f4381a.getContext()); c.o(gVar, this.f4390j); PorterDuff.Mode mode = this.f4389i; if (mode != null) { c.p(gVar, mode); } gVar.W(this.f4388h, this.f4391k); g gVar2 = new g(this.f4382b); gVar2.setTint(0); gVar2.V(this.f4388h, this.f4394n ? g3.a.c(this.f4381a, c3.a.f3454j) : 0); if (f4380s) { g gVar3 = new g(this.f4382b); this.f4393m = gVar3; c.n(gVar3, -1); RippleDrawable rippleDrawable = new RippleDrawable(b.a(this.f4392l), D(new LayerDrawable(new Drawable[]{gVar2, gVar})), this.f4393m); this.f4398r = rippleDrawable; return rippleDrawable; } n3.a aVar = new n3.a(this.f4382b); this.f4393m = aVar; c.o(aVar, b.a(this.f4392l)); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{gVar2, gVar, this.f4393m}); this.f4398r = layerDrawable; return D(layerDrawable); } private g e(boolean z10) { LayerDrawable layerDrawable = this.f4398r; if (layerDrawable == null || layerDrawable.getNumberOfLayers() <= 0) { return null; } return f4380s ? (g) ((LayerDrawable) ((InsetDrawable) this.f4398r.getDrawable(0)).getDrawable()).getDrawable(!z10 ? 1 : 0) : (g) this.f4398r.getDrawable(!z10 ? 1 : 0); } private g l() { return e(true); } void B(int i10, int i11) { Drawable drawable = this.f4393m; if (drawable != null) { drawable.setBounds(this.f4383c, this.f4385e, i11 - this.f4384d, i10 - this.f4386f); } } int b() { return this.f4387g; } public n c() { LayerDrawable layerDrawable = this.f4398r; if (layerDrawable == null || layerDrawable.getNumberOfLayers() <= 1) { return null; } return this.f4398r.getNumberOfLayers() > 2 ? (n) this.f4398r.getDrawable(2) : (n) this.f4398r.getDrawable(1); } g d() { return e(false); } ColorStateList f() { return this.f4392l; } k g() { return this.f4382b; } ColorStateList h() { return this.f4391k; } int i() { return this.f4388h; } ColorStateList j() { return this.f4390j; } PorterDuff.Mode k() { return this.f4389i; } boolean m() { return this.f4395o; } boolean n() { return this.f4397q; } void o(TypedArray typedArray) { this.f4383c = typedArray.getDimensionPixelOffset(j.f3613i1, 0); this.f4384d = typedArray.getDimensionPixelOffset(j.f3619j1, 0); this.f4385e = typedArray.getDimensionPixelOffset(j.f3625k1, 0); this.f4386f = typedArray.getDimensionPixelOffset(j.f3631l1, 0); int i10 = j.f3655p1; if (typedArray.hasValue(i10)) { int dimensionPixelSize = typedArray.getDimensionPixelSize(i10, -1); this.f4387g = dimensionPixelSize; u(this.f4382b.w(dimensionPixelSize)); this.f4396p = true; } this.f4388h = typedArray.getDimensionPixelSize(j.f3707z1, 0); this.f4389i = com.google.android.material.internal.g.c(typedArray.getInt(j.f3649o1, -1), PorterDuff.Mode.SRC_IN); this.f4390j = m3.c.a(this.f4381a.getContext(), typedArray, j.f3643n1); this.f4391k = m3.c.a(this.f4381a.getContext(), typedArray, j.f3702y1); this.f4392l = m3.c.a(this.f4381a.getContext(), typedArray, j.f3697x1); this.f4397q = typedArray.getBoolean(j.f3637m1, false); int dimensionPixelSize2 = typedArray.getDimensionPixelSize(j.f3661q1, 0); int G = n0.G(this.f4381a); int paddingTop = this.f4381a.getPaddingTop(); int F = n0.F(this.f4381a); int paddingBottom = this.f4381a.getPaddingBottom(); this.f4381a.setInternalBackground(a()); g d10 = d(); if (d10 != null) { d10.Q(dimensionPixelSize2); } n0.z0(this.f4381a, G + this.f4383c, paddingTop + this.f4385e, F + this.f4384d, paddingBottom + this.f4386f); } void p(int i10) { if (d() != null) { d().setTint(i10); } } void q() { this.f4395o = true; this.f4381a.setSupportBackgroundTintList(this.f4390j); this.f4381a.setSupportBackgroundTintMode(this.f4389i); } void r(boolean z10) { this.f4397q = z10; } void s(int i10) { if (this.f4396p && this.f4387g == i10) { return; } this.f4387g = i10; this.f4396p = true; u(this.f4382b.w(i10)); } void t(ColorStateList colorStateList) { if (this.f4392l != colorStateList) { this.f4392l = colorStateList; boolean z10 = f4380s; if (z10 && (this.f4381a.getBackground() instanceof RippleDrawable)) { ((RippleDrawable) this.f4381a.getBackground()).setColor(b.a(colorStateList)); } else { if (z10 || !(this.f4381a.getBackground() instanceof n3.a)) { return; } ((n3.a) this.f4381a.getBackground()).setTintList(b.a(colorStateList)); } } } void u(k kVar) { this.f4382b = kVar; A(kVar); } void v(boolean z10) { this.f4394n = z10; C(); } void w(ColorStateList colorStateList) { if (this.f4391k != colorStateList) { this.f4391k = colorStateList; C(); } } void x(int i10) { if (this.f4388h != i10) { this.f4388h = i10; C(); } } void y(ColorStateList colorStateList) { if (this.f4390j != colorStateList) { this.f4390j = colorStateList; if (d() != null) { c.o(d(), this.f4390j); } } } void z(PorterDuff.Mode mode) { if (this.f4389i != mode) { this.f4389i = mode; if (d() == null || this.f4389i == null) { return; } c.p(d(), this.f4389i); } } }