package o;

import android.os.Build;
import android.text.TextUtils;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.EditText;
import com.google.android.material.textfield.TextInputLayout;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Be0 extends C2011o0 {
    public final TextInputLayout d;

    public Be0(TextInputLayout textInputLayout) {
        this.d = textInputLayout;
    }

    @Override // o.C2011o0
    public final void d(View view, H0 h0) {
        AccessibilityNodeInfo accessibilityNodeInfo = h0.a;
        this.a.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfo);
        TextInputLayout textInputLayout = this.d;
        EditText editText = textInputLayout.getEditText();
        CharSequence text = editText != null ? editText.getText() : null;
        CharSequence hint = textInputLayout.getHint();
        CharSequence error = textInputLayout.getError();
        CharSequence placeholderText = textInputLayout.getPlaceholderText();
        int counterMaxLength = textInputLayout.getCounterMaxLength();
        CharSequence counterOverflowDescription = textInputLayout.getCounterOverflowDescription();
        boolean zIsEmpty = TextUtils.isEmpty(text);
        boolean zIsEmpty2 = TextUtils.isEmpty(hint);
        boolean z = textInputLayout.F0;
        boolean zIsEmpty3 = TextUtils.isEmpty(error);
        boolean z2 = (zIsEmpty3 && TextUtils.isEmpty(counterOverflowDescription)) ? false : true;
        String string = !zIsEmpty2 ? hint.toString() : "";
        C2342ra0 c2342ra0 = textInputLayout.m;
        E8 e8 = c2342ra0.m;
        if (e8.getVisibility() == 0) {
            accessibilityNodeInfo.setLabelFor(e8);
            accessibilityNodeInfo.setTraversalAfter(e8);
        } else {
            accessibilityNodeInfo.setTraversalAfter(c2342ra0.f702o);
        }
        if (!zIsEmpty) {
            h0.n(text);
        } else if (!TextUtils.isEmpty(string)) {
            h0.n(string);
            if (!z && placeholderText != null) {
                h0.n(string + ", " + ((Object) placeholderText));
            }
        } else if (placeholderText != null) {
            h0.n(placeholderText);
        }
        if (!TextUtils.isEmpty(string)) {
            int i = Build.VERSION.SDK_INT;
            if (i >= 26) {
                h0.l(string);
            } else {
                if (!zIsEmpty) {
                    string = ((Object) text) + ", " + string;
                }
                h0.n(string);
            }
            if (i >= 26) {
                accessibilityNodeInfo.setShowingHintText(zIsEmpty);
            } else {
                h0.h(4, zIsEmpty);
            }
        }
        if (text == null || text.length() != counterMaxLength) {
            counterMaxLength = -1;
        }
        accessibilityNodeInfo.setMaxTextLength(counterMaxLength);
        if (z2) {
            if (zIsEmpty3) {
                error = counterOverflowDescription;
            }
            accessibilityNodeInfo.setError(error);
        }
        E8 e82 = textInputLayout.u.y;
        if (e82 != null) {
            accessibilityNodeInfo.setLabelFor(e82);
        }
        textInputLayout.n.b().m(h0);
    }

    @Override // o.C2011o0
    public final void e(View view, AccessibilityEvent accessibilityEvent) {
        super.e(view, accessibilityEvent);
        this.d.n.b().n(accessibilityEvent);
    }
}
