package com.google.android.material.textfield;

import a3.g0;
import android.R;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.os.Parcelable;
import android.text.Editable;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStructure;
import android.view.ViewTreeObserver;
import android.view.animation.LinearInterpolator;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.s1;
import com.google.android.gms.common.api.internal.i0;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.internal.k0;
import com.google.android.material.internal.q0;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Iterator;
import java.util.LinkedHashSet;
import l.c0;
import l.p1;
import l.p3;
import r3.d0;

/* JADX INFO: loaded from: classes2.dex */
public class TextInputLayout extends LinearLayout implements ViewTreeObserver.OnGlobalLayoutListener {
    public static final int T0 = x8.l.Widget_Design_TextInputLayout;
    public static final int[][] U0 = {new int[]{R.attr.state_pressed}, new int[0]};
    public ColorStateList A0;
    public int B0;
    public int C0;
    public int D0;
    public ColorStateList E0;
    public int F0;
    public int G0;
    public int H0;
    public int I0;
    public int J0;
    public int K0;
    public boolean L0;
    public final com.google.android.material.internal.e M0;
    public boolean N0;
    public boolean O0;
    public ValueAnimator P0;
    public boolean Q;
    public boolean Q0;
    public z R;
    public boolean R0;
    public int S;
    public boolean S0;
    public int T;
    public CharSequence U;
    public boolean V;
    public AppCompatTextView W;

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

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

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

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

    @Nullable
    private com.google.android.material.shape.k boxBackground;

    @Nullable
    private com.google.android.material.shape.k boxUnderlineDefault;

    @Nullable
    private com.google.android.material.shape.k boxUnderlineFocused;

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

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public CharSequence f23357c0;

    @Nullable
    private ColorStateList counterOverflowTextColor;

    @Nullable
    private ColorStateList counterTextColor;

    @Nullable
    private TextView counterView;

    @Nullable
    private ColorStateList cursorColor;

    @Nullable
    private ColorStateList cursorErrorColor;

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public EditText f23360e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public com.google.android.material.shape.k f23361e0;

    @Nullable
    private Drawable endDummyDrawable;

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

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public StateListDrawable f23363f0;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final s f23372k;

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

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

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

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

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

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

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

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

    @Nullable
    private r3.g placeholderFadeIn;

    @Nullable
    private r3.g placeholderFadeOut;

    @Nullable
    private ColorStateList placeholderTextColor;

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

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

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

    @Nullable
    private Drawable startDummyDrawable;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public final RectF f23384t0;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public Typeface f23385u0;

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

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public final LinkedHashSet f23387w0;

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

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public Drawable f23389y0;
    public ColorStateList z0;

    @Retention(RetentionPolicy.SOURCE)
    public @interface BoxBackgroundMode {
    }

    @Retention(RetentionPolicy.SOURCE)
    @RestrictTo({RestrictTo.Scope.f556b})
    public @interface EndIconMode {
    }

    public TextInputLayout(@NonNull Context context) {
        this(context, null);
    }

    @Nullable
    private Drawable getEditTextBoxBackground() {
        int color;
        EditText editText = this.f23360e;
        if (!(editText instanceof AutoCompleteTextView) || editText.getInputType() != 0) {
            return this.boxBackground;
        }
        int iB = h9.a.b(d.a.colorControlHighlight, this.f23360e);
        int i10 = this.f23373k0;
        int[][] iArr = U0;
        if (i10 != 2) {
            if (i10 != 1) {
                return null;
            }
            com.google.android.material.shape.k kVar = this.boxBackground;
            int i11 = this.f23381q0;
            return new RippleDrawable(new ColorStateList(iArr, new int[]{h9.a.e(0.1f, iB, i11), i11}), kVar, kVar);
        }
        Context context = getContext();
        com.google.android.material.shape.k kVar2 = this.boxBackground;
        TypedValue typedValueC = q9.c.c(context, x8.c.colorSurface, "TextInputLayout");
        int i12 = typedValueC.resourceId;
        if (i12 != 0) {
            Object obj = g0.d.f26125a;
            color = context.getColor(i12);
        } else {
            color = typedValueC.data;
        }
        com.google.android.material.shape.k kVar3 = new com.google.android.material.shape.k(kVar2.f23095b.f23068a);
        int iE = h9.a.e(0.1f, iB, color);
        kVar3.setFillColor(new ColorStateList(iArr, new int[]{iE, 0}));
        kVar3.setTint(color);
        ColorStateList colorStateList = new ColorStateList(iArr, new int[]{iE, color});
        com.google.android.material.shape.k kVar4 = new com.google.android.material.shape.k(kVar2.f23095b.f23068a);
        kVar4.setTint(-1);
        return new LayerDrawable(new Drawable[]{new RippleDrawable(colorStateList, kVar3, kVar4), kVar2});
    }

    private Drawable getOrCreateFilledDropDownMenuBackground() {
        if (this.f23363f0 == null) {
            StateListDrawable stateListDrawable = new StateListDrawable();
            this.f23363f0 = stateListDrawable;
            stateListDrawable.addState(new int[]{R.attr.state_above_anchor}, getOrCreateOutlinedDropDownMenuBackground());
            this.f23363f0.addState(new int[0], i(false));
        }
        return this.f23363f0;
    }

    private Drawable getOrCreateOutlinedDropDownMenuBackground() {
        if (this.f23361e0 == null) {
            this.f23361e0 = i(true);
        }
        return this.f23361e0;
    }

    public static void n(ViewGroup viewGroup, boolean z10) {
        int childCount = viewGroup.getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = viewGroup.getChildAt(i10);
            childAt.setEnabled(z10);
            if (childAt instanceof ViewGroup) {
                n((ViewGroup) childAt, z10);
            }
        }
    }

    private void setEditText(EditText editText) {
        if (this.f23360e != null) {
            throw new IllegalArgumentException("We already have an EditText, can only have one");
        }
        if (getEndIconMode() != 3) {
            boolean z10 = editText instanceof TextInputEditText;
        }
        this.f23360e = editText;
        int i10 = this.f23364g;
        if (i10 != -1) {
            setMinEms(i10);
        } else {
            setMinWidth(this.f23368i);
        }
        int i11 = this.f23366h;
        if (i11 != -1) {
            setMaxEms(i11);
        } else {
            setMaxWidth(this.f23370j);
        }
        this.f23365g0 = false;
        l();
        setTextInputAccessibilityDelegate(new y(this));
        Typeface typeface = this.f23360e.getTypeface();
        com.google.android.material.internal.e eVar = this.M0;
        boolean zS = eVar.s(typeface);
        boolean zY = eVar.y(typeface);
        if (zS || zY) {
            eVar.l(false);
        }
        eVar.x(this.f23360e.getTextSize());
        float letterSpacing = this.f23360e.getLetterSpacing();
        if (eVar.f22727e0 != letterSpacing) {
            eVar.f22727e0 = letterSpacing;
            eVar.l(false);
        }
        int gravity = this.f23360e.getGravity();
        eVar.r((gravity & (-113)) | 48);
        eVar.w(gravity);
        this.K0 = editText.getMinimumHeight();
        this.f23360e.addTextChangedListener(new x(this, editText));
        if (this.z0 == null) {
            this.z0 = this.f23360e.getHintTextColors();
        }
        if (this.f23355b0) {
            if (TextUtils.isEmpty(this.f23357c0)) {
                CharSequence hint = this.f23360e.getHint();
                this.f23362f = hint;
                setHint(hint);
                this.f23360e.setHint((CharSequence) null);
            }
            this.f23359d0 = true;
        }
        if (Build.VERSION.SDK_INT >= 29) {
            q();
        }
        if (this.counterView != null) {
            updateCounter(this.f23360e.getText());
        }
        s();
        this.f23372k.d();
        this.f23354b.bringToFront();
        o oVar = this.f23356c;
        oVar.bringToFront();
        Iterator it = this.f23387w0.iterator();
        while (it.hasNext()) {
            ((n) it.next()).a(this);
        }
        oVar.n();
        if (!isEnabled()) {
            editText.setEnabled(false);
        }
        v(false, true);
    }

    private void setHintInternal(CharSequence charSequence) {
        if (TextUtils.equals(charSequence, this.f23357c0)) {
            return;
        }
        this.f23357c0 = charSequence;
        this.M0.setText(charSequence);
        if (this.L0) {
            return;
        }
        m();
    }

    private void setPlaceholderTextEnabled(boolean z10) {
        if (this.V == z10) {
            return;
        }
        if (z10) {
            AppCompatTextView appCompatTextView = this.W;
            if (appCompatTextView != null) {
                this.f23352a.addView(appCompatTextView);
                this.W.setVisibility(0);
            }
        } else {
            AppCompatTextView appCompatTextView2 = this.W;
            if (appCompatTextView2 != null) {
                appCompatTextView2.setVisibility(8);
            }
            this.W = null;
        }
        this.V = z10;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void updatePlaceholderText(@Nullable Editable editable) {
        int iCountLength = ((c7.g) this.R).countLength(editable);
        FrameLayout frameLayout = this.f23352a;
        if (iCountLength != 0 || this.L0) {
            AppCompatTextView appCompatTextView = this.W;
            if (appCompatTextView == null || !this.V) {
                return;
            }
            appCompatTextView.setText((CharSequence) null);
            d0.beginDelayedTransition(frameLayout, this.placeholderFadeOut);
            this.W.setVisibility(4);
            return;
        }
        if (this.W == null || !this.V || TextUtils.isEmpty(this.U)) {
            return;
        }
        this.W.setText(this.U);
        d0.beginDelayedTransition(frameLayout, this.placeholderFadeIn);
        this.W.setVisibility(0);
        this.W.bringToFront();
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        if (!(view instanceof EditText)) {
            super.addView(view, i10, layoutParams);
            return;
        }
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(layoutParams);
        layoutParams2.gravity = (layoutParams2.gravity & (-113)) | 16;
        FrameLayout frameLayout = this.f23352a;
        frameLayout.addView(view, layoutParams2);
        frameLayout.setLayoutParams(layoutParams);
        u();
        setEditText((EditText) view);
    }

    public final void b() {
        if (this.f23360e == null || this.f23373k0 != 1) {
            return;
        }
        if (getHintMaxLines() != 1) {
            EditText editText = this.f23360e;
            editText.setPaddingRelative(editText.getPaddingStart(), (int) (this.M0.h() + this.f23358d), this.f23360e.getPaddingEnd(), getResources().getDimensionPixelSize(x8.e.material_filled_edittext_font_1_3_padding_bottom));
        } else if (getContext().getResources().getConfiguration().fontScale >= 2.0f) {
            EditText editText2 = this.f23360e;
            editText2.setPaddingRelative(editText2.getPaddingStart(), getResources().getDimensionPixelSize(x8.e.material_filled_edittext_font_2_0_padding_top), this.f23360e.getPaddingEnd(), getResources().getDimensionPixelSize(x8.e.material_filled_edittext_font_2_0_padding_bottom));
        } else if (q9.d.c(getContext())) {
            EditText editText3 = this.f23360e;
            editText3.setPaddingRelative(editText3.getPaddingStart(), getResources().getDimensionPixelSize(x8.e.material_filled_edittext_font_1_3_padding_top), this.f23360e.getPaddingEnd(), getResources().getDimensionPixelSize(x8.e.material_filled_edittext_font_1_3_padding_bottom));
        }
    }

    public final void c(float f10) {
        com.google.android.material.internal.e eVar = this.M0;
        if (eVar.f22720b == f10) {
            return;
        }
        int i10 = 2;
        if (this.P0 == null) {
            ValueAnimator valueAnimator = new ValueAnimator();
            this.P0 = valueAnimator;
            valueAnimator.setInterpolator(com.bumptech.glide.f.p(getContext(), x8.c.motionEasingEmphasizedInterpolator, y8.a.f36865b));
            this.P0.setDuration(com.bumptech.glide.f.o(getContext(), x8.c.motionDurationMedium4, 167));
            this.P0.addUpdateListener(new r6.d(this, i10));
        }
        this.P0.setFloatValues(eVar.f22720b, f10);
        this.P0.start();
    }

    public final void d() {
        int i10;
        int i11;
        com.google.android.material.shape.k kVar = this.boxBackground;
        if (kVar == null) {
            return;
        }
        com.google.android.material.shape.s sVar = kVar.f23095b.f23068a;
        com.google.android.material.shape.s sVar2 = this.f23367h0;
        if (sVar != sVar2) {
            kVar.setShapeAppearanceModel(sVar2);
        }
        if (this.f23373k0 == 2 && (i10 = this.f23377m0) > -1 && (i11 = this.f23380p0) != 0) {
            com.google.android.material.shape.k kVar2 = this.boxBackground;
            kVar2.D(i10);
            kVar2.setStrokeColor(ColorStateList.valueOf(i11));
        }
        int iC = this.f23381q0;
        if (this.f23373k0 == 1) {
            iC = j0.c.c(this.f23381q0, h9.a.c(getContext(), x8.c.colorSurface, 0));
        }
        this.f23381q0 = iC;
        this.boxBackground.setFillColor(ColorStateList.valueOf(iC));
        com.google.android.material.shape.k kVar3 = this.boxUnderlineDefault;
        if (kVar3 != null && this.boxUnderlineFocused != null) {
            if (this.f23377m0 > -1 && this.f23380p0 != 0) {
                kVar3.setFillColor(this.f23360e.isFocused() ? ColorStateList.valueOf(this.B0) : ColorStateList.valueOf(this.f23380p0));
                this.boxUnderlineFocused.setFillColor(ColorStateList.valueOf(this.f23380p0));
            }
            invalidate();
        }
        t();
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void dispatchProvideAutofillStructure(ViewStructure viewStructure, int i10) {
        EditText editText = this.f23360e;
        if (editText == null) {
            super.dispatchProvideAutofillStructure(viewStructure, i10);
            return;
        }
        if (this.f23362f != null) {
            boolean z10 = this.f23359d0;
            this.f23359d0 = false;
            CharSequence hint = editText.getHint();
            this.f23360e.setHint(this.f23362f);
            try {
                super.dispatchProvideAutofillStructure(viewStructure, i10);
                return;
            } finally {
                this.f23360e.setHint(hint);
                this.f23359d0 = z10;
            }
        }
        viewStructure.setAutofillId(getAutofillId());
        onProvideAutofillStructure(viewStructure, i10);
        onProvideAutofillVirtualStructure(viewStructure, i10);
        FrameLayout frameLayout = this.f23352a;
        viewStructure.setChildCount(frameLayout.getChildCount());
        for (int i11 = 0; i11 < frameLayout.getChildCount(); i11++) {
            View childAt = frameLayout.getChildAt(i11);
            ViewStructure viewStructureNewChild = viewStructure.newChild(i11);
            childAt.dispatchProvideAutofillStructure(viewStructureNewChild, i10);
            if (childAt == this.f23360e) {
                viewStructureNewChild.setHint(getHint());
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void dispatchRestoreInstanceState(SparseArray sparseArray) {
        this.R0 = true;
        super.dispatchRestoreInstanceState(sparseArray);
        this.R0 = false;
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        com.google.android.material.shape.k kVar;
        super.draw(canvas);
        boolean z10 = this.f23355b0;
        com.google.android.material.internal.e eVar = this.M0;
        if (z10) {
            eVar.f(canvas);
        }
        if (this.boxUnderlineFocused == null || (kVar = this.boxUnderlineDefault) == null) {
            return;
        }
        kVar.draw(canvas);
        if (this.f23360e.isFocused()) {
            Rect bounds = this.boxUnderlineFocused.getBounds();
            Rect bounds2 = this.boxUnderlineDefault.getBounds();
            float f10 = eVar.f22720b;
            int iCenterX = bounds2.centerX();
            bounds.left = y8.a.c(f10, iCenterX, bounds2.left);
            bounds.right = y8.a.c(f10, iCenterX, bounds2.right);
            this.boxUnderlineFocused.draw(canvas);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x002f  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void drawableStateChanged() {
        boolean z10;
        ColorStateList colorStateList;
        if (this.Q0) {
            return;
        }
        this.Q0 = true;
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        com.google.android.material.internal.e eVar = this.M0;
        if (eVar != null) {
            eVar.P = drawableState;
            ColorStateList colorStateList2 = eVar.f22746o;
            if ((colorStateList2 == null || !colorStateList2.isStateful()) && ((colorStateList = eVar.f22744n) == null || !colorStateList.isStateful())) {
                z10 = false;
            } else {
                eVar.l(false);
                z10 = true;
            }
        }
        if (this.f23360e != null) {
            v(isLaidOut() && isEnabled(), false);
        }
        s();
        x();
        if (z10) {
            invalidate();
        }
        this.Q0 = false;
    }

    public final Rect e(Rect rect) {
        if (this.f23360e == null) {
            throw new IllegalStateException();
        }
        boolean z10 = getLayoutDirection() == 1;
        int i10 = rect.bottom;
        Rect rect2 = this.f23383s0;
        rect2.bottom = i10;
        int i11 = this.f23373k0;
        if (i11 == 1) {
            rect2.left = j(rect.left, z10);
            rect2.top = rect.top + this.f23375l0;
            rect2.right = k(rect.right, z10);
            return rect2;
        }
        if (i11 != 2) {
            rect2.left = j(rect.left, z10);
            rect2.top = getPaddingTop();
            rect2.right = k(rect.right, z10);
            return rect2;
        }
        rect2.left = this.f23360e.getPaddingLeft() + rect.left;
        rect2.top = rect.top - f();
        rect2.right = rect.right - this.f23360e.getPaddingRight();
        return rect2;
    }

    public final int f() {
        if (!this.f23355b0) {
            return 0;
        }
        int i10 = this.f23373k0;
        com.google.android.material.internal.e eVar = this.M0;
        if (i10 == 0) {
            return (int) eVar.h();
        }
        if (i10 != 2) {
            return 0;
        }
        if (getHintMaxLines() == 1) {
            return (int) (eVar.h() / 2.0f);
        }
        float fH = eVar.h();
        TextPaint textPaint = eVar.S;
        textPaint.setTextSize(eVar.f22742m);
        textPaint.setTypeface(eVar.f22759w);
        textPaint.setLetterSpacing(eVar.f22725d0);
        return Math.max(0, (int) (fH - ((-textPaint.ascent()) / 2.0f)));
    }

    public final r3.g g() {
        r3.g gVar = new r3.g();
        gVar.f32452c = com.bumptech.glide.f.o(getContext(), x8.c.motionDurationShort2, 87);
        gVar.setInterpolator(com.bumptech.glide.f.p(getContext(), x8.c.motionEasingLinearInterpolator, y8.a.f36864a));
        return gVar;
    }

    @Override // android.widget.LinearLayout, android.view.View
    public int getBaseline() {
        EditText editText = this.f23360e;
        if (editText == null) {
            return super.getBaseline();
        }
        return f() + getPaddingTop() + editText.getBaseline();
    }

    @NonNull
    public com.google.android.material.shape.k getBoxBackground() {
        int i10 = this.f23373k0;
        if (i10 == 1 || i10 == 2) {
            return this.boxBackground;
        }
        throw new IllegalStateException();
    }

    public int getBoxBackgroundColor() {
        return this.f23381q0;
    }

    public int getBoxBackgroundMode() {
        return this.f23373k0;
    }

    public int getBoxCollapsedPaddingTop() {
        return this.f23375l0;
    }

    public float getBoxCornerRadiusBottomEnd() {
        int layoutDirection = getLayoutDirection();
        RectF rectF = this.f23384t0;
        return layoutDirection == 1 ? this.f23367h0.f23158h.a(rectF) : this.f23367h0.f23157g.a(rectF);
    }

    public float getBoxCornerRadiusBottomStart() {
        int layoutDirection = getLayoutDirection();
        RectF rectF = this.f23384t0;
        return layoutDirection == 1 ? this.f23367h0.f23157g.a(rectF) : this.f23367h0.f23158h.a(rectF);
    }

    public float getBoxCornerRadiusTopEnd() {
        int layoutDirection = getLayoutDirection();
        RectF rectF = this.f23384t0;
        return layoutDirection == 1 ? this.f23367h0.f23155e.a(rectF) : this.f23367h0.f23156f.a(rectF);
    }

    public float getBoxCornerRadiusTopStart() {
        int layoutDirection = getLayoutDirection();
        RectF rectF = this.f23384t0;
        return layoutDirection == 1 ? this.f23367h0.f23156f.a(rectF) : this.f23367h0.f23155e.a(rectF);
    }

    public int getBoxStrokeColor() {
        return this.D0;
    }

    @Nullable
    public ColorStateList getBoxStrokeErrorColor() {
        return this.E0;
    }

    public int getBoxStrokeWidth() {
        return this.f23378n0;
    }

    public int getBoxStrokeWidthFocused() {
        return this.f23379o0;
    }

    public int getCounterMaxLength() {
        return this.f23376m;
    }

    @Nullable
    public CharSequence getCounterOverflowDescription() {
        TextView textView;
        if (this.f23374l && this.Q && (textView = this.counterView) != null) {
            return textView.getContentDescription();
        }
        return null;
    }

    @Nullable
    public ColorStateList getCounterOverflowTextColor() {
        return this.counterOverflowTextColor;
    }

    @Nullable
    public ColorStateList getCounterTextColor() {
        return this.counterTextColor;
    }

    @Nullable
    @RequiresApi(29)
    public ColorStateList getCursorColor() {
        return this.cursorColor;
    }

    @Nullable
    @RequiresApi(29)
    public ColorStateList getCursorErrorColor() {
        return this.cursorErrorColor;
    }

    @Nullable
    public ColorStateList getDefaultHintTextColor() {
        return this.z0;
    }

    @Nullable
    public EditText getEditText() {
        return this.f23360e;
    }

    @Nullable
    public CharSequence getEndIconContentDescription() {
        return this.f23356c.getEndIconContentDescription();
    }

    @Nullable
    public Drawable getEndIconDrawable() {
        return this.f23356c.getEndIconDrawable();
    }

    public int getEndIconMinSize() {
        return this.f23356c.f23438m;
    }

    public int getEndIconMode() {
        return this.f23356c.f23434i;
    }

    @NonNull
    public ImageView.ScaleType getEndIconScaleType() {
        return this.f23356c.Q;
    }

    @NonNull
    public CheckableImageButton getEndIconView() {
        return this.f23356c.f23432g;
    }

    @Nullable
    public CharSequence getError() {
        s sVar = this.f23372k;
        if (sVar.f23462o) {
            return sVar.getErrorText();
        }
        return null;
    }

    public int getErrorAccessibilityLiveRegion() {
        return this.f23372k.f23463p;
    }

    @Nullable
    public CharSequence getErrorContentDescription() {
        return this.f23372k.getErrorContentDescription();
    }

    @ColorInt
    public int getErrorCurrentTextColors() {
        return this.f23372k.g();
    }

    @Nullable
    public Drawable getErrorIconDrawable() {
        return this.f23356c.f23428c.getDrawable();
    }

    @Nullable
    public CharSequence getHelperText() {
        s sVar = this.f23372k;
        if (sVar.f23466s) {
            return sVar.f23465r;
        }
        return null;
    }

    @ColorInt
    public int getHelperTextCurrentTextColor() {
        return this.f23372k.h();
    }

    @Nullable
    public CharSequence getHint() {
        if (this.f23355b0) {
            return this.f23357c0;
        }
        return null;
    }

    @VisibleForTesting
    public final float getHintCollapsedTextHeight() {
        return this.M0.h();
    }

    @VisibleForTesting
    public final int getHintCurrentCollapsedTextColor() {
        return this.M0.i();
    }

    public int getHintMaxLines() {
        return this.M0.f22741l0;
    }

    @Nullable
    public ColorStateList getHintTextColor() {
        return this.A0;
    }

    @NonNull
    public z getLengthCounter() {
        return this.R;
    }

    public int getMaxEms() {
        return this.f23366h;
    }

    @Px
    public int getMaxWidth() {
        return this.f23370j;
    }

    public int getMinEms() {
        return this.f23364g;
    }

    @Px
    public int getMinWidth() {
        return this.f23368i;
    }

    @Nullable
    @Deprecated
    public CharSequence getPasswordVisibilityToggleContentDescription() {
        return this.f23356c.getPasswordVisibilityToggleContentDescription();
    }

    @Nullable
    @Deprecated
    public Drawable getPasswordVisibilityToggleDrawable() {
        return this.f23356c.getPasswordVisibilityToggleDrawable();
    }

    @Nullable
    public CharSequence getPlaceholderText() {
        if (this.V) {
            return this.U;
        }
        return null;
    }

    @StyleRes
    public int getPlaceholderTextAppearance() {
        return this.f23353a0;
    }

    @Nullable
    public ColorStateList getPlaceholderTextColor() {
        return this.placeholderTextColor;
    }

    @Nullable
    public CharSequence getPrefixText() {
        return this.f23354b.getPrefixText();
    }

    @Nullable
    public ColorStateList getPrefixTextColor() {
        return this.f23354b.getPrefixTextColor();
    }

    @NonNull
    public TextView getPrefixTextView() {
        return this.f23354b.f23473b;
    }

    @NonNull
    public com.google.android.material.shape.s getShapeAppearanceModel() {
        return this.f23367h0;
    }

    @Nullable
    public CharSequence getStartIconContentDescription() {
        return this.f23354b.getStartIconContentDescription();
    }

    @Nullable
    public Drawable getStartIconDrawable() {
        return this.f23354b.getStartIconDrawable();
    }

    public int getStartIconMinSize() {
        return this.f23354b.f23477f;
    }

    @NonNull
    public ImageView.ScaleType getStartIconScaleType() {
        return this.f23354b.f23478g;
    }

    @Nullable
    public CharSequence getSuffixText() {
        return this.f23356c.getSuffixText();
    }

    @Nullable
    public ColorStateList getSuffixTextColor() {
        return this.f23356c.getSuffixTextColor();
    }

    @NonNull
    public TextView getSuffixTextView() {
        return this.f23356c.S;
    }

    @Nullable
    public Typeface getTypeface() {
        return this.f23385u0;
    }

    public final boolean h() {
        return this.f23355b0 && !TextUtils.isEmpty(this.f23357c0) && (this.boxBackground instanceof i);
    }

    public final com.google.android.material.shape.k i(boolean z10) {
        float dimensionPixelOffset = getResources().getDimensionPixelOffset(x8.e.mtrl_shape_corner_size_small_component);
        float f10 = z10 ? dimensionPixelOffset : 0.0f;
        EditText editText = this.f23360e;
        float popupElevation = editText instanceof MaterialAutoCompleteTextView ? ((MaterialAutoCompleteTextView) editText).getPopupElevation() : getResources().getDimensionPixelOffset(x8.e.m3_comp_outlined_autocomplete_menu_container_elevation);
        int dimensionPixelOffset2 = getResources().getDimensionPixelOffset(x8.e.mtrl_exposed_dropdown_menu_popup_vertical_padding);
        com.google.android.material.shape.q qVar = new com.google.android.material.shape.q();
        qVar.f(f10);
        qVar.g(f10);
        qVar.d(dimensionPixelOffset);
        qVar.e(dimensionPixelOffset);
        com.google.android.material.shape.s sVarA = qVar.a();
        EditText editText2 = this.f23360e;
        com.google.android.material.shape.k kVarCreateWithElevationOverlay = com.google.android.material.shape.k.createWithElevationOverlay(getContext(), popupElevation, editText2 instanceof MaterialAutoCompleteTextView ? ((MaterialAutoCompleteTextView) editText2).getDropDownBackgroundTintList() : null);
        kVarCreateWithElevationOverlay.setShapeAppearanceModel(sVarA);
        kVarCreateWithElevationOverlay.y(0, dimensionPixelOffset2, 0, dimensionPixelOffset2);
        return kVarCreateWithElevationOverlay;
    }

    public final int j(int i10, boolean z10) {
        return ((z10 || getPrefixText() == null) ? (!z10 || getSuffixText() == null) ? this.f23360e.getCompoundPaddingLeft() : this.f23356c.d() : this.f23354b.a()) + i10;
    }

    public final int k(int i10, boolean z10) {
        return i10 - ((z10 || getSuffixText() == null) ? (!z10 || getPrefixText() == null) ? this.f23360e.getCompoundPaddingRight() : this.f23354b.a() : this.f23356c.d());
    }

    public final void l() {
        int i10 = this.f23373k0;
        if (i10 == 0) {
            this.boxBackground = null;
            this.boxUnderlineDefault = null;
            this.boxUnderlineFocused = null;
        } else if (i10 == 1) {
            this.boxBackground = new com.google.android.material.shape.k(this.f23367h0);
            this.boxUnderlineDefault = new com.google.android.material.shape.k();
            this.boxUnderlineFocused = new com.google.android.material.shape.k();
        } else {
            if (i10 != 2) {
                throw new IllegalArgumentException(u.a.b(new StringBuilder(), this.f23373k0, " is illegal; only @BoxBackgroundMode constants are supported."));
            }
            if (!this.f23355b0 || (this.boxBackground instanceof i)) {
                this.boxBackground = new com.google.android.material.shape.k(this.f23367h0);
            } else {
                this.boxBackground = i.create(this.f23367h0);
            }
            this.boxUnderlineDefault = null;
            this.boxUnderlineFocused = null;
        }
        t();
        x();
        if (this.f23373k0 == 1) {
            if (getContext().getResources().getConfiguration().fontScale >= 2.0f) {
                this.f23375l0 = getResources().getDimensionPixelSize(x8.e.material_font_2_0_box_collapsed_padding_top);
            } else if (q9.d.c(getContext())) {
                this.f23375l0 = getResources().getDimensionPixelSize(x8.e.material_font_1_3_box_collapsed_padding_top);
            }
        }
        b();
        if (this.f23373k0 != 0) {
            u();
        }
        EditText editText = this.f23360e;
        if (editText instanceof AutoCompleteTextView) {
            AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) editText;
            if (autoCompleteTextView.getDropDownBackground() == null) {
                int i11 = this.f23373k0;
                if (i11 == 2) {
                    autoCompleteTextView.setDropDownBackgroundDrawable(getOrCreateOutlinedDropDownMenuBackground());
                } else if (i11 == 1) {
                    autoCompleteTextView.setDropDownBackgroundDrawable(getOrCreateFilledDropDownMenuBackground());
                }
            }
        }
    }

    public final void m() {
        if (h()) {
            int width = this.f23360e.getWidth();
            int gravity = this.f23360e.getGravity();
            com.google.android.material.internal.e eVar = this.M0;
            RectF rectF = this.f23384t0;
            eVar.g(rectF, width, gravity);
            if (rectF.width() <= 0.0f || rectF.height() <= 0.0f) {
                return;
            }
            float f10 = rectF.left;
            float f11 = this.f23371j0;
            rectF.left = f10 - f11;
            rectF.right += f11;
            rectF.offset(-getPaddingLeft(), ((-getPaddingTop()) - (rectF.height() / 2.0f)) + this.f23377m0);
            rectF.top = 0.0f;
            i iVar = (i) this.boxBackground;
            iVar.getClass();
            iVar.I(rectF.left, rectF.top, rectF.right, rectF.bottom);
        }
    }

    public final void o(TextView textView, int i10) {
        try {
            textView.setTextAppearance(i10);
            if (textView.getTextColors().getDefaultColor() != -65281) {
                return;
            }
        } catch (Exception unused) {
        }
        textView.setTextAppearance(d.i.TextAppearance_AppCompat_Caption);
        Context context = getContext();
        int i11 = x8.d.design_error;
        Object obj = g0.d.f26125a;
        textView.setTextColor(context.getColor(i11));
    }

    @Override // android.view.View
    public final void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.M0.k(configuration);
    }

    @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
    public final void onGlobalLayout() {
        int iMax;
        o oVar = this.f23356c;
        oVar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        boolean z10 = false;
        this.S0 = false;
        if (this.f23360e != null && this.f23360e.getMeasuredHeight() < (iMax = Math.max(oVar.getMeasuredHeight(), this.f23354b.getMeasuredHeight()))) {
            this.f23360e.setMinimumHeight(iMax);
            z10 = true;
        }
        boolean zR = r();
        if (z10 || zR) {
            this.f23360e.post(new y.a(this, 17));
        }
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        float fJ;
        int i14;
        int compoundPaddingTop;
        super.onLayout(z10, i10, i11, i12, i13);
        EditText editText = this.f23360e;
        if (editText != null) {
            Rect rect = this.f23382r0;
            com.google.android.material.internal.g.a(this, editText, rect);
            com.google.android.material.shape.k kVar = this.boxUnderlineDefault;
            if (kVar != null) {
                int i15 = rect.bottom;
                kVar.setBounds(rect.left, i15 - this.f23378n0, rect.right, i15);
            }
            com.google.android.material.shape.k kVar2 = this.boxUnderlineFocused;
            if (kVar2 != null) {
                int i16 = rect.bottom;
                kVar2.setBounds(rect.left, i16 - this.f23379o0, rect.right, i16);
            }
            if (this.f23355b0) {
                float textSize = this.f23360e.getTextSize();
                com.google.android.material.internal.e eVar = this.M0;
                eVar.x(textSize);
                int gravity = this.f23360e.getGravity();
                eVar.r((gravity & (-113)) | 48);
                eVar.w(gravity);
                Rect rectE = e(rect);
                eVar.n(rectE.left, rectE.top, rectE.right, rectE.bottom);
                if (this.f23360e == null) {
                    throw new IllegalStateException();
                }
                int hintMaxLines = getHintMaxLines();
                TextPaint textPaint = eVar.S;
                if (hintMaxLines == 1) {
                    textPaint.setTextSize(eVar.f22740l);
                    textPaint.setTypeface(eVar.f22762z);
                    textPaint.setLetterSpacing(eVar.f22727e0);
                    fJ = -textPaint.ascent();
                } else {
                    fJ = eVar.j() * eVar.f22748p;
                }
                int compoundPaddingLeft = this.f23360e.getCompoundPaddingLeft() + rect.left;
                Rect rect2 = this.f23383s0;
                rect2.left = compoundPaddingLeft;
                if (this.f23373k0 == 1 && this.f23360e.getMinLines() <= 1) {
                    compoundPaddingTop = (int) (rect.centerY() - (fJ / 2.0f));
                } else {
                    if (this.f23373k0 != 0 || getHintMaxLines() == 1) {
                        i14 = 0;
                    } else {
                        textPaint.setTextSize(eVar.f22740l);
                        textPaint.setTypeface(eVar.f22762z);
                        textPaint.setLetterSpacing(eVar.f22727e0);
                        i14 = (int) ((-textPaint.ascent()) / 2.0f);
                    }
                    compoundPaddingTop = (this.f23360e.getCompoundPaddingTop() + rect.top) - i14;
                }
                rect2.top = compoundPaddingTop;
                rect2.right = rect.right - this.f23360e.getCompoundPaddingRight();
                int compoundPaddingBottom = (this.f23373k0 != 1 || this.f23360e.getMinLines() > 1) ? rect.bottom - this.f23360e.getCompoundPaddingBottom() : (int) (rect2.top + fJ);
                rect2.bottom = compoundPaddingBottom;
                eVar.t(rect2.left, rect2.top, rect2.right, compoundPaddingBottom, true);
                eVar.l(false);
                if (!h() || this.L0) {
                    return;
                }
                m();
            }
        }
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onMeasure(int i10, int i11) {
        float f10;
        EditText editText;
        super.onMeasure(i10, i11);
        boolean z10 = this.S0;
        o oVar = this.f23356c;
        if (!z10) {
            oVar.getViewTreeObserver().addOnGlobalLayoutListener(this);
            this.S0 = true;
        }
        if (this.W != null && (editText = this.f23360e) != null) {
            this.W.setGravity(editText.getGravity());
            this.W.setPadding(this.f23360e.getCompoundPaddingLeft(), this.f23360e.getCompoundPaddingTop(), this.f23360e.getCompoundPaddingRight(), this.f23360e.getCompoundPaddingBottom());
        }
        oVar.n();
        if (getHintMaxLines() == 1) {
            return;
        }
        int measuredWidth = (this.f23360e.getMeasuredWidth() - this.f23360e.getCompoundPaddingLeft()) - this.f23360e.getCompoundPaddingRight();
        com.google.android.material.internal.e eVar = this.M0;
        eVar.B(measuredWidth);
        EditText editText2 = this.f23360e;
        Rect rect = this.f23382r0;
        com.google.android.material.internal.g.a(this, editText2, rect);
        Rect rectE = e(rect);
        eVar.n(rectE.left, rectE.top, rectE.right, rectE.bottom);
        u();
        b();
        if (this.f23360e == null) {
            return;
        }
        int i12 = eVar.f22753r0;
        if (i12 != -1) {
            f10 = i12;
        } else {
            TextPaint textPaint = eVar.S;
            textPaint.setTextSize(eVar.f22740l);
            textPaint.setTypeface(eVar.f22762z);
            textPaint.setLetterSpacing(eVar.f22727e0);
            f10 = -textPaint.ascent();
        }
        if (this.U != null) {
            TextPaint textPaint2 = new TextPaint(129);
            textPaint2.set(this.W.getPaint());
            textPaint2.setTextSize(this.W.getTextSize());
            textPaint2.setTypeface(this.W.getTypeface());
            textPaint2.setLetterSpacing(this.W.getLetterSpacing());
            k0 k0Var = new k0(this.U, textPaint2, measuredWidth);
            k0Var.f22786k = getLayoutDirection() == 1;
            k0Var.f22785j = true;
            float lineSpacingExtra = this.W.getLineSpacingExtra();
            float lineSpacingMultiplier = this.W.getLineSpacingMultiplier();
            k0Var.f22782g = lineSpacingExtra;
            k0Var.f22783h = lineSpacingMultiplier;
            fH = (this.f23373k0 == 1 ? eVar.h() + this.f23375l0 + this.f23358d : 0.0f) + k0Var.setStaticLayoutBuilderConfigurer(new androidx.core.app.e(this, 25)).a().getHeight();
        }
        float fMax = Math.max(f10, fH);
        if (this.f23360e.getMeasuredHeight() < fMax) {
            this.f23360e.setMinimumHeight(Math.round(fMax));
        }
    }

    @Override // android.view.View
    public void onRestoreInstanceState(@Nullable Parcelable parcelable) {
        if (!(parcelable instanceof b0)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        b0 b0Var = (b0) parcelable;
        super.onRestoreInstanceState(b0Var.getSuperState());
        setError(b0Var.error);
        if (b0Var.f23394c) {
            post(new i0(this, 4));
        }
        requestLayout();
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onRtlPropertiesChanged(int i10) {
        super.onRtlPropertiesChanged(i10);
        boolean z10 = i10 == 1;
        if (z10 != this.f23369i0) {
            com.google.android.material.shape.d dVar = this.f23367h0.f23155e;
            RectF rectF = this.f23384t0;
            float fA = dVar.a(rectF);
            float fA2 = this.f23367h0.f23156f.a(rectF);
            float fA3 = this.f23367h0.f23158h.a(rectF);
            float fA4 = this.f23367h0.f23157g.a(rectF);
            com.google.android.material.shape.s sVar = this.f23367h0;
            com.bumptech.glide.h hVar = sVar.f23151a;
            com.bumptech.glide.h hVar2 = sVar.f23152b;
            com.bumptech.glide.h hVar3 = sVar.f23154d;
            com.bumptech.glide.h hVar4 = sVar.f23153c;
            com.google.android.material.shape.q qVar = new com.google.android.material.shape.q();
            qVar.f23134a = hVar2;
            com.google.android.material.shape.q.b(hVar2);
            qVar.f23135b = hVar;
            com.google.android.material.shape.q.b(hVar);
            qVar.f23137d = hVar4;
            com.google.android.material.shape.q.b(hVar4);
            qVar.f23136c = hVar3;
            com.google.android.material.shape.q.b(hVar3);
            qVar.f(fA2);
            qVar.g(fA);
            qVar.d(fA4);
            qVar.e(fA3);
            com.google.android.material.shape.s sVarA = qVar.a();
            this.f23369i0 = z10;
            setShapeAppearanceModel(sVarA);
        }
    }

    @Override // android.view.View
    @Nullable
    public Parcelable onSaveInstanceState() {
        b0 b0Var = new b0(super.onSaveInstanceState());
        if (this.f23372k.f()) {
            b0Var.error = getError();
        }
        o oVar = this.f23356c;
        b0Var.f23394c = oVar.f23434i != 0 && oVar.f23432g.isChecked();
        return b0Var;
    }

    public final void p() {
        ColorStateList colorStateList;
        ColorStateList colorStateList2;
        TextView textView = this.counterView;
        if (textView != null) {
            o(textView, this.Q ? this.S : this.T);
            if (!this.Q && (colorStateList2 = this.counterTextColor) != null) {
                this.counterView.setTextColor(colorStateList2);
            }
            if (!this.Q || (colorStateList = this.counterOverflowTextColor) == null) {
                return;
            }
            this.counterView.setTextColor(colorStateList);
        }
    }

    public final void q() {
        ColorStateList colorStateList;
        ColorStateList colorStateListOrNull = this.cursorColor;
        if (colorStateListOrNull == null) {
            colorStateListOrNull = h9.a.getColorStateListOrNull(getContext(), d.a.colorControlActivated);
        }
        EditText editText = this.f23360e;
        if (editText == null || editText.getTextCursorDrawable() == null) {
            return;
        }
        Drawable drawableMutate = this.f23360e.getTextCursorDrawable().mutate();
        if ((this.f23372k.f() || (this.counterView != null && this.Q)) && (colorStateList = this.cursorErrorColor) != null) {
            colorStateListOrNull = colorStateList;
        }
        drawableMutate.setTintList(colorStateListOrNull);
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x005f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean r() {
        boolean z10;
        if (this.f23360e == null) {
            return false;
        }
        boolean z11 = true;
        if (getStartIconDrawable() != null || (getPrefixText() != null && getPrefixTextView().getVisibility() == 0)) {
            v vVar = this.f23354b;
            if (vVar.getMeasuredWidth() > 0) {
                int measuredWidth = vVar.getMeasuredWidth() - this.f23360e.getPaddingLeft();
                if (this.startDummyDrawable == null || this.f23386v0 != measuredWidth) {
                    ColorDrawable colorDrawable = new ColorDrawable();
                    this.startDummyDrawable = colorDrawable;
                    this.f23386v0 = measuredWidth;
                    colorDrawable.setBounds(0, 0, measuredWidth, 1);
                }
                Drawable[] compoundDrawablesRelative = this.f23360e.getCompoundDrawablesRelative();
                Drawable drawable = compoundDrawablesRelative[0];
                Drawable drawable2 = this.startDummyDrawable;
                if (drawable != drawable2) {
                    this.f23360e.setCompoundDrawablesRelative(drawable2, compoundDrawablesRelative[1], compoundDrawablesRelative[2], compoundDrawablesRelative[3]);
                    z10 = true;
                }
                z10 = false;
            } else {
                if (this.startDummyDrawable != null) {
                    Drawable[] compoundDrawablesRelative2 = this.f23360e.getCompoundDrawablesRelative();
                    this.f23360e.setCompoundDrawablesRelative(null, compoundDrawablesRelative2[1], compoundDrawablesRelative2[2], compoundDrawablesRelative2[3]);
                    this.startDummyDrawable = null;
                    z10 = true;
                }
                z10 = false;
            }
        }
        o oVar = this.f23356c;
        if ((oVar.f() || ((oVar.f23434i != 0 && oVar.e()) || oVar.getSuffixText() != null)) && oVar.getMeasuredWidth() > 0) {
            int measuredWidth2 = oVar.S.getMeasuredWidth() - this.f23360e.getPaddingRight();
            CheckableImageButton currentEndIconView = oVar.getCurrentEndIconView();
            if (currentEndIconView != null) {
                measuredWidth2 = ((ViewGroup.MarginLayoutParams) currentEndIconView.getLayoutParams()).getMarginStart() + currentEndIconView.getMeasuredWidth() + measuredWidth2;
            }
            Drawable[] compoundDrawablesRelative3 = this.f23360e.getCompoundDrawablesRelative();
            Drawable drawable3 = this.endDummyDrawable;
            if (drawable3 == null || this.f23388x0 == measuredWidth2) {
                if (drawable3 == null) {
                    ColorDrawable colorDrawable2 = new ColorDrawable();
                    this.endDummyDrawable = colorDrawable2;
                    this.f23388x0 = measuredWidth2;
                    colorDrawable2.setBounds(0, 0, measuredWidth2, 1);
                }
                Drawable drawable4 = compoundDrawablesRelative3[2];
                Drawable drawable5 = this.endDummyDrawable;
                if (drawable4 != drawable5) {
                    this.f23389y0 = drawable4;
                    this.f23360e.setCompoundDrawablesRelative(compoundDrawablesRelative3[0], compoundDrawablesRelative3[1], drawable5, compoundDrawablesRelative3[3]);
                } else {
                    z11 = z10;
                }
            } else {
                this.f23388x0 = measuredWidth2;
                drawable3.setBounds(0, 0, measuredWidth2, 1);
                this.f23360e.setCompoundDrawablesRelative(compoundDrawablesRelative3[0], compoundDrawablesRelative3[1], this.endDummyDrawable, compoundDrawablesRelative3[3]);
            }
        } else {
            if (this.endDummyDrawable == null) {
                return z10;
            }
            Drawable[] compoundDrawablesRelative4 = this.f23360e.getCompoundDrawablesRelative();
            if (compoundDrawablesRelative4[2] == this.endDummyDrawable) {
                this.f23360e.setCompoundDrawablesRelative(compoundDrawablesRelative4[0], compoundDrawablesRelative4[1], this.f23389y0, compoundDrawablesRelative4[3]);
            } else {
                z11 = z10;
            }
            this.endDummyDrawable = null;
        }
        return z11;
    }

    public final void s() {
        Drawable background;
        TextView textView;
        EditText editText = this.f23360e;
        if (editText == null || this.f23373k0 != 0 || (background = editText.getBackground()) == null) {
            return;
        }
        int[] iArr = p1.f29805a;
        Drawable drawableMutate = background.mutate();
        if (this.f23372k.f()) {
            drawableMutate.setColorFilter(c0.c(getErrorCurrentTextColors(), PorterDuff.Mode.SRC_IN));
        } else if (this.Q && (textView = this.counterView) != null) {
            drawableMutate.setColorFilter(c0.c(textView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
        } else {
            drawableMutate.clearColorFilter();
            this.f23360e.refreshDrawableState();
        }
    }

    public void setBoxBackgroundColor(@ColorInt int i10) {
        if (this.f23381q0 != i10) {
            this.f23381q0 = i10;
            this.F0 = i10;
            this.H0 = i10;
            this.I0 = i10;
            d();
        }
    }

    public void setBoxBackgroundColorResource(@ColorRes int i10) {
        Context context = getContext();
        Object obj = g0.d.f26125a;
        setBoxBackgroundColor(context.getColor(i10));
    }

    public void setBoxBackgroundColorStateList(@NonNull ColorStateList colorStateList) {
        int defaultColor = colorStateList.getDefaultColor();
        this.F0 = defaultColor;
        this.f23381q0 = defaultColor;
        this.G0 = colorStateList.getColorForState(new int[]{-16842910}, -1);
        this.H0 = colorStateList.getColorForState(new int[]{R.attr.state_focused, R.attr.state_enabled}, -1);
        this.I0 = colorStateList.getColorForState(new int[]{R.attr.state_hovered, R.attr.state_enabled}, -1);
        d();
    }

    public void setBoxBackgroundMode(int i10) {
        if (i10 == this.f23373k0) {
            return;
        }
        this.f23373k0 = i10;
        if (this.f23360e != null) {
            l();
        }
    }

    public void setBoxCollapsedPaddingTop(int i10) {
        this.f23375l0 = i10;
    }

    public void setBoxCornerFamily(int i10) {
        com.google.android.material.shape.q qVarH = this.f23367h0.h();
        com.google.android.material.shape.d dVar = this.f23367h0.f23155e;
        com.bumptech.glide.h hVarB = com.bumptech.glide.f.b(i10);
        qVarH.f23134a = hVarB;
        com.google.android.material.shape.q.b(hVarB);
        qVarH.f23138e = dVar;
        com.google.android.material.shape.d dVar2 = this.f23367h0.f23156f;
        com.bumptech.glide.h hVarB2 = com.bumptech.glide.f.b(i10);
        qVarH.f23135b = hVarB2;
        com.google.android.material.shape.q.b(hVarB2);
        qVarH.f23139f = dVar2;
        com.google.android.material.shape.d dVar3 = this.f23367h0.f23158h;
        com.bumptech.glide.h hVarB3 = com.bumptech.glide.f.b(i10);
        qVarH.f23137d = hVarB3;
        com.google.android.material.shape.q.b(hVarB3);
        qVarH.f23141h = dVar3;
        com.google.android.material.shape.d dVar4 = this.f23367h0.f23157g;
        com.bumptech.glide.h hVarB4 = com.bumptech.glide.f.b(i10);
        qVarH.f23136c = hVarB4;
        com.google.android.material.shape.q.b(hVarB4);
        qVarH.f23140g = dVar4;
        this.f23367h0 = qVarH.a();
        d();
    }

    public void setBoxCornerRadii(float f10, float f11, float f12, float f13) {
        boolean z10 = getLayoutDirection() == 1;
        this.f23369i0 = z10;
        float f14 = z10 ? f11 : f10;
        if (!z10) {
            f10 = f11;
        }
        float f15 = z10 ? f13 : f12;
        if (!z10) {
            f12 = f13;
        }
        com.google.android.material.shape.k kVar = this.boxBackground;
        if (kVar != null && kVar.p() == f14 && this.boxBackground.q() == f10 && this.boxBackground.j() == f15 && this.boxBackground.k() == f12) {
            return;
        }
        com.google.android.material.shape.q qVarH = this.f23367h0.h();
        qVarH.f(f14);
        qVarH.g(f10);
        qVarH.d(f15);
        qVarH.e(f12);
        this.f23367h0 = qVarH.a();
        d();
    }

    public void setBoxCornerRadiiResources(@DimenRes int i10, @DimenRes int i11, @DimenRes int i12, @DimenRes int i13) {
        setBoxCornerRadii(getContext().getResources().getDimension(i10), getContext().getResources().getDimension(i11), getContext().getResources().getDimension(i13), getContext().getResources().getDimension(i12));
    }

    public void setBoxStrokeColor(@ColorInt int i10) {
        if (this.D0 != i10) {
            this.D0 = i10;
            x();
        }
    }

    public void setBoxStrokeColorStateList(@NonNull ColorStateList colorStateList) {
        if (colorStateList.isStateful()) {
            this.B0 = colorStateList.getDefaultColor();
            this.J0 = colorStateList.getColorForState(new int[]{-16842910}, -1);
            this.C0 = colorStateList.getColorForState(new int[]{R.attr.state_hovered, R.attr.state_enabled}, -1);
            this.D0 = colorStateList.getColorForState(new int[]{R.attr.state_focused, R.attr.state_enabled}, -1);
        } else if (this.D0 != colorStateList.getDefaultColor()) {
            this.D0 = colorStateList.getDefaultColor();
        }
        x();
    }

    public void setBoxStrokeErrorColor(@Nullable ColorStateList colorStateList) {
        if (this.E0 != colorStateList) {
            this.E0 = colorStateList;
            x();
        }
    }

    public void setBoxStrokeWidth(int i10) {
        this.f23378n0 = i10;
        x();
    }

    public void setBoxStrokeWidthFocused(int i10) {
        this.f23379o0 = i10;
        x();
    }

    public void setBoxStrokeWidthFocusedResource(@DimenRes int i10) {
        setBoxStrokeWidthFocused(getResources().getDimensionPixelSize(i10));
    }

    public void setBoxStrokeWidthResource(@DimenRes int i10) {
        setBoxStrokeWidth(getResources().getDimensionPixelSize(i10));
    }

    public void setCounterEnabled(boolean z10) {
        if (this.f23374l != z10) {
            s sVar = this.f23372k;
            if (z10) {
                AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
                this.counterView = appCompatTextView;
                appCompatTextView.setId(x8.g.textinput_counter);
                Typeface typeface = this.f23385u0;
                if (typeface != null) {
                    this.counterView.setTypeface(typeface);
                }
                this.counterView.setMaxLines(1);
                sVar.c(this.counterView, 2);
                ((ViewGroup.MarginLayoutParams) this.counterView.getLayoutParams()).setMarginStart(getResources().getDimensionPixelOffset(x8.e.mtrl_textinput_counter_margin_start));
                p();
                if (this.counterView != null) {
                    EditText editText = this.f23360e;
                    updateCounter(editText != null ? editText.getText() : null);
                }
            } else {
                sVar.j(this.counterView, 2);
                this.counterView = null;
            }
            this.f23374l = z10;
        }
    }

    public void setCounterMaxLength(int i10) {
        if (this.f23376m != i10) {
            if (i10 > 0) {
                this.f23376m = i10;
            } else {
                this.f23376m = -1;
            }
            if (!this.f23374l || this.counterView == null) {
                return;
            }
            EditText editText = this.f23360e;
            updateCounter(editText == null ? null : editText.getText());
        }
    }

    public void setCounterOverflowTextAppearance(int i10) {
        if (this.S != i10) {
            this.S = i10;
            p();
        }
    }

    public void setCounterOverflowTextColor(@Nullable ColorStateList colorStateList) {
        if (this.counterOverflowTextColor != colorStateList) {
            this.counterOverflowTextColor = colorStateList;
            p();
        }
    }

    public void setCounterTextAppearance(int i10) {
        if (this.T != i10) {
            this.T = i10;
            p();
        }
    }

    public void setCounterTextColor(@Nullable ColorStateList colorStateList) {
        if (this.counterTextColor != colorStateList) {
            this.counterTextColor = colorStateList;
            p();
        }
    }

    @RequiresApi(29)
    public void setCursorColor(@Nullable ColorStateList colorStateList) {
        if (this.cursorColor != colorStateList) {
            this.cursorColor = colorStateList;
            q();
        }
    }

    @RequiresApi(29)
    public void setCursorErrorColor(@Nullable ColorStateList colorStateList) {
        if (this.cursorErrorColor != colorStateList) {
            this.cursorErrorColor = colorStateList;
            if (this.f23372k.f() || (this.counterView != null && this.Q)) {
                q();
            }
        }
    }

    public void setDefaultHintTextColor(@Nullable ColorStateList colorStateList) {
        this.z0 = colorStateList;
        this.A0 = colorStateList;
        if (this.f23360e != null) {
            v(false, false);
        }
    }

    @Override // android.view.View
    public void setEnabled(boolean z10) {
        n(this, z10);
        super.setEnabled(z10);
    }

    public void setEndIconActivated(boolean z10) {
        this.f23356c.f23432g.setActivated(z10);
    }

    public void setEndIconCheckable(boolean z10) {
        this.f23356c.f23432g.setCheckable(z10);
    }

    public void setEndIconContentDescription(@StringRes int i10) {
        o oVar = this.f23356c;
        oVar.setEndIconContentDescription(i10 != 0 ? oVar.getResources().getText(i10) : null);
    }

    public void setEndIconDrawable(@DrawableRes int i10) {
        o oVar = this.f23356c;
        oVar.setEndIconDrawable(i10 != 0 ? f.a.getDrawable(oVar.getContext(), i10) : null);
    }

    public void setEndIconMinSize(@IntRange(from = 0) int i10) {
        o oVar = this.f23356c;
        if (i10 < 0) {
            oVar.getClass();
            throw new IllegalArgumentException("endIconSize cannot be less than 0");
        }
        if (i10 != oVar.f23438m) {
            oVar.f23438m = i10;
            CheckableImageButton checkableImageButton = oVar.f23432g;
            checkableImageButton.setMinimumWidth(i10);
            checkableImageButton.setMinimumHeight(i10);
            CheckableImageButton checkableImageButton2 = oVar.f23428c;
            checkableImageButton2.setMinimumWidth(i10);
            checkableImageButton2.setMinimumHeight(i10);
        }
    }

    public void setEndIconMode(int i10) {
        this.f23356c.i(i10);
    }

    public void setEndIconOnClickListener(@Nullable View.OnClickListener onClickListener) {
        this.f23356c.setEndIconOnClickListener(onClickListener);
    }

    public void setEndIconOnLongClickListener(@Nullable View.OnLongClickListener onLongClickListener) {
        this.f23356c.setEndIconOnLongClickListener(onLongClickListener);
    }

    public void setEndIconScaleType(@NonNull ImageView.ScaleType scaleType) {
        o oVar = this.f23356c;
        oVar.Q = scaleType;
        oVar.f23432g.setScaleType(scaleType);
        oVar.f23428c.setScaleType(scaleType);
    }

    public void setEndIconTintList(@Nullable ColorStateList colorStateList) {
        this.f23356c.setEndIconTintList(colorStateList);
    }

    public void setEndIconTintMode(@Nullable PorterDuff.Mode mode) {
        this.f23356c.setEndIconTintMode(mode);
    }

    public void setEndIconVisible(boolean z10) {
        this.f23356c.j(z10);
    }

    public void setError(@Nullable CharSequence charSequence) {
        s sVar = this.f23372k;
        if (!sVar.f23462o) {
            if (TextUtils.isEmpty(charSequence)) {
                return;
            } else {
                setErrorEnabled(true);
            }
        }
        if (TextUtils.isEmpty(charSequence)) {
            sVar.i();
        } else {
            sVar.q(charSequence);
        }
    }

    public void setErrorAccessibilityLiveRegion(int i10) {
        this.f23372k.k(i10);
    }

    public void setErrorContentDescription(@Nullable CharSequence charSequence) {
        this.f23372k.setErrorContentDescription(charSequence);
    }

    public void setErrorEnabled(boolean z10) {
        this.f23372k.l(z10);
    }

    public void setErrorIconDrawable(@DrawableRes int i10) {
        o oVar = this.f23356c;
        oVar.setErrorIconDrawable(i10 != 0 ? f.a.getDrawable(oVar.getContext(), i10) : null);
        q.c(oVar.f23426a, oVar.f23428c, oVar.f23429d);
    }

    public void setErrorIconOnClickListener(@Nullable View.OnClickListener onClickListener) {
        this.f23356c.setErrorIconOnClickListener(onClickListener);
    }

    public void setErrorIconOnLongClickListener(@Nullable View.OnLongClickListener onLongClickListener) {
        this.f23356c.setErrorIconOnLongClickListener(onLongClickListener);
    }

    public void setErrorIconTintList(@Nullable ColorStateList colorStateList) {
        this.f23356c.setErrorIconTintList(colorStateList);
    }

    public void setErrorIconTintMode(@Nullable PorterDuff.Mode mode) {
        this.f23356c.setErrorIconTintMode(mode);
    }

    public void setErrorTextAppearance(@StyleRes int i10) {
        this.f23372k.m(i10);
    }

    public void setErrorTextColor(@Nullable ColorStateList colorStateList) {
        this.f23372k.setErrorViewTextColor(colorStateList);
    }

    public void setExpandedHintEnabled(boolean z10) {
        if (this.N0 != z10) {
            this.N0 = z10;
            v(false, false);
        }
    }

    public void setHelperText(@Nullable CharSequence charSequence) {
        boolean zIsEmpty = TextUtils.isEmpty(charSequence);
        s sVar = this.f23372k;
        if (zIsEmpty) {
            if (sVar.f23466s) {
                setHelperTextEnabled(false);
            }
        } else {
            if (!sVar.f23466s) {
                setHelperTextEnabled(true);
            }
            sVar.r(charSequence);
        }
    }

    public void setHelperTextColor(@Nullable ColorStateList colorStateList) {
        this.f23372k.setHelperTextViewTextColor(colorStateList);
    }

    public void setHelperTextEnabled(boolean z10) {
        this.f23372k.o(z10);
    }

    public void setHelperTextTextAppearance(@StyleRes int i10) {
        this.f23372k.n(i10);
    }

    public void setHint(@Nullable CharSequence charSequence) {
        if (this.f23355b0) {
            setHintInternal(charSequence);
            sendAccessibilityEvent(2048);
        }
    }

    public void setHintAnimationEnabled(boolean z10) {
        this.O0 = z10;
    }

    public void setHintEnabled(boolean z10) {
        if (z10 != this.f23355b0) {
            this.f23355b0 = z10;
            if (z10) {
                CharSequence hint = this.f23360e.getHint();
                if (!TextUtils.isEmpty(hint)) {
                    if (TextUtils.isEmpty(this.f23357c0)) {
                        setHint(hint);
                    }
                    this.f23360e.setHint((CharSequence) null);
                }
                this.f23359d0 = true;
            } else {
                this.f23359d0 = false;
                if (!TextUtils.isEmpty(this.f23357c0) && TextUtils.isEmpty(this.f23360e.getHint())) {
                    this.f23360e.setHint(this.f23357c0);
                }
                setHintInternal(null);
            }
            if (this.f23360e != null) {
                u();
            }
        }
    }

    public void setHintMaxLines(int i10) {
        com.google.android.material.internal.e eVar = this.M0;
        if (i10 != eVar.f22743m0) {
            eVar.f22743m0 = i10;
            eVar.l(false);
        }
        eVar.u(i10);
        requestLayout();
    }

    public void setHintTextAppearance(@StyleRes int i10) {
        com.google.android.material.internal.e eVar = this.M0;
        eVar.p(i10);
        this.A0 = eVar.f22746o;
        if (this.f23360e != null) {
            v(false, false);
            u();
        }
    }

    public void setHintTextColor(@Nullable ColorStateList colorStateList) {
        if (this.A0 != colorStateList) {
            if (this.z0 == null) {
                this.M0.q(colorStateList);
            }
            this.A0 = colorStateList;
            if (this.f23360e != null) {
                v(false, false);
            }
        }
    }

    public void setLengthCounter(@NonNull z zVar) {
        this.R = zVar;
    }

    public void setMaxEms(int i10) {
        this.f23366h = i10;
        EditText editText = this.f23360e;
        if (editText == null || i10 == -1) {
            return;
        }
        editText.setMaxEms(i10);
    }

    public void setMaxWidth(@Px int i10) {
        this.f23370j = i10;
        EditText editText = this.f23360e;
        if (editText == null || i10 == -1) {
            return;
        }
        editText.setMaxWidth(i10);
    }

    public void setMaxWidthResource(@DimenRes int i10) {
        setMaxWidth(getContext().getResources().getDimensionPixelSize(i10));
    }

    public void setMinEms(int i10) {
        this.f23364g = i10;
        EditText editText = this.f23360e;
        if (editText == null || i10 == -1) {
            return;
        }
        editText.setMinEms(i10);
    }

    public void setMinWidth(@Px int i10) {
        this.f23368i = i10;
        EditText editText = this.f23360e;
        if (editText == null || i10 == -1) {
            return;
        }
        editText.setMinWidth(i10);
    }

    public void setMinWidthResource(@DimenRes int i10) {
        setMinWidth(getContext().getResources().getDimensionPixelSize(i10));
    }

    @Deprecated
    public void setPasswordVisibilityToggleContentDescription(@StringRes int i10) {
        o oVar = this.f23356c;
        oVar.setPasswordVisibilityToggleContentDescription(i10 != 0 ? oVar.getResources().getText(i10) : null);
    }

    @Deprecated
    public void setPasswordVisibilityToggleDrawable(@DrawableRes int i10) {
        o oVar = this.f23356c;
        oVar.setPasswordVisibilityToggleDrawable(i10 != 0 ? f.a.getDrawable(oVar.getContext(), i10) : null);
    }

    @Deprecated
    public void setPasswordVisibilityToggleEnabled(boolean z10) {
        o oVar = this.f23356c;
        if (z10 && oVar.f23434i != 1) {
            oVar.i(1);
        } else if (z10) {
            oVar.getClass();
        } else {
            oVar.i(0);
        }
    }

    @Deprecated
    public void setPasswordVisibilityToggleTintList(@Nullable ColorStateList colorStateList) {
        this.f23356c.setPasswordVisibilityToggleTintList(colorStateList);
    }

    @Deprecated
    public void setPasswordVisibilityToggleTintMode(@Nullable PorterDuff.Mode mode) {
        this.f23356c.setPasswordVisibilityToggleTintMode(mode);
    }

    public void setPlaceholderText(@Nullable CharSequence charSequence) {
        if (this.W == null) {
            AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
            this.W = appCompatTextView;
            appCompatTextView.setId(x8.g.textinput_placeholder);
            this.W.setImportantForAccessibility(1);
            this.W.setAccessibilityLiveRegion(1);
            r3.g gVarG = g();
            this.placeholderFadeIn = gVarG;
            gVarG.f32450b = 67L;
            this.placeholderFadeOut = g();
            setPlaceholderTextAppearance(this.f23353a0);
            setPlaceholderTextColor(this.placeholderTextColor);
            s1.setAccessibilityDelegate(this.W, new g0(this, 8));
        }
        if (TextUtils.isEmpty(charSequence)) {
            setPlaceholderTextEnabled(false);
        } else {
            if (!this.V) {
                setPlaceholderTextEnabled(true);
            }
            this.U = charSequence;
        }
        EditText editText = this.f23360e;
        updatePlaceholderText(editText == null ? null : editText.getText());
    }

    public void setPlaceholderTextAppearance(@StyleRes int i10) {
        this.f23353a0 = i10;
        AppCompatTextView appCompatTextView = this.W;
        if (appCompatTextView != null) {
            appCompatTextView.setTextAppearance(i10);
        }
    }

    public void setPlaceholderTextColor(@Nullable ColorStateList colorStateList) {
        if (this.placeholderTextColor != colorStateList) {
            this.placeholderTextColor = colorStateList;
            AppCompatTextView appCompatTextView = this.W;
            if (appCompatTextView == null || colorStateList == null) {
                return;
            }
            appCompatTextView.setTextColor(colorStateList);
        }
    }

    public void setPrefixText(@Nullable CharSequence charSequence) {
        this.f23354b.setPrefixText(charSequence);
    }

    public void setPrefixTextAppearance(@StyleRes int i10) {
        this.f23354b.f23473b.setTextAppearance(i10);
    }

    public void setPrefixTextColor(@NonNull ColorStateList colorStateList) {
        this.f23354b.f23473b.setTextColor(colorStateList);
    }

    public void setShapeAppearanceModel(@NonNull com.google.android.material.shape.s sVar) {
        com.google.android.material.shape.k kVar = this.boxBackground;
        if (kVar == null || kVar.f23095b.f23068a == sVar) {
            return;
        }
        this.f23367h0 = sVar;
        d();
    }

    public void setStartIconCheckable(boolean z10) {
        this.f23354b.f23474c.setCheckable(z10);
    }

    public void setStartIconContentDescription(@StringRes int i10) {
        setStartIconContentDescription(i10 != 0 ? getResources().getText(i10) : null);
    }

    public void setStartIconDrawable(@DrawableRes int i10) {
        setStartIconDrawable(i10 != 0 ? f.a.getDrawable(getContext(), i10) : null);
    }

    public void setStartIconMinSize(@IntRange(from = 0) int i10) {
        v vVar = this.f23354b;
        if (i10 < 0) {
            vVar.getClass();
            throw new IllegalArgumentException("startIconSize cannot be less than 0");
        }
        if (i10 != vVar.f23477f) {
            vVar.f23477f = i10;
            CheckableImageButton checkableImageButton = vVar.f23474c;
            checkableImageButton.setMinimumWidth(i10);
            checkableImageButton.setMinimumHeight(i10);
        }
    }

    public void setStartIconOnClickListener(@Nullable View.OnClickListener onClickListener) {
        this.f23354b.setStartIconOnClickListener(onClickListener);
    }

    public void setStartIconOnLongClickListener(@Nullable View.OnLongClickListener onLongClickListener) {
        this.f23354b.setStartIconOnLongClickListener(onLongClickListener);
    }

    public void setStartIconScaleType(@NonNull ImageView.ScaleType scaleType) {
        v vVar = this.f23354b;
        vVar.f23478g = scaleType;
        vVar.f23474c.setScaleType(scaleType);
    }

    public void setStartIconTintList(@Nullable ColorStateList colorStateList) {
        this.f23354b.setStartIconTintList(colorStateList);
    }

    public void setStartIconTintMode(@Nullable PorterDuff.Mode mode) {
        this.f23354b.setStartIconTintMode(mode);
    }

    public void setStartIconVisible(boolean z10) {
        this.f23354b.b(z10);
    }

    public void setSuffixText(@Nullable CharSequence charSequence) {
        this.f23356c.setSuffixText(charSequence);
    }

    public void setSuffixTextAppearance(@StyleRes int i10) {
        this.f23356c.S.setTextAppearance(i10);
    }

    public void setSuffixTextColor(@NonNull ColorStateList colorStateList) {
        this.f23356c.S.setTextColor(colorStateList);
    }

    public void setTextInputAccessibilityDelegate(@Nullable y yVar) {
        EditText editText = this.f23360e;
        if (editText != null) {
            s1.setAccessibilityDelegate(editText, yVar);
        }
    }

    public void setTypeface(@Nullable Typeface typeface) {
        if (typeface != this.f23385u0) {
            this.f23385u0 = typeface;
            com.google.android.material.internal.e eVar = this.M0;
            boolean zS = eVar.s(typeface);
            boolean zY = eVar.y(typeface);
            if (zS || zY) {
                eVar.l(false);
            }
            this.f23372k.p(typeface);
            TextView textView = this.counterView;
            if (textView != null) {
                textView.setTypeface(typeface);
            }
        }
    }

    public final void t() {
        EditText editText = this.f23360e;
        if (editText == null || this.boxBackground == null) {
            return;
        }
        if ((this.f23365g0 || editText.getBackground() == null) && this.f23373k0 != 0) {
            this.f23360e.setBackground(getEditTextBoxBackground());
            this.f23365g0 = true;
        }
    }

    public final void u() {
        if (this.f23373k0 != 1) {
            FrameLayout frameLayout = this.f23352a;
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
            int iF = f();
            if (iF != layoutParams.topMargin) {
                layoutParams.topMargin = iF;
                frameLayout.requestLayout();
            }
        }
    }

    public void updateCounter(@Nullable Editable editable) {
        int iCountLength = ((c7.g) this.R).countLength(editable);
        boolean z10 = this.Q;
        int i10 = this.f23376m;
        String string = null;
        if (i10 == -1) {
            this.counterView.setText(String.valueOf(iCountLength));
            this.counterView.setContentDescription(null);
            this.Q = false;
        } else {
            this.Q = iCountLength > i10;
            Context context = getContext();
            this.counterView.setContentDescription(context.getString(this.Q ? x8.k.character_counter_overflowed_content_description : x8.k.character_counter_content_description, Integer.valueOf(iCountLength), Integer.valueOf(this.f23376m)));
            if (z10 != this.Q) {
                p();
            }
            o0.b bVarC = o0.b.c();
            TextView textView = this.counterView;
            String string2 = getContext().getString(x8.k.character_counter_pattern, Integer.valueOf(iCountLength), Integer.valueOf(this.f23376m));
            if (string2 == null) {
                bVarC.getClass();
            } else {
                string = bVarC.d(string2, bVarC.f31264c).toString();
            }
            textView.setText(string);
        }
        if (this.f23360e == null || z10 == this.Q) {
            return;
        }
        v(false, false);
        x();
        s();
    }

    public final void v(boolean z10, boolean z11) {
        ColorStateList colorStateList;
        TextView textView;
        boolean zIsEnabled = isEnabled();
        EditText editText = this.f23360e;
        boolean z12 = (editText == null || TextUtils.isEmpty(editText.getText())) ? false : true;
        EditText editText2 = this.f23360e;
        boolean z13 = editText2 != null && editText2.hasFocus();
        ColorStateList colorStateList2 = this.z0;
        com.google.android.material.internal.e eVar = this.M0;
        if (colorStateList2 != null) {
            eVar.setCollapsedAndExpandedTextColor(colorStateList2);
        }
        if (zIsEnabled) {
            s sVar = this.f23372k;
            if (sVar.f()) {
                eVar.setCollapsedAndExpandedTextColor(sVar.getErrorViewTextColors());
            } else if (this.Q && (textView = this.counterView) != null) {
                eVar.setCollapsedAndExpandedTextColor(textView.getTextColors());
            } else if (z13 && (colorStateList = this.A0) != null) {
                eVar.q(colorStateList);
            }
        } else {
            ColorStateList colorStateList3 = this.z0;
            eVar.setCollapsedAndExpandedTextColor(ColorStateList.valueOf(colorStateList3 != null ? colorStateList3.getColorForState(new int[]{-16842910}, this.J0) : this.J0));
        }
        o oVar = this.f23356c;
        v vVar = this.f23354b;
        if (z12 || !this.N0 || (isEnabled() && z13)) {
            if (z11 || this.L0) {
                ValueAnimator valueAnimator = this.P0;
                if (valueAnimator != null && valueAnimator.isRunning()) {
                    this.P0.cancel();
                }
                if (z10 && this.O0) {
                    c(1.0f);
                } else {
                    eVar.z(1.0f);
                }
                this.L0 = false;
                if (h()) {
                    m();
                }
                EditText editText3 = this.f23360e;
                updatePlaceholderText(editText3 != null ? editText3.getText() : null);
                vVar.f23480i = false;
                vVar.d();
                oVar.T = false;
                oVar.o();
                return;
            }
            return;
        }
        if (z11 || !this.L0) {
            ValueAnimator valueAnimator2 = this.P0;
            if (valueAnimator2 != null && valueAnimator2.isRunning()) {
                this.P0.cancel();
            }
            if (z10 && this.O0) {
                c(0.0f);
            } else {
                eVar.z(0.0f);
            }
            if (h() && (!((i) this.boxBackground).f23409e0.f23408o.isEmpty()) && h()) {
                ((i) this.boxBackground).I(0.0f, 0.0f, 0.0f, 0.0f);
            }
            this.L0 = true;
            AppCompatTextView appCompatTextView = this.W;
            if (appCompatTextView != null && this.V) {
                appCompatTextView.setText((CharSequence) null);
                d0.beginDelayedTransition(this.f23352a, this.placeholderFadeOut);
                this.W.setVisibility(4);
            }
            vVar.f23480i = true;
            vVar.d();
            oVar.T = true;
            oVar.o();
        }
    }

    public final void w(boolean z10, boolean z11) {
        int defaultColor = this.E0.getDefaultColor();
        int colorForState = this.E0.getColorForState(new int[]{R.attr.state_hovered, R.attr.state_enabled}, defaultColor);
        int colorForState2 = this.E0.getColorForState(new int[]{R.attr.state_activated, R.attr.state_enabled}, defaultColor);
        if (z10) {
            this.f23380p0 = colorForState2;
        } else if (z11) {
            this.f23380p0 = colorForState;
        } else {
            this.f23380p0 = defaultColor;
        }
    }

    public final void x() {
        TextView textView;
        EditText editText;
        EditText editText2;
        if (this.boxBackground == null || this.f23373k0 == 0) {
            return;
        }
        boolean z10 = false;
        boolean z11 = isFocused() || ((editText2 = this.f23360e) != null && editText2.hasFocus());
        if (isHovered() || ((editText = this.f23360e) != null && editText.isHovered())) {
            z10 = true;
        }
        if (!isEnabled()) {
            this.f23380p0 = this.J0;
        } else if (this.f23372k.f()) {
            if (this.E0 != null) {
                w(z11, z10);
            } else {
                this.f23380p0 = getErrorCurrentTextColors();
            }
        } else if (!this.Q || (textView = this.counterView) == null) {
            if (z11) {
                this.f23380p0 = this.D0;
            } else if (z10) {
                this.f23380p0 = this.C0;
            } else {
                this.f23380p0 = this.B0;
            }
        } else if (this.E0 != null) {
            w(z11, z10);
        } else {
            this.f23380p0 = textView.getCurrentTextColor();
        }
        if (Build.VERSION.SDK_INT >= 29) {
            q();
        }
        o oVar = this.f23356c;
        oVar.m();
        CheckableImageButton checkableImageButton = oVar.f23428c;
        ColorStateList colorStateList = oVar.f23429d;
        TextInputLayout textInputLayout = oVar.f23426a;
        q.c(textInputLayout, checkableImageButton, colorStateList);
        ColorStateList colorStateList2 = oVar.f23436k;
        CheckableImageButton checkableImageButton2 = oVar.f23432g;
        q.c(textInputLayout, checkableImageButton2, colorStateList2);
        if (oVar.c() instanceof l) {
            if (!textInputLayout.f23372k.f() || oVar.getEndIconDrawable() == null) {
                q.a(textInputLayout, checkableImageButton2, oVar.f23436k, oVar.f23437l);
            } else {
                Drawable drawableMutate = oVar.getEndIconDrawable().mutate();
                drawableMutate.setTint(textInputLayout.getErrorCurrentTextColors());
                checkableImageButton2.setImageDrawable(drawableMutate);
            }
        }
        v vVar = this.f23354b;
        q.c(vVar.f23472a, vVar.f23474c, vVar.f23475d);
        if (this.f23373k0 == 2) {
            int i10 = this.f23377m0;
            if (z11 && isEnabled()) {
                this.f23377m0 = this.f23379o0;
            } else {
                this.f23377m0 = this.f23378n0;
            }
            if (this.f23377m0 != i10 && h() && !this.L0) {
                if (h()) {
                    ((i) this.boxBackground).I(0.0f, 0.0f, 0.0f, 0.0f);
                }
                m();
            }
        }
        if (this.f23373k0 == 1) {
            if (!isEnabled()) {
                this.f23381q0 = this.G0;
            } else if (z10 && !z11) {
                this.f23381q0 = this.I0;
            } else if (z11) {
                this.f23381q0 = this.H0;
            } else {
                this.f23381q0 = this.F0;
            }
        }
        d();
    }

    public TextInputLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, x8.c.textInputStyle);
    }

    public void setStartIconContentDescription(@Nullable CharSequence charSequence) {
        this.f23354b.setStartIconContentDescription(charSequence);
    }

    public void setStartIconDrawable(@Nullable Drawable drawable) {
        this.f23354b.setStartIconDrawable(drawable);
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public TextInputLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        int i11 = T0;
        super(x9.a.wrap(context, attributeSet, i10, i11), attributeSet, i10);
        this.f23364g = -1;
        this.f23366h = -1;
        this.f23368i = -1;
        this.f23370j = -1;
        this.f23372k = new s(this);
        this.R = new c7.g(13);
        this.f23382r0 = new Rect();
        this.f23383s0 = new Rect();
        this.f23384t0 = new RectF();
        this.f23387w0 = new LinkedHashSet();
        com.google.android.material.internal.e eVar = new com.google.android.material.internal.e(this);
        this.M0 = eVar;
        this.S0 = false;
        Context context2 = getContext();
        setOrientation(1);
        setWillNotDraw(false);
        setAddStatesFromChildren(true);
        FrameLayout frameLayout = new FrameLayout(context2);
        this.f23352a = frameLayout;
        frameLayout.setAddStatesFromChildren(true);
        LinearInterpolator linearInterpolator = y8.a.f36864a;
        eVar.U = linearInterpolator;
        eVar.l(false);
        eVar.T = linearInterpolator;
        eVar.l(false);
        eVar.r(8388659);
        int[] iArr = x8.m.TextInputLayout;
        int i12 = x8.m.TextInputLayout_counterTextAppearance;
        int i13 = x8.m.TextInputLayout_counterOverflowTextAppearance;
        int i14 = x8.m.TextInputLayout_errorTextAppearance;
        int i15 = x8.m.TextInputLayout_helperTextTextAppearance;
        int i16 = x8.m.TextInputLayout_hintTextAppearance;
        p3 p3VarD = q0.d(context2, attributeSet, iArr, i10, i11, i12, i13, i14, i15, i16);
        v vVar = new v(this, p3VarD);
        this.f23354b = vVar;
        int i17 = x8.m.TextInputLayout_hintEnabled;
        TypedArray typedArray = p3VarD.f29809b;
        this.f23355b0 = typedArray.getBoolean(i17, true);
        setHint(typedArray.getText(x8.m.TextInputLayout_android_hint));
        this.O0 = typedArray.getBoolean(x8.m.TextInputLayout_hintAnimationEnabled, true);
        this.N0 = typedArray.getBoolean(x8.m.TextInputLayout_expandedHintEnabled, true);
        int i18 = x8.m.TextInputLayout_android_minEms;
        if (typedArray.hasValue(i18)) {
            setMinEms(typedArray.getInt(i18, -1));
        } else {
            int i19 = x8.m.TextInputLayout_android_minWidth;
            if (typedArray.hasValue(i19)) {
                setMinWidth(typedArray.getDimensionPixelSize(i19, -1));
            }
        }
        int i20 = x8.m.TextInputLayout_android_maxEms;
        if (typedArray.hasValue(i20)) {
            setMaxEms(typedArray.getInt(i20, -1));
        } else {
            int i21 = x8.m.TextInputLayout_android_maxWidth;
            if (typedArray.hasValue(i21)) {
                setMaxWidth(typedArray.getDimensionPixelSize(i21, -1));
            }
        }
        this.f23367h0 = com.google.android.material.shape.s.c(context2, attributeSet, i10, i11).a();
        this.f23371j0 = context2.getResources().getDimensionPixelOffset(x8.e.mtrl_textinput_box_label_cutout_padding);
        this.f23375l0 = typedArray.getDimensionPixelOffset(x8.m.TextInputLayout_boxCollapsedPaddingTop, 0);
        this.f23358d = getResources().getDimensionPixelSize(x8.e.m3_multiline_hint_filled_text_extra_space);
        this.f23378n0 = typedArray.getDimensionPixelSize(x8.m.TextInputLayout_boxStrokeWidth, context2.getResources().getDimensionPixelSize(x8.e.mtrl_textinput_box_stroke_width_default));
        this.f23379o0 = typedArray.getDimensionPixelSize(x8.m.TextInputLayout_boxStrokeWidthFocused, context2.getResources().getDimensionPixelSize(x8.e.mtrl_textinput_box_stroke_width_focused));
        this.f23377m0 = this.f23378n0;
        float dimension = typedArray.getDimension(x8.m.TextInputLayout_boxCornerRadiusTopStart, -1.0f);
        float dimension2 = typedArray.getDimension(x8.m.TextInputLayout_boxCornerRadiusTopEnd, -1.0f);
        float dimension3 = typedArray.getDimension(x8.m.TextInputLayout_boxCornerRadiusBottomEnd, -1.0f);
        float dimension4 = typedArray.getDimension(x8.m.TextInputLayout_boxCornerRadiusBottomStart, -1.0f);
        com.google.android.material.shape.q qVarH = this.f23367h0.h();
        if (dimension >= 0.0f) {
            qVarH.f(dimension);
        }
        if (dimension2 >= 0.0f) {
            qVarH.g(dimension2);
        }
        if (dimension3 >= 0.0f) {
            qVarH.e(dimension3);
        }
        if (dimension4 >= 0.0f) {
            qVarH.d(dimension4);
        }
        this.f23367h0 = qVarH.a();
        ColorStateList colorStateList = q9.d.getColorStateList(context2, p3VarD, x8.m.TextInputLayout_boxBackgroundColor);
        if (colorStateList != null) {
            int defaultColor = colorStateList.getDefaultColor();
            this.F0 = defaultColor;
            this.f23381q0 = defaultColor;
            if (colorStateList.isStateful()) {
                this.G0 = colorStateList.getColorForState(new int[]{-16842910}, -1);
                this.H0 = colorStateList.getColorForState(new int[]{R.attr.state_focused, R.attr.state_enabled}, -1);
                this.I0 = colorStateList.getColorForState(new int[]{R.attr.state_hovered, R.attr.state_enabled}, -1);
            } else {
                this.H0 = this.F0;
                ColorStateList colorStateList2 = g0.d.getColorStateList(context2, x8.d.mtrl_filled_background_color);
                this.G0 = colorStateList2.getColorForState(new int[]{-16842910}, -1);
                this.I0 = colorStateList2.getColorForState(new int[]{R.attr.state_hovered}, -1);
            }
        } else {
            this.f23381q0 = 0;
            this.F0 = 0;
            this.G0 = 0;
            this.H0 = 0;
            this.I0 = 0;
        }
        int i22 = x8.m.TextInputLayout_android_textColorHint;
        if (typedArray.hasValue(i22)) {
            ColorStateList colorStateListA = p3VarD.a(i22);
            this.A0 = colorStateListA;
            this.z0 = colorStateListA;
        }
        int i23 = x8.m.TextInputLayout_boxStrokeColor;
        ColorStateList colorStateList3 = q9.d.getColorStateList(context2, p3VarD, i23);
        this.D0 = typedArray.getColor(i23, 0);
        int i24 = x8.d.mtrl_textinput_default_box_stroke_color;
        Object obj = g0.d.f26125a;
        this.B0 = context2.getColor(i24);
        this.J0 = context2.getColor(x8.d.mtrl_textinput_disabled_color);
        this.C0 = context2.getColor(x8.d.mtrl_textinput_hovered_box_stroke_color);
        if (colorStateList3 != null) {
            setBoxStrokeColorStateList(colorStateList3);
        }
        int i25 = x8.m.TextInputLayout_boxStrokeErrorColor;
        if (typedArray.hasValue(i25)) {
            setBoxStrokeErrorColor(q9.d.getColorStateList(context2, p3VarD, i25));
        }
        if (typedArray.getResourceId(i16, -1) != -1) {
            setHintTextAppearance(typedArray.getResourceId(i16, 0));
        }
        this.cursorColor = p3VarD.a(x8.m.TextInputLayout_cursorColor);
        this.cursorErrorColor = p3VarD.a(x8.m.TextInputLayout_cursorErrorColor);
        int resourceId = typedArray.getResourceId(i14, 0);
        CharSequence text = typedArray.getText(x8.m.TextInputLayout_errorContentDescription);
        int i26 = typedArray.getInt(x8.m.TextInputLayout_errorAccessibilityLiveRegion, 1);
        boolean z10 = typedArray.getBoolean(x8.m.TextInputLayout_errorEnabled, false);
        int resourceId2 = typedArray.getResourceId(i15, 0);
        boolean z11 = typedArray.getBoolean(x8.m.TextInputLayout_helperTextEnabled, false);
        CharSequence text2 = typedArray.getText(x8.m.TextInputLayout_helperText);
        int resourceId3 = typedArray.getResourceId(x8.m.TextInputLayout_placeholderTextAppearance, 0);
        CharSequence text3 = typedArray.getText(x8.m.TextInputLayout_placeholderText);
        boolean z12 = typedArray.getBoolean(x8.m.TextInputLayout_counterEnabled, false);
        setCounterMaxLength(typedArray.getInt(x8.m.TextInputLayout_counterMaxLength, -1));
        this.T = typedArray.getResourceId(i12, 0);
        this.S = typedArray.getResourceId(i13, 0);
        setBoxBackgroundMode(typedArray.getInt(x8.m.TextInputLayout_boxBackgroundMode, 0));
        setErrorContentDescription(text);
        setErrorAccessibilityLiveRegion(i26);
        setCounterOverflowTextAppearance(this.S);
        setHelperTextTextAppearance(resourceId2);
        setErrorTextAppearance(resourceId);
        setCounterTextAppearance(this.T);
        setPlaceholderText(text3);
        setPlaceholderTextAppearance(resourceId3);
        int i27 = x8.m.TextInputLayout_errorTextColor;
        if (typedArray.hasValue(i27)) {
            setErrorTextColor(p3VarD.a(i27));
        }
        int i28 = x8.m.TextInputLayout_helperTextTextColor;
        if (typedArray.hasValue(i28)) {
            setHelperTextColor(p3VarD.a(i28));
        }
        int i29 = x8.m.TextInputLayout_hintTextColor;
        if (typedArray.hasValue(i29)) {
            setHintTextColor(p3VarD.a(i29));
        }
        int i30 = x8.m.TextInputLayout_counterTextColor;
        if (typedArray.hasValue(i30)) {
            setCounterTextColor(p3VarD.a(i30));
        }
        int i31 = x8.m.TextInputLayout_counterOverflowTextColor;
        if (typedArray.hasValue(i31)) {
            setCounterOverflowTextColor(p3VarD.a(i31));
        }
        int i32 = x8.m.TextInputLayout_placeholderTextColor;
        if (typedArray.hasValue(i32)) {
            setPlaceholderTextColor(p3VarD.a(i32));
        }
        o oVar = new o(this, p3VarD);
        this.f23356c = oVar;
        boolean z13 = typedArray.getBoolean(x8.m.TextInputLayout_android_enabled, true);
        setHintMaxLines(typedArray.getInt(x8.m.TextInputLayout_hintMaxLines, 1));
        p3VarD.e();
        setImportantForAccessibility(2);
        if (Build.VERSION.SDK_INT >= 26) {
            setImportantForAutofill(1);
        }
        frameLayout.addView(vVar);
        frameLayout.addView(oVar);
        addView(frameLayout);
        setEnabled(z13);
        setHelperTextEnabled(z11);
        setErrorEnabled(z10);
        setCounterEnabled(z12);
        setHelperText(text2);
    }

    public void setHint(@StringRes int i10) {
        setHint(i10 != 0 ? getResources().getText(i10) : null);
    }

    public void setEndIconContentDescription(@Nullable CharSequence charSequence) {
        this.f23356c.setEndIconContentDescription(charSequence);
    }

    public void setEndIconDrawable(@Nullable Drawable drawable) {
        this.f23356c.setEndIconDrawable(drawable);
    }

    @Deprecated
    public void setPasswordVisibilityToggleContentDescription(@Nullable CharSequence charSequence) {
        this.f23356c.setPasswordVisibilityToggleContentDescription(charSequence);
    }

    @Deprecated
    public void setPasswordVisibilityToggleDrawable(@Nullable Drawable drawable) {
        this.f23356c.setPasswordVisibilityToggleDrawable(drawable);
    }

    public void setErrorIconDrawable(@Nullable Drawable drawable) {
        this.f23356c.setErrorIconDrawable(drawable);
    }
}
