package l2;

import P.Q;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.textfield.TextInputLayout;
import com.riyaz.zvytour.R;
import e4.AbstractC0566j;
import java.lang.reflect.Field;
import m.C0840I;

/* JADX INFO: loaded from: classes.dex */
public final class u extends LinearLayout {

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final C0840I f8890l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final CheckableImageButton f8892n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ColorStateList f8893o;
    public PorterDuff.Mode p;
    public int q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public ImageView.ScaleType f8894r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public View.OnLongClickListener f8895s;

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

    public u(TextInputLayout textInputLayout, B2.a aVar) {
        CharSequence text;
        super(textInputLayout.getContext());
        this.f8889k = textInputLayout;
        setVisibility(8);
        setOrientation(0);
        setLayoutParams(new FrameLayout.LayoutParams(-2, -1, 8388611));
        CheckableImageButton checkableImageButton = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(R.layout.design_text_input_start_icon, (ViewGroup) this, false);
        this.f8892n = checkableImageButton;
        C0840I c0840i = new C0840I(getContext(), null);
        this.f8890l = c0840i;
        if (S4.m.s(getContext())) {
            ((ViewGroup.MarginLayoutParams) checkableImageButton.getLayoutParams()).setMarginEnd(0);
        }
        View.OnLongClickListener onLongClickListener = this.f8895s;
        checkableImageButton.setOnClickListener(null);
        AbstractC0566j.x(checkableImageButton, onLongClickListener);
        this.f8895s = null;
        checkableImageButton.setOnLongClickListener(null);
        AbstractC0566j.x(checkableImageButton, null);
        TypedArray typedArray = (TypedArray) aVar.f136n;
        if (typedArray.hasValue(67)) {
            this.f8893o = S4.m.i(getContext(), aVar, 67);
        }
        if (typedArray.hasValue(68)) {
            this.p = d2.k.f(typedArray.getInt(68, -1), null);
        }
        if (typedArray.hasValue(64)) {
            a(aVar.t(64));
            if (typedArray.hasValue(63) && checkableImageButton.getContentDescription() != (text = typedArray.getText(63))) {
                checkableImageButton.setContentDescription(text);
            }
            checkableImageButton.setCheckable(typedArray.getBoolean(62, true));
        }
        int dimensionPixelSize = typedArray.getDimensionPixelSize(65, getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size));
        if (dimensionPixelSize < 0) {
            throw new IllegalArgumentException("startIconSize cannot be less than 0");
        }
        if (dimensionPixelSize != this.q) {
            this.q = dimensionPixelSize;
            checkableImageButton.setMinimumWidth(dimensionPixelSize);
            checkableImageButton.setMinimumHeight(dimensionPixelSize);
        }
        if (typedArray.hasValue(66)) {
            ImageView.ScaleType scaleTypeH = AbstractC0566j.h(typedArray.getInt(66, -1));
            this.f8894r = scaleTypeH;
            checkableImageButton.setScaleType(scaleTypeH);
        }
        c0840i.setVisibility(8);
        c0840i.setId(R.id.textinput_prefix_text);
        c0840i.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
        Field field = Q.f2392a;
        c0840i.setAccessibilityLiveRegion(1);
        c0840i.setTextAppearance(typedArray.getResourceId(58, 0));
        if (typedArray.hasValue(59)) {
            c0840i.setTextColor(aVar.s(59));
        }
        CharSequence text2 = typedArray.getText(57);
        this.f8891m = TextUtils.isEmpty(text2) ? null : text2;
        c0840i.setText(text2);
        d();
        addView(checkableImageButton);
        addView(c0840i);
    }

    public final void a(Drawable drawable) {
        CheckableImageButton checkableImageButton = this.f8892n;
        checkableImageButton.setImageDrawable(drawable);
        if (drawable != null) {
            ColorStateList colorStateList = this.f8893o;
            PorterDuff.Mode mode = this.p;
            TextInputLayout textInputLayout = this.f8889k;
            AbstractC0566j.b(textInputLayout, checkableImageButton, colorStateList, mode);
            b(true);
            AbstractC0566j.v(textInputLayout, checkableImageButton, this.f8893o);
            return;
        }
        b(false);
        View.OnLongClickListener onLongClickListener = this.f8895s;
        checkableImageButton.setOnClickListener(null);
        AbstractC0566j.x(checkableImageButton, onLongClickListener);
        this.f8895s = null;
        checkableImageButton.setOnLongClickListener(null);
        AbstractC0566j.x(checkableImageButton, null);
        if (checkableImageButton.getContentDescription() != null) {
            checkableImageButton.setContentDescription(null);
        }
    }

    public final void b(boolean z5) {
        CheckableImageButton checkableImageButton = this.f8892n;
        if ((checkableImageButton.getVisibility() == 0) != z5) {
            checkableImageButton.setVisibility(z5 ? 0 : 8);
            c();
            d();
        }
    }

    public final void c() {
        int paddingStart;
        EditText editText = this.f8889k.f5629n;
        if (editText == null) {
            return;
        }
        if (this.f8892n.getVisibility() == 0) {
            paddingStart = 0;
        } else {
            Field field = Q.f2392a;
            paddingStart = editText.getPaddingStart();
        }
        int compoundPaddingTop = editText.getCompoundPaddingTop();
        int dimensionPixelSize = getContext().getResources().getDimensionPixelSize(R.dimen.material_input_text_to_prefix_suffix_padding);
        int compoundPaddingBottom = editText.getCompoundPaddingBottom();
        Field field2 = Q.f2392a;
        this.f8890l.setPaddingRelative(paddingStart, compoundPaddingTop, dimensionPixelSize, compoundPaddingBottom);
    }

    public final void d() {
        int i = (this.f8891m == null || this.f8896t) ? 8 : 0;
        setVisibility((this.f8892n.getVisibility() == 0 || i == 0) ? 0 : 8);
        this.f8890l.setVisibility(i);
        this.f8889k.p();
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onMeasure(int i, int i5) {
        super.onMeasure(i, i5);
        c();
    }
}
