package z3;

import M.J;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.util.Property;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.material.textfield.TextInputLayout;
import com.martsnew.tv.R;
import i3.AbstractC1051a;
import java.lang.reflect.Field;
import java.util.ArrayList;
import n.C1190H;

/* JADX INFO: loaded from: classes.dex */
public final class o {

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

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final float f19330g;

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

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

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

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

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

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ColorStateList f19337o;

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

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public C1190H f19340r;

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

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

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

    public o(TextInputLayout textInputLayout) {
        this.f19324a = textInputLayout.getContext();
        this.f19325b = textInputLayout;
        this.f19330g = r0.getResources().getDimensionPixelSize(R.dimen.design_textinput_caption_translate_y);
    }

    public final void a(C1190H c1190h, int i) {
        if (this.f19326c == null && this.f19328e == null) {
            Context context = this.f19324a;
            LinearLayout linearLayout = new LinearLayout(context);
            this.f19326c = linearLayout;
            linearLayout.setOrientation(0);
            LinearLayout linearLayout2 = this.f19326c;
            TextInputLayout textInputLayout = this.f19325b;
            textInputLayout.addView(linearLayout2, -1, -2);
            this.f19328e = new FrameLayout(context);
            this.f19326c.addView(this.f19328e, new LinearLayout.LayoutParams(0, -2, 1.0f));
            if (textInputLayout.getEditText() != null) {
                b();
            }
        }
        if (i == 0 || i == 1) {
            this.f19328e.setVisibility(0);
            this.f19328e.addView(c1190h);
        } else {
            this.f19326c.addView(c1190h, new LinearLayout.LayoutParams(-2, -2));
        }
        this.f19326c.setVisibility(0);
        this.f19327d++;
    }

    public final void b() {
        if (this.f19326c != null) {
            TextInputLayout textInputLayout = this.f19325b;
            if (textInputLayout.getEditText() != null) {
                EditText editText = textInputLayout.getEditText();
                Context context = this.f19324a;
                boolean zX = s7.d.x(context);
                LinearLayout linearLayout = this.f19326c;
                Field field = J.f4065a;
                int paddingStart = editText.getPaddingStart();
                if (zX) {
                    paddingStart = context.getResources().getDimensionPixelSize(R.dimen.material_helper_text_font_1_3_padding_horizontal);
                }
                int dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.material_helper_text_default_padding_top);
                if (zX) {
                    dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.material_helper_text_font_1_3_padding_top);
                }
                int paddingEnd = editText.getPaddingEnd();
                if (zX) {
                    paddingEnd = context.getResources().getDimensionPixelSize(R.dimen.material_helper_text_font_1_3_padding_horizontal);
                }
                linearLayout.setPaddingRelative(paddingStart, dimensionPixelSize, paddingEnd, 0);
            }
        }
    }

    public final void c() {
        AnimatorSet animatorSet = this.f19329f;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
    }

    public final void d(ArrayList arrayList, boolean z8, C1190H c1190h, int i, int i5, int i8) {
        if (c1190h == null || !z8) {
            return;
        }
        if (i == i8 || i == i5) {
            ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(c1190h, (Property<C1190H, Float>) View.ALPHA, i8 == i ? 1.0f : 0.0f);
            objectAnimatorOfFloat.setDuration(167L);
            objectAnimatorOfFloat.setInterpolator(AbstractC1051a.f13505a);
            arrayList.add(objectAnimatorOfFloat);
            if (i8 == i) {
                ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(c1190h, (Property<C1190H, Float>) View.TRANSLATION_Y, -this.f19330g, 0.0f);
                objectAnimatorOfFloat2.setDuration(217L);
                objectAnimatorOfFloat2.setInterpolator(AbstractC1051a.f13508d);
                arrayList.add(objectAnimatorOfFloat2);
            }
        }
    }

    public final boolean e() {
        return (this.i != 1 || this.f19334l == null || TextUtils.isEmpty(this.f19332j)) ? false : true;
    }

    public final TextView f(int i) {
        if (i == 1) {
            return this.f19334l;
        }
        if (i != 2) {
            return null;
        }
        return this.f19340r;
    }

    public final void g() {
        this.f19332j = null;
        c();
        if (this.f19331h == 1) {
            if (!this.f19339q || TextUtils.isEmpty(this.f19338p)) {
                this.i = 0;
            } else {
                this.i = 2;
            }
        }
        j(this.f19331h, this.i, i(this.f19334l, null));
    }

    public final void h(C1190H c1190h, int i) {
        FrameLayout frameLayout;
        LinearLayout linearLayout = this.f19326c;
        if (linearLayout == null) {
            return;
        }
        if ((i == 0 || i == 1) && (frameLayout = this.f19328e) != null) {
            frameLayout.removeView(c1190h);
        } else {
            linearLayout.removeView(c1190h);
        }
        int i5 = this.f19327d - 1;
        this.f19327d = i5;
        LinearLayout linearLayout2 = this.f19326c;
        if (i5 == 0) {
            linearLayout2.setVisibility(8);
        }
    }

    public final boolean i(C1190H c1190h, CharSequence charSequence) {
        Field field = J.f4065a;
        TextInputLayout textInputLayout = this.f19325b;
        if (textInputLayout.isLaidOut() && textInputLayout.isEnabled()) {
            return (this.i == this.f19331h && c1190h != null && TextUtils.equals(c1190h.getText(), charSequence)) ? false : true;
        }
        return false;
    }

    public final void j(int i, int i5, boolean z8) {
        TextView textViewF;
        TextView textViewF2;
        o oVar = this;
        if (i == i5) {
            return;
        }
        if (z8) {
            AnimatorSet animatorSet = new AnimatorSet();
            oVar.f19329f = animatorSet;
            ArrayList arrayList = new ArrayList();
            oVar.d(arrayList, oVar.f19339q, oVar.f19340r, 2, i, i5);
            oVar.d(arrayList, oVar.f19333k, oVar.f19334l, 1, i, i5);
            int size = arrayList.size();
            long jMax = 0;
            for (int i8 = 0; i8 < size; i8++) {
                Animator animator = (Animator) arrayList.get(i8);
                jMax = Math.max(jMax, animator.getDuration() + animator.getStartDelay());
            }
            ValueAnimator valueAnimatorOfInt = ValueAnimator.ofInt(0, 0);
            valueAnimatorOfInt.setDuration(jMax);
            arrayList.add(0, valueAnimatorOfInt);
            animatorSet.playTogether(arrayList);
            n nVar = new n(this, i5, f(i), i, oVar.f(i5));
            oVar = this;
            animatorSet.addListener(nVar);
            animatorSet.start();
        } else if (i != i5) {
            if (i5 != 0 && (textViewF2 = oVar.f(i5)) != null) {
                textViewF2.setVisibility(0);
                textViewF2.setAlpha(1.0f);
            }
            if (i != 0 && (textViewF = f(i)) != null) {
                textViewF.setVisibility(4);
                if (i == 1) {
                    textViewF.setText((CharSequence) null);
                }
            }
            oVar.f19331h = i5;
        }
        TextInputLayout textInputLayout = oVar.f19325b;
        textInputLayout.q();
        textInputLayout.s(z8, false);
        textInputLayout.z();
    }
}
