package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.a0;
import androidx.core.view.c0;
import androidx.core.view.s1;
import androidx.core.view.w;
import androidx.fragment.app.t0;
import d.j;
import e.f;
import e.s0;
import j.k;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;
import k.n;
import k.r;
import l.f4;
import l.m1;
import l.p;
import l.p3;
import l.q2;
import l.q3;
import l.r3;
import l.s3;
import l.t3;
import l.u3;
import l.v3;
import l.w3;
import l.y3;
import xyz.stream.utils.f0;

/* JADX INFO: loaded from: classes.dex */
public class Toolbar extends ViewGroup implements w {
    public final int Q;
    public final int R;
    public int S;
    public int T;
    public int U;
    public int V;
    public q2 W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public ActionMenuView f798a;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public AppCompatTextView f800b;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Drawable f808f;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public final ArrayList f819k0;

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

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public final int[] f821l0;

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

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public final a0 f823m0;

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

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

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public final xyz.stream.utils.a0 f826p0;

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

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

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public s3 f829s0;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public k.a0 f830t0;

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

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

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public OnBackInvokedCallback f833w0;

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

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public boolean f835y0;
    public final s0 z0;

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

    private ArrayList<MenuItem> getCurrentMenuItems() {
        ArrayList<MenuItem> arrayList = new ArrayList<>();
        Menu menu = getMenu();
        for (int i10 = 0; i10 < menu.size(); i10++) {
            arrayList.add(menu.getItem(i10));
        }
        return arrayList;
    }

    private MenuInflater getMenuInflater() {
        return new k(getContext());
    }

    public static t3 h() {
        t3 t3Var = new t3(-2, -2);
        t3Var.f29847b = 0;
        t3Var.f25186a = 8388627;
        return t3Var;
    }

    public static t3 i(ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof t3) {
            t3 t3Var = (t3) layoutParams;
            t3 t3Var2 = new t3(t3Var);
            t3Var2.f29847b = 0;
            t3Var2.f29847b = t3Var.f29847b;
            return t3Var2;
        }
        if (layoutParams instanceof e.a) {
            t3 t3Var3 = new t3((e.a) layoutParams);
            t3Var3.f29847b = 0;
            return t3Var3;
        }
        if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
            t3 t3Var4 = new t3(layoutParams);
            t3Var4.f29847b = 0;
            return t3Var4;
        }
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        t3 t3Var5 = new t3(marginLayoutParams);
        t3Var5.f29847b = 0;
        ((ViewGroup.MarginLayoutParams) t3Var5).leftMargin = marginLayoutParams.leftMargin;
        ((ViewGroup.MarginLayoutParams) t3Var5).topMargin = marginLayoutParams.topMargin;
        ((ViewGroup.MarginLayoutParams) t3Var5).rightMargin = marginLayoutParams.rightMargin;
        ((ViewGroup.MarginLayoutParams) t3Var5).bottomMargin = marginLayoutParams.bottomMargin;
        return t3Var5;
    }

    public static int k(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.getMarginEnd() + marginLayoutParams.getMarginStart();
    }

    public static int l(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    public final void a(int i10, ArrayList arrayList) {
        boolean z10 = getLayoutDirection() == 1;
        int childCount = getChildCount();
        int absoluteGravity = Gravity.getAbsoluteGravity(i10, getLayoutDirection());
        arrayList.clear();
        if (!z10) {
            for (int i11 = 0; i11 < childCount; i11++) {
                View childAt = getChildAt(i11);
                t3 t3Var = (t3) childAt.getLayoutParams();
                if (t3Var.f29847b == 0 && u(childAt)) {
                    int i12 = t3Var.f25186a;
                    int layoutDirection = getLayoutDirection();
                    int absoluteGravity2 = Gravity.getAbsoluteGravity(i12, layoutDirection) & 7;
                    if (absoluteGravity2 != 1 && absoluteGravity2 != 3 && absoluteGravity2 != 5) {
                        absoluteGravity2 = layoutDirection == 1 ? 5 : 3;
                    }
                    if (absoluteGravity2 == absoluteGravity) {
                        arrayList.add(childAt);
                    }
                }
            }
            return;
        }
        for (int i13 = childCount - 1; i13 >= 0; i13--) {
            View childAt2 = getChildAt(i13);
            t3 t3Var2 = (t3) childAt2.getLayoutParams();
            if (t3Var2.f29847b == 0 && u(childAt2)) {
                int i14 = t3Var2.f25186a;
                int layoutDirection2 = getLayoutDirection();
                int absoluteGravity3 = Gravity.getAbsoluteGravity(i14, layoutDirection2) & 7;
                if (absoluteGravity3 != 1 && absoluteGravity3 != 3 && absoluteGravity3 != 5) {
                    absoluteGravity3 = layoutDirection2 == 1 ? 5 : 3;
                }
                if (absoluteGravity3 == absoluteGravity) {
                    arrayList.add(childAt2);
                }
            }
        }
    }

    @Override // androidx.core.view.w
    public final void addMenuProvider(c0 c0Var) {
        a0 a0Var = this.f823m0;
        a0Var.f1710b.add(c0Var);
        a0Var.f1709a.run();
    }

    public final void b(View view, boolean z10) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        t3 t3VarH = layoutParams == null ? h() : !checkLayoutParams(layoutParams) ? i(layoutParams) : (t3) layoutParams;
        t3VarH.f29847b = 1;
        if (!z10 || this.f814i == null) {
            addView(view, t3VarH);
        } else {
            view.setLayoutParams(t3VarH);
            this.f819k0.add(view);
        }
    }

    public final void c() {
        if (this.f812h == null) {
            AppCompatImageButton appCompatImageButton = new AppCompatImageButton(getContext(), null, d.a.toolbarNavigationButtonStyle);
            this.f812h = appCompatImageButton;
            appCompatImageButton.setImageDrawable(this.f808f);
            this.f812h.setContentDescription(this.f810g);
            t3 t3VarH = h();
            t3VarH.f25186a = (this.Q & 112) | 8388611;
            t3VarH.f29847b = 2;
            this.f812h.setLayoutParams(t3VarH);
            this.f812h.setOnClickListener(new f(this, 2));
        }
    }

    @Override // android.view.ViewGroup
    public final boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return super.checkLayoutParams(layoutParams) && (layoutParams instanceof t3);
    }

    public final void d() {
        if (this.W == null) {
            q2 q2Var = new q2();
            q2Var.f29816a = 0;
            q2Var.f29817b = 0;
            q2Var.f29818c = Integer.MIN_VALUE;
            q2Var.f29819d = Integer.MIN_VALUE;
            q2Var.f29820e = 0;
            q2Var.f29821f = 0;
            q2Var.f29822g = false;
            q2Var.f29823h = false;
            this.W = q2Var;
        }
    }

    public final void e() {
        f();
        ActionMenuView actionMenuView = this.f798a;
        if (actionMenuView.S == null) {
            k.p pVar = (k.p) actionMenuView.getMenu();
            if (this.f829s0 == null) {
                this.f829s0 = new s3(this);
            }
            this.f798a.setExpandedActionViewsExclusive(true);
            pVar.b(this.f829s0, this.f816j);
            w();
        }
    }

    public final void f() {
        if (this.f798a == null) {
            ActionMenuView actionMenuView = new ActionMenuView(getContext());
            this.f798a = actionMenuView;
            actionMenuView.setPopupTheme(this.f818k);
            this.f798a.setOnMenuItemClickListener(this.f826p0);
            this.f798a.setMenuCallbacks(this.f830t0, new f0(this, 3));
            t3 t3VarH = h();
            t3VarH.f25186a = (this.Q & 112) | 8388613;
            this.f798a.setLayoutParams(t3VarH);
            b(this.f798a, false);
        }
    }

    public final void g() {
        if (this.f804d == null) {
            this.f804d = new AppCompatImageButton(getContext(), null, d.a.toolbarNavigationButtonStyle);
            t3 t3VarH = h();
            t3VarH.f25186a = (this.Q & 112) | 8388611;
            this.f804d.setLayoutParams(t3VarH);
        }
    }

    @Override // android.view.ViewGroup
    public final /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return h();
    }

    @Override // android.view.ViewGroup
    public final /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return i(layoutParams);
    }

    @Nullable
    public CharSequence getCollapseContentDescription() {
        AppCompatImageButton appCompatImageButton = this.f812h;
        if (appCompatImageButton != null) {
            return appCompatImageButton.getContentDescription();
        }
        return null;
    }

    @Nullable
    public Drawable getCollapseIcon() {
        AppCompatImageButton appCompatImageButton = this.f812h;
        if (appCompatImageButton != null) {
            return appCompatImageButton.getDrawable();
        }
        return null;
    }

    public int getContentInsetEnd() {
        q2 q2Var = this.W;
        if (q2Var != null) {
            return q2Var.f29822g ? q2Var.f29816a : q2Var.f29817b;
        }
        return 0;
    }

    public int getContentInsetEndWithActions() {
        int i10 = this.f801b0;
        return i10 != Integer.MIN_VALUE ? i10 : getContentInsetEnd();
    }

    public int getContentInsetLeft() {
        q2 q2Var = this.W;
        if (q2Var != null) {
            return q2Var.f29816a;
        }
        return 0;
    }

    public int getContentInsetRight() {
        q2 q2Var = this.W;
        if (q2Var != null) {
            return q2Var.f29817b;
        }
        return 0;
    }

    public int getContentInsetStart() {
        q2 q2Var = this.W;
        if (q2Var != null) {
            return q2Var.f29822g ? q2Var.f29817b : q2Var.f29816a;
        }
        return 0;
    }

    public int getContentInsetStartWithNavigation() {
        int i10 = this.f799a0;
        return i10 != Integer.MIN_VALUE ? i10 : getContentInsetStart();
    }

    public int getCurrentContentInsetEnd() {
        k.p pVar;
        ActionMenuView actionMenuView = this.f798a;
        return (actionMenuView == null || (pVar = actionMenuView.S) == null || !pVar.hasVisibleItems()) ? getContentInsetEnd() : Math.max(getContentInsetEnd(), Math.max(this.f801b0, 0));
    }

    public int getCurrentContentInsetLeft() {
        return getLayoutDirection() == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
    }

    public int getCurrentContentInsetRight() {
        return getLayoutDirection() == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
    }

    public int getCurrentContentInsetStart() {
        return getNavigationIcon() != null ? Math.max(getContentInsetStart(), Math.max(this.f799a0, 0)) : getContentInsetStart();
    }

    public Drawable getLogo() {
        AppCompatImageView appCompatImageView = this.f806e;
        if (appCompatImageView != null) {
            return appCompatImageView.getDrawable();
        }
        return null;
    }

    public CharSequence getLogoDescription() {
        AppCompatImageView appCompatImageView = this.f806e;
        if (appCompatImageView != null) {
            return appCompatImageView.getContentDescription();
        }
        return null;
    }

    public Menu getMenu() {
        e();
        return this.f798a.getMenu();
    }

    @Nullable
    @VisibleForTesting
    public View getNavButtonView() {
        return this.f804d;
    }

    @Nullable
    public CharSequence getNavigationContentDescription() {
        AppCompatImageButton appCompatImageButton = this.f804d;
        if (appCompatImageButton != null) {
            return appCompatImageButton.getContentDescription();
        }
        return null;
    }

    @Nullable
    public Drawable getNavigationIcon() {
        AppCompatImageButton appCompatImageButton = this.f804d;
        if (appCompatImageButton != null) {
            return appCompatImageButton.getDrawable();
        }
        return null;
    }

    public p getOuterActionMenuPresenter() {
        return this.f828r0;
    }

    @Nullable
    public Drawable getOverflowIcon() {
        e();
        return this.f798a.getOverflowIcon();
    }

    public Context getPopupContext() {
        return this.f816j;
    }

    @StyleRes
    public int getPopupTheme() {
        return this.f818k;
    }

    public CharSequence getSubtitle() {
        return this.f807e0;
    }

    @Nullable
    @VisibleForTesting
    public final TextView getSubtitleTextView() {
        return this.f802c;
    }

    public CharSequence getTitle() {
        return this.f805d0;
    }

    public int getTitleMarginBottom() {
        return this.V;
    }

    public int getTitleMarginEnd() {
        return this.T;
    }

    public int getTitleMarginStart() {
        return this.S;
    }

    public int getTitleMarginTop() {
        return this.U;
    }

    @Nullable
    @VisibleForTesting
    public final TextView getTitleTextView() {
        return this.f800b;
    }

    @RestrictTo({RestrictTo.Scope.f557c})
    public m1 getWrapper() {
        if (this.f827q0 == null) {
            this.f827q0 = new w3(this, true);
        }
        return this.f827q0;
    }

    public final int j(int i10, View view) {
        t3 t3Var = (t3) view.getLayoutParams();
        int measuredHeight = view.getMeasuredHeight();
        int i11 = i10 > 0 ? (measuredHeight - i10) / 2 : 0;
        int i12 = t3Var.f25186a & 112;
        if (i12 != 16 && i12 != 48 && i12 != 80) {
            i12 = this.f803c0 & 112;
        }
        if (i12 == 48) {
            return getPaddingTop() - i11;
        }
        if (i12 == 80) {
            return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) t3Var).bottomMargin) - i11;
        }
        int paddingTop = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int height = getHeight();
        int iMax = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
        int i13 = ((ViewGroup.MarginLayoutParams) t3Var).topMargin;
        if (iMax < i13) {
            iMax = i13;
        } else {
            int i14 = (((height - paddingBottom) - measuredHeight) - iMax) - paddingTop;
            int i15 = ((ViewGroup.MarginLayoutParams) t3Var).bottomMargin;
            if (i14 < i15) {
                iMax = Math.max(0, iMax - (i15 - i14));
            }
        }
        return paddingTop + iMax;
    }

    public void m(int i10) {
        getMenuInflater().inflate(i10, getMenu());
    }

    public final void n() {
        Iterator it = this.f824n0.iterator();
        while (it.hasNext()) {
            getMenu().removeItem(((MenuItem) it.next()).getItemId());
        }
        Menu menu = getMenu();
        ArrayList<MenuItem> currentMenuItems = getCurrentMenuItems();
        MenuInflater menuInflater = getMenuInflater();
        Iterator it2 = this.f823m0.f1710b.iterator();
        while (it2.hasNext()) {
            ((t0) ((c0) it2.next())).f2595a.j(menu, menuInflater);
        }
        ArrayList<MenuItem> currentMenuItems2 = getCurrentMenuItems();
        currentMenuItems2.removeAll(currentMenuItems);
        this.f824n0 = currentMenuItems2;
    }

    public final boolean o(View view) {
        return view.getParent() == this || this.f819k0.contains(view);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        w();
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        removeCallbacks(this.z0);
        w();
    }

    @Override // android.view.View
    public final boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.f815i0 = false;
        }
        if (!this.f815i0) {
            boolean zOnHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !zOnHoverEvent) {
                this.f815i0 = true;
            }
        }
        if (actionMasked == 10 || actionMasked == 3) {
            this.f815i0 = false;
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:105:0x0293 A[LOOP:0: B:104:0x0291->B:105:0x0293, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:108:0x02af A[LOOP:1: B:107:0x02ad->B:108:0x02af, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:111:0x02cf A[LOOP:2: B:110:0x02cd->B:111:0x02cf, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:115:0x0310  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x031d A[LOOP:3: B:119:0x031b->B:120:0x031d, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0062  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0079  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00cd  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00ea  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0101  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0106  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x011e  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x012b  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x012d  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0134  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0137  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0168  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x01a0  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x01af  */
    /* JADX WARN: Removed duplicated region for block: B:90:0x021d  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        int iQ;
        int iR;
        boolean zU;
        boolean zU2;
        int i14;
        int measuredHeight;
        int i15;
        int i16;
        int i17;
        int i18;
        int paddingTop;
        int i19;
        int i20;
        int i21;
        int i22;
        int size;
        int iQ2;
        int i23;
        int size2;
        int i24;
        int size3;
        int i25;
        int i26;
        int i27;
        int size4;
        boolean z11 = getLayoutDirection() == 1;
        int width = getWidth();
        int height = getHeight();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int paddingTop2 = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int i28 = width - paddingRight;
        int[] iArr = this.f821l0;
        iArr[1] = 0;
        iArr[0] = 0;
        WeakHashMap weakHashMap = s1.f1815a;
        int minimumHeight = getMinimumHeight();
        int iMin = minimumHeight >= 0 ? Math.min(minimumHeight, i13 - i11) : 0;
        if (!u(this.f804d)) {
            iQ = paddingLeft;
        } else {
            if (z11) {
                iR = r(this.f804d, i28, iMin, iArr);
                iQ = paddingLeft;
                if (u(this.f812h)) {
                    if (z11) {
                        iR = r(this.f812h, iR, iMin, iArr);
                    } else {
                        iQ = q(this.f812h, iQ, iMin, iArr);
                    }
                }
                if (u(this.f798a)) {
                    if (z11) {
                        iQ = q(this.f798a, iQ, iMin, iArr);
                    } else {
                        iR = r(this.f798a, iR, iMin, iArr);
                    }
                }
                int currentContentInsetLeft = getCurrentContentInsetLeft();
                int currentContentInsetRight = getCurrentContentInsetRight();
                iArr[0] = Math.max(0, currentContentInsetLeft - iQ);
                iArr[1] = Math.max(0, currentContentInsetRight - (i28 - iR));
                int iMax = Math.max(iQ, currentContentInsetLeft);
                int iMin2 = Math.min(iR, i28 - currentContentInsetRight);
                if (u(this.f814i)) {
                    if (z11) {
                        iMin2 = r(this.f814i, iMin2, iMin, iArr);
                    } else {
                        iMax = q(this.f814i, iMax, iMin, iArr);
                    }
                }
                if (u(this.f806e)) {
                    if (z11) {
                        iMin2 = r(this.f806e, iMin2, iMin, iArr);
                    } else {
                        iMax = q(this.f806e, iMax, iMin, iArr);
                    }
                }
                zU = u(this.f800b);
                zU2 = u(this.f802c);
                if (zU) {
                    i14 = paddingRight;
                    measuredHeight = 0;
                } else {
                    t3 t3Var = (t3) this.f800b.getLayoutParams();
                    i14 = paddingRight;
                    measuredHeight = ((ViewGroup.MarginLayoutParams) t3Var).bottomMargin + this.f800b.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) t3Var).topMargin;
                }
                if (zU2) {
                    i15 = width;
                } else {
                    t3 t3Var2 = (t3) this.f802c.getLayoutParams();
                    i15 = width;
                    measuredHeight += this.f802c.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) t3Var2).topMargin + ((ViewGroup.MarginLayoutParams) t3Var2).bottomMargin;
                }
                if (!zU || zU2) {
                    AppCompatTextView appCompatTextView = !zU ? this.f800b : this.f802c;
                    AppCompatTextView appCompatTextView2 = !zU2 ? this.f802c : this.f800b;
                    t3 t3Var3 = (t3) appCompatTextView.getLayoutParams();
                    t3 t3Var4 = (t3) appCompatTextView2.getLayoutParams();
                    boolean z12 = (zU && this.f800b.getMeasuredWidth() > 0) || (zU2 && this.f802c.getMeasuredWidth() > 0);
                    i16 = this.f803c0 & 112;
                    i17 = paddingLeft;
                    if (i16 == 48) {
                        i18 = iMin;
                        paddingTop = getPaddingTop() + ((ViewGroup.MarginLayoutParams) t3Var3).topMargin + this.U;
                    } else if (i16 != 80) {
                        int iMax2 = (((height - paddingTop2) - paddingBottom) - measuredHeight) / 2;
                        i18 = iMin;
                        int i29 = ((ViewGroup.MarginLayoutParams) t3Var3).topMargin + this.U;
                        if (iMax2 < i29) {
                            iMax2 = i29;
                        } else {
                            int i30 = (((height - paddingBottom) - measuredHeight) - iMax2) - paddingTop2;
                            int i31 = ((ViewGroup.MarginLayoutParams) t3Var3).bottomMargin;
                            int i32 = this.V;
                            if (i30 < i31 + i32) {
                                iMax2 = Math.max(0, iMax2 - ((((ViewGroup.MarginLayoutParams) t3Var4).bottomMargin + i32) - i30));
                            }
                        }
                        paddingTop = paddingTop2 + iMax2;
                    } else {
                        i18 = iMin;
                        paddingTop = (((height - paddingBottom) - ((ViewGroup.MarginLayoutParams) t3Var4).bottomMargin) - this.V) - measuredHeight;
                    }
                    if (z11) {
                        int i33 = (z12 ? this.S : 0) - iArr[1];
                        iMin2 -= Math.max(0, i33);
                        iArr[1] = Math.max(0, -i33);
                        if (zU) {
                            t3 t3Var5 = (t3) this.f800b.getLayoutParams();
                            int measuredWidth = iMin2 - this.f800b.getMeasuredWidth();
                            int measuredHeight2 = this.f800b.getMeasuredHeight() + paddingTop;
                            this.f800b.layout(measuredWidth, paddingTop, iMin2, measuredHeight2);
                            i21 = measuredWidth - this.T;
                            paddingTop = measuredHeight2 + ((ViewGroup.MarginLayoutParams) t3Var5).bottomMargin;
                        } else {
                            i21 = iMin2;
                        }
                        if (zU2) {
                            int i34 = paddingTop + ((ViewGroup.MarginLayoutParams) ((t3) this.f802c.getLayoutParams())).topMargin;
                            this.f802c.layout(iMin2 - this.f802c.getMeasuredWidth(), i34, iMin2, this.f802c.getMeasuredHeight() + i34);
                            i22 = iMin2 - this.T;
                        } else {
                            i22 = iMin2;
                        }
                        if (z12) {
                            iMin2 = Math.min(i21, i22);
                        }
                    } else {
                        int i35 = (z12 ? this.S : 0) - iArr[0];
                        iMax += Math.max(0, i35);
                        iArr[0] = Math.max(0, -i35);
                        if (zU) {
                            t3 t3Var6 = (t3) this.f800b.getLayoutParams();
                            int measuredWidth2 = this.f800b.getMeasuredWidth() + iMax;
                            int measuredHeight3 = this.f800b.getMeasuredHeight() + paddingTop;
                            this.f800b.layout(iMax, paddingTop, measuredWidth2, measuredHeight3);
                            i19 = measuredWidth2 + this.T;
                            paddingTop = measuredHeight3 + ((ViewGroup.MarginLayoutParams) t3Var6).bottomMargin;
                        } else {
                            i19 = iMax;
                        }
                        if (zU2) {
                            int i36 = paddingTop + ((ViewGroup.MarginLayoutParams) ((t3) this.f802c.getLayoutParams())).topMargin;
                            int measuredWidth3 = this.f802c.getMeasuredWidth() + iMax;
                            this.f802c.layout(iMax, i36, measuredWidth3, this.f802c.getMeasuredHeight() + i36);
                            i20 = measuredWidth3 + this.T;
                        } else {
                            i20 = iMax;
                        }
                        if (z12) {
                            iMax = Math.max(i19, i20);
                        }
                    }
                } else {
                    i17 = paddingLeft;
                    i18 = iMin;
                }
                ArrayList arrayList = this.f817j0;
                a(3, arrayList);
                size = arrayList.size();
                iQ2 = iMax;
                for (i23 = 0; i23 < size; i23++) {
                    iQ2 = q((View) arrayList.get(i23), iQ2, i18, iArr);
                }
                int i37 = i18;
                a(5, arrayList);
                size2 = arrayList.size();
                for (i24 = 0; i24 < size2; i24++) {
                    iMin2 = r((View) arrayList.get(i24), iMin2, i37, iArr);
                }
                a(1, arrayList);
                int i38 = iArr[0];
                int i39 = iArr[1];
                size3 = arrayList.size();
                int i40 = i39;
                int i41 = i38;
                i25 = 0;
                int measuredWidth4 = 0;
                while (i25 < size3) {
                    View view = (View) arrayList.get(i25);
                    t3 t3Var7 = (t3) view.getLayoutParams();
                    int i42 = ((ViewGroup.MarginLayoutParams) t3Var7).leftMargin - i41;
                    int i43 = ((ViewGroup.MarginLayoutParams) t3Var7).rightMargin - i40;
                    int iMax3 = Math.max(0, i42);
                    int iMax4 = Math.max(0, i43);
                    int iMax5 = Math.max(0, -i42);
                    int iMax6 = Math.max(0, -i43);
                    measuredWidth4 += view.getMeasuredWidth() + iMax3 + iMax4;
                    i25++;
                    i40 = iMax6;
                    i41 = iMax5;
                }
                i27 = ((((i15 - i17) - i14) / 2) + i17) - (measuredWidth4 / 2);
                int i44 = measuredWidth4 + i27;
                if (i27 >= iQ2) {
                    iQ2 = i44 > iMin2 ? i27 - (i44 - iMin2) : i27;
                }
                size4 = arrayList.size();
                for (i26 = 0; i26 < size4; i26++) {
                    iQ2 = q((View) arrayList.get(i26), iQ2, i37, iArr);
                }
                arrayList.clear();
            }
            iQ = q(this.f804d, paddingLeft, iMin, iArr);
        }
        iR = i28;
        if (u(this.f812h)) {
        }
        if (u(this.f798a)) {
        }
        int currentContentInsetLeft2 = getCurrentContentInsetLeft();
        int currentContentInsetRight2 = getCurrentContentInsetRight();
        iArr[0] = Math.max(0, currentContentInsetLeft2 - iQ);
        iArr[1] = Math.max(0, currentContentInsetRight2 - (i28 - iR));
        int iMax7 = Math.max(iQ, currentContentInsetLeft2);
        int iMin22 = Math.min(iR, i28 - currentContentInsetRight2);
        if (u(this.f814i)) {
        }
        if (u(this.f806e)) {
        }
        zU = u(this.f800b);
        zU2 = u(this.f802c);
        if (zU) {
        }
        if (zU2) {
        }
        if (zU) {
            if (!zU) {
            }
            if (!zU2) {
            }
            t3 t3Var32 = (t3) appCompatTextView.getLayoutParams();
            t3 t3Var42 = (t3) appCompatTextView2.getLayoutParams();
            if (zU) {
                i16 = this.f803c0 & 112;
                i17 = paddingLeft;
                if (i16 == 48) {
                }
                if (z11) {
                }
            } else {
                i16 = this.f803c0 & 112;
                i17 = paddingLeft;
                if (i16 == 48) {
                }
                if (z11) {
                }
            }
        }
        ArrayList arrayList2 = this.f817j0;
        a(3, arrayList2);
        size = arrayList2.size();
        iQ2 = iMax7;
        while (i23 < size) {
        }
        int i372 = i18;
        a(5, arrayList2);
        size2 = arrayList2.size();
        while (i24 < size2) {
        }
        a(1, arrayList2);
        int i382 = iArr[0];
        int i392 = iArr[1];
        size3 = arrayList2.size();
        int i402 = i392;
        int i412 = i382;
        i25 = 0;
        int measuredWidth42 = 0;
        while (i25 < size3) {
        }
        i27 = ((((i15 - i17) - i14) / 2) + i17) - (measuredWidth42 / 2);
        int i442 = measuredWidth42 + i27;
        if (i27 >= iQ2) {
        }
        size4 = arrayList2.size();
        while (i26 < size4) {
        }
        arrayList2.clear();
    }

    @Override // android.view.View
    public void onMeasure(int i10, int i11) {
        char c6;
        char c10;
        int iK;
        int iMax;
        int iCombineMeasuredStates;
        int iK2;
        int iL;
        int iCombineMeasuredStates2;
        int iMax2;
        boolean z10 = f4.f29682a;
        int i12 = 0;
        if (getLayoutDirection() == 1) {
            c10 = 1;
            c6 = 0;
        } else {
            c6 = 1;
            c10 = 0;
        }
        if (u(this.f804d)) {
            t(this.f804d, i10, 0, i11, this.R);
            iK = k(this.f804d) + this.f804d.getMeasuredWidth();
            iMax = Math.max(0, l(this.f804d) + this.f804d.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(0, this.f804d.getMeasuredState());
        } else {
            iK = 0;
            iMax = 0;
            iCombineMeasuredStates = 0;
        }
        if (u(this.f812h)) {
            t(this.f812h, i10, 0, i11, this.R);
            iK = k(this.f812h) + this.f812h.getMeasuredWidth();
            iMax = Math.max(iMax, l(this.f812h) + this.f812h.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f812h.getMeasuredState());
        }
        int currentContentInsetStart = getCurrentContentInsetStart();
        int iMax3 = Math.max(currentContentInsetStart, iK);
        int iMax4 = Math.max(0, currentContentInsetStart - iK);
        int[] iArr = this.f821l0;
        iArr[c10] = iMax4;
        if (u(this.f798a)) {
            t(this.f798a, i10, iMax3, i11, this.R);
            iK2 = k(this.f798a) + this.f798a.getMeasuredWidth();
            iMax = Math.max(iMax, l(this.f798a) + this.f798a.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f798a.getMeasuredState());
        } else {
            iK2 = 0;
        }
        int currentContentInsetEnd = getCurrentContentInsetEnd();
        int iMax5 = Math.max(currentContentInsetEnd, iK2) + iMax3;
        iArr[c6] = Math.max(0, currentContentInsetEnd - iK2);
        if (u(this.f814i)) {
            iMax5 += s(this.f814i, i10, iMax5, i11, 0, iArr);
            iMax = Math.max(iMax, l(this.f814i) + this.f814i.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f814i.getMeasuredState());
        }
        if (u(this.f806e)) {
            iMax5 += s(this.f806e, i10, iMax5, i11, 0, iArr);
            iMax = Math.max(iMax, l(this.f806e) + this.f806e.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f806e.getMeasuredState());
        }
        int childCount = getChildCount();
        for (int i13 = 0; i13 < childCount; i13++) {
            View childAt = getChildAt(i13);
            if (((t3) childAt.getLayoutParams()).f29847b == 0 && u(childAt)) {
                iMax5 += s(childAt, i10, iMax5, i11, 0, iArr);
                iMax = Math.max(iMax, l(childAt) + childAt.getMeasuredHeight());
                iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, childAt.getMeasuredState());
            }
        }
        int i14 = this.U + this.V;
        int i15 = this.S + this.T;
        if (u(this.f800b)) {
            s(this.f800b, i10, iMax5 + i15, i11, i14, iArr);
            int iK3 = k(this.f800b) + this.f800b.getMeasuredWidth();
            iL = l(this.f800b) + this.f800b.getMeasuredHeight();
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates, this.f800b.getMeasuredState());
            iMax2 = iK3;
        } else {
            iL = 0;
            iCombineMeasuredStates2 = iCombineMeasuredStates;
            iMax2 = 0;
        }
        if (u(this.f802c)) {
            iMax2 = Math.max(iMax2, s(this.f802c, i10, iMax5 + i15, i11, iL + i14, iArr));
            iL += l(this.f802c) + this.f802c.getMeasuredHeight();
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates2, this.f802c.getMeasuredState());
        }
        int iMax6 = Math.max(iMax, iL);
        int paddingRight = getPaddingRight() + getPaddingLeft();
        int paddingBottom = getPaddingBottom() + getPaddingTop() + iMax6;
        int iResolveSizeAndState = View.resolveSizeAndState(Math.max(paddingRight + iMax5 + iMax2, getSuggestedMinimumWidth()), i10, (-16777216) & iCombineMeasuredStates2);
        int iResolveSizeAndState2 = View.resolveSizeAndState(Math.max(paddingBottom, getSuggestedMinimumHeight()), i11, iCombineMeasuredStates2 << 16);
        if (!this.f832v0) {
            i12 = iResolveSizeAndState2;
            break;
        }
        int childCount2 = getChildCount();
        for (int i16 = 0; i16 < childCount2; i16++) {
            View childAt2 = getChildAt(i16);
            if (u(childAt2) && childAt2.getMeasuredWidth() > 0 && childAt2.getMeasuredHeight() > 0) {
                i12 = iResolveSizeAndState2;
                break;
            }
        }
        setMeasuredDimension(iResolveSizeAndState, i12);
    }

    @Override // android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        MenuItem menuItemFindItem;
        if (!(parcelable instanceof v3)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        v3 v3Var = (v3) parcelable;
        super.onRestoreInstanceState(v3Var.getSuperState());
        ActionMenuView actionMenuView = this.f798a;
        k.p pVar = actionMenuView != null ? actionMenuView.S : null;
        int i10 = v3Var.f29874c;
        if (i10 != 0 && this.f829s0 != null && pVar != null && (menuItemFindItem = pVar.findItem(i10)) != null) {
            menuItemFindItem.expandActionView();
        }
        if (v3Var.f29875d) {
            s0 s0Var = this.z0;
            removeCallbacks(s0Var);
            post(s0Var);
        }
    }

    @Override // android.view.View
    public final void onRtlPropertiesChanged(int i10) {
        super.onRtlPropertiesChanged(i10);
        d();
        q2 q2Var = this.W;
        boolean z10 = i10 == 1;
        if (z10 == q2Var.f29822g) {
            return;
        }
        q2Var.f29822g = z10;
        if (!q2Var.f29823h) {
            q2Var.f29816a = q2Var.f29820e;
            q2Var.f29817b = q2Var.f29821f;
            return;
        }
        if (z10) {
            int i11 = q2Var.f29819d;
            if (i11 == Integer.MIN_VALUE) {
                i11 = q2Var.f29820e;
            }
            q2Var.f29816a = i11;
            int i12 = q2Var.f29818c;
            if (i12 == Integer.MIN_VALUE) {
                i12 = q2Var.f29821f;
            }
            q2Var.f29817b = i12;
            return;
        }
        int i13 = q2Var.f29818c;
        if (i13 == Integer.MIN_VALUE) {
            i13 = q2Var.f29820e;
        }
        q2Var.f29816a = i13;
        int i14 = q2Var.f29819d;
        if (i14 == Integer.MIN_VALUE) {
            i14 = q2Var.f29821f;
        }
        q2Var.f29817b = i14;
    }

    @Override // android.view.View
    public Parcelable onSaveInstanceState() {
        r rVar;
        v3 v3Var = new v3(super.onSaveInstanceState());
        s3 s3Var = this.f829s0;
        if (s3Var != null && (rVar = s3Var.f29840b) != null) {
            v3Var.f29874c = rVar.f28908a;
        }
        v3Var.f29875d = p();
        return v3Var;
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f813h0 = false;
        }
        if (!this.f813h0) {
            boolean zOnTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !zOnTouchEvent) {
                this.f813h0 = true;
            }
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.f813h0 = false;
        }
        return true;
    }

    public final boolean p() {
        p pVar;
        ActionMenuView actionMenuView = this.f798a;
        return (actionMenuView == null || (pVar = actionMenuView.W) == null || !pVar.g()) ? false : true;
    }

    public final int q(View view, int i10, int i11, int[] iArr) {
        t3 t3Var = (t3) view.getLayoutParams();
        int i12 = ((ViewGroup.MarginLayoutParams) t3Var).leftMargin - iArr[0];
        int iMax = Math.max(0, i12) + i10;
        iArr[0] = Math.max(0, -i12);
        int iJ = j(i11, view);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax, iJ, iMax + measuredWidth, view.getMeasuredHeight() + iJ);
        return measuredWidth + ((ViewGroup.MarginLayoutParams) t3Var).rightMargin + iMax;
    }

    public final int r(View view, int i10, int i11, int[] iArr) {
        t3 t3Var = (t3) view.getLayoutParams();
        int i12 = ((ViewGroup.MarginLayoutParams) t3Var).rightMargin - iArr[1];
        int iMax = i10 - Math.max(0, i12);
        iArr[1] = Math.max(0, -i12);
        int iJ = j(i11, view);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax - measuredWidth, iJ, iMax, view.getMeasuredHeight() + iJ);
        return iMax - (measuredWidth + ((ViewGroup.MarginLayoutParams) t3Var).leftMargin);
    }

    @Override // androidx.core.view.w
    public final void removeMenuProvider(c0 c0Var) {
        this.f823m0.b(c0Var);
    }

    public final int s(View view, int i10, int i11, int i12, int i13, int[] iArr) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int i14 = marginLayoutParams.leftMargin - iArr[0];
        int i15 = marginLayoutParams.rightMargin - iArr[1];
        int iMax = Math.max(0, i15) + Math.max(0, i14);
        iArr[0] = Math.max(0, -i14);
        iArr[1] = Math.max(0, -i15);
        view.measure(ViewGroup.getChildMeasureSpec(i10, getPaddingRight() + getPaddingLeft() + iMax + i11, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i12, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i13, marginLayoutParams.height));
        return view.getMeasuredWidth() + iMax;
    }

    public void setBackInvokedCallbackEnabled(boolean z10) {
        if (this.f835y0 != z10) {
            this.f835y0 = z10;
            w();
        }
    }

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

    public void setCollapseIcon(@DrawableRes int i10) {
        setCollapseIcon(f.a.getDrawable(getContext(), i10));
    }

    @RestrictTo({RestrictTo.Scope.f557c})
    public void setCollapsible(boolean z10) {
        this.f832v0 = z10;
        requestLayout();
    }

    public void setContentInsetEndWithActions(int i10) {
        if (i10 < 0) {
            i10 = Integer.MIN_VALUE;
        }
        if (i10 != this.f801b0) {
            this.f801b0 = i10;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setContentInsetStartWithNavigation(int i10) {
        if (i10 < 0) {
            i10 = Integer.MIN_VALUE;
        }
        if (i10 != this.f799a0) {
            this.f799a0 = i10;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setContentInsetsAbsolute(int i10, int i11) {
        d();
        q2 q2Var = this.W;
        q2Var.f29823h = false;
        if (i10 != Integer.MIN_VALUE) {
            q2Var.f29820e = i10;
            q2Var.f29816a = i10;
        }
        if (i11 != Integer.MIN_VALUE) {
            q2Var.f29821f = i11;
            q2Var.f29817b = i11;
        }
    }

    public void setContentInsetsRelative(int i10, int i11) {
        d();
        this.W.a(i10, i11);
    }

    public void setLogo(@DrawableRes int i10) {
        setLogo(f.a.getDrawable(getContext(), i10));
    }

    public void setLogoDescription(@StringRes int i10) {
        setLogoDescription(getContext().getText(i10));
    }

    @RestrictTo({RestrictTo.Scope.f555a})
    public void setMenu(k.p pVar, p pVar2) {
        if (pVar == null && this.f798a == null) {
            return;
        }
        f();
        k.p pVar3 = this.f798a.S;
        if (pVar3 == pVar) {
            return;
        }
        if (pVar3 != null) {
            pVar3.r(this.f828r0);
            pVar3.r(this.f829s0);
        }
        if (this.f829s0 == null) {
            this.f829s0 = new s3(this);
        }
        pVar2.U = true;
        if (pVar != null) {
            pVar.b(pVar2, this.f816j);
            pVar.b(this.f829s0, this.f816j);
        } else {
            pVar2.initForMenu(this.f816j, null);
            this.f829s0.initForMenu(this.f816j, null);
            pVar2.b(true);
            this.f829s0.b(true);
        }
        this.f798a.setPopupTheme(this.f818k);
        this.f798a.setPresenter(pVar2);
        this.f828r0 = pVar2;
        w();
    }

    @RestrictTo({RestrictTo.Scope.f557c})
    public void setMenuCallbacks(k.a0 a0Var, n nVar) {
        this.f830t0 = a0Var;
        this.f831u0 = nVar;
        ActionMenuView actionMenuView = this.f798a;
        if (actionMenuView != null) {
            actionMenuView.setMenuCallbacks(a0Var, nVar);
        }
    }

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

    public void setNavigationIcon(@DrawableRes int i10) {
        setNavigationIcon(f.a.getDrawable(getContext(), i10));
    }

    public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
        g();
        this.f804d.setOnClickListener(onClickListener);
    }

    public void setOnMenuItemClickListener(u3 u3Var) {
        this.f825o0 = u3Var;
    }

    public void setOverflowIcon(@Nullable Drawable drawable) {
        e();
        this.f798a.setOverflowIcon(drawable);
    }

    public void setPopupTheme(@StyleRes int i10) {
        if (this.f818k != i10) {
            this.f818k = i10;
            if (i10 == 0) {
                this.f816j = getContext();
            } else {
                this.f816j = new ContextThemeWrapper(getContext(), i10);
            }
        }
    }

    public void setSubtitle(@StringRes int i10) {
        setSubtitle(getContext().getText(i10));
    }

    public void setSubtitleTextAppearance(Context context, @StyleRes int i10) {
        this.f822m = i10;
        AppCompatTextView appCompatTextView = this.f802c;
        if (appCompatTextView != null) {
            appCompatTextView.setTextAppearance(context, i10);
        }
    }

    public void setSubtitleTextColor(@ColorInt int i10) {
        setSubtitleTextColor(ColorStateList.valueOf(i10));
    }

    public void setTitle(@StringRes int i10) {
        setTitle(getContext().getText(i10));
    }

    public void setTitleMargin(int i10, int i11, int i12, int i13) {
        this.S = i10;
        this.U = i11;
        this.T = i12;
        this.V = i13;
        requestLayout();
    }

    public void setTitleMarginBottom(int i10) {
        this.V = i10;
        requestLayout();
    }

    public void setTitleMarginEnd(int i10) {
        this.T = i10;
        requestLayout();
    }

    public void setTitleMarginStart(int i10) {
        this.S = i10;
        requestLayout();
    }

    public void setTitleMarginTop(int i10) {
        this.U = i10;
        requestLayout();
    }

    public void setTitleTextAppearance(Context context, @StyleRes int i10) {
        this.f820l = i10;
        AppCompatTextView appCompatTextView = this.f800b;
        if (appCompatTextView != null) {
            appCompatTextView.setTextAppearance(context, i10);
        }
    }

    public void setTitleTextColor(@ColorInt int i10) {
        setTitleTextColor(ColorStateList.valueOf(i10));
    }

    public final void t(View view, int i10, int i11, int i12, int i13) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int childMeasureSpec = ViewGroup.getChildMeasureSpec(i10, getPaddingRight() + getPaddingLeft() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i11, marginLayoutParams.width);
        int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i12, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin, marginLayoutParams.height);
        int mode = View.MeasureSpec.getMode(childMeasureSpec2);
        if (mode != 1073741824 && i13 >= 0) {
            if (mode != 0) {
                i13 = Math.min(View.MeasureSpec.getSize(childMeasureSpec2), i13);
            }
            childMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i13, 1073741824);
        }
        view.measure(childMeasureSpec, childMeasureSpec2);
    }

    public final boolean u(View view) {
        return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true;
    }

    public final boolean v() {
        p pVar;
        ActionMenuView actionMenuView = this.f798a;
        return (actionMenuView == null || (pVar = actionMenuView.W) == null || !pVar.i()) ? false : true;
    }

    public final void w() {
        OnBackInvokedDispatcher onBackInvokedDispatcher;
        if (Build.VERSION.SDK_INT >= 33) {
            OnBackInvokedDispatcher onBackInvokedDispatcherFindOnBackInvokedDispatcher = r3.findOnBackInvokedDispatcher(this);
            s3 s3Var = this.f829s0;
            boolean z10 = false;
            int i10 = 1;
            if (((s3Var == null || s3Var.f29840b == null) ? false : true) && onBackInvokedDispatcherFindOnBackInvokedDispatcher != null && isAttachedToWindow() && this.f835y0) {
                z10 = true;
            }
            if (z10 && this.f834x0 == null) {
                if (this.f833w0 == null) {
                    this.f833w0 = r3.a(new q3(this, i10));
                }
                r3.b(onBackInvokedDispatcherFindOnBackInvokedDispatcher, this.f833w0);
                this.f834x0 = onBackInvokedDispatcherFindOnBackInvokedDispatcher;
                return;
            }
            if (z10 || (onBackInvokedDispatcher = this.f834x0) == null) {
                return;
            }
            r3.c(onBackInvokedDispatcher, this.f833w0);
            this.f834x0 = null;
        }
    }

    public Toolbar(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, d.a.toolbarStyle);
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        Context context = getContext();
        t3 t3Var = new t3(context, attributeSet);
        t3Var.f25186a = 0;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, j.ActionBarLayout);
        t3Var.f25186a = typedArrayObtainStyledAttributes.getInt(j.ActionBarLayout_android_layout_gravity, 0);
        typedArrayObtainStyledAttributes.recycle();
        t3Var.f29847b = 0;
        return t3Var;
    }

    public void setCollapseContentDescription(@Nullable CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            c();
        }
        AppCompatImageButton appCompatImageButton = this.f812h;
        if (appCompatImageButton != null) {
            appCompatImageButton.setContentDescription(charSequence);
        }
    }

    public void setCollapseIcon(@Nullable Drawable drawable) {
        if (drawable != null) {
            c();
            this.f812h.setImageDrawable(drawable);
        } else {
            AppCompatImageButton appCompatImageButton = this.f812h;
            if (appCompatImageButton != null) {
                appCompatImageButton.setImageDrawable(this.f808f);
            }
        }
    }

    public void setLogo(Drawable drawable) {
        if (drawable != null) {
            if (this.f806e == null) {
                this.f806e = new AppCompatImageView(getContext());
            }
            if (!o(this.f806e)) {
                b(this.f806e, true);
            }
        } else {
            AppCompatImageView appCompatImageView = this.f806e;
            if (appCompatImageView != null && o(appCompatImageView)) {
                removeView(this.f806e);
                this.f819k0.remove(this.f806e);
            }
        }
        AppCompatImageView appCompatImageView2 = this.f806e;
        if (appCompatImageView2 != null) {
            appCompatImageView2.setImageDrawable(drawable);
        }
    }

    public void setLogoDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence) && this.f806e == null) {
            this.f806e = new AppCompatImageView(getContext());
        }
        AppCompatImageView appCompatImageView = this.f806e;
        if (appCompatImageView != null) {
            appCompatImageView.setContentDescription(charSequence);
        }
    }

    public void setNavigationContentDescription(@Nullable CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            g();
        }
        AppCompatImageButton appCompatImageButton = this.f804d;
        if (appCompatImageButton != null) {
            appCompatImageButton.setContentDescription(charSequence);
            y3.setTooltipText(this.f804d, charSequence);
        }
    }

    public void setNavigationIcon(@Nullable Drawable drawable) {
        if (drawable != null) {
            g();
            if (!o(this.f804d)) {
                b(this.f804d, true);
            }
        } else {
            AppCompatImageButton appCompatImageButton = this.f804d;
            if (appCompatImageButton != null && o(appCompatImageButton)) {
                removeView(this.f804d);
                this.f819k0.remove(this.f804d);
            }
        }
        AppCompatImageButton appCompatImageButton2 = this.f804d;
        if (appCompatImageButton2 != null) {
            appCompatImageButton2.setImageDrawable(drawable);
        }
    }

    public void setSubtitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            AppCompatTextView appCompatTextView = this.f802c;
            if (appCompatTextView != null && o(appCompatTextView)) {
                removeView(this.f802c);
                this.f819k0.remove(this.f802c);
            }
        } else {
            if (this.f802c == null) {
                Context context = getContext();
                AppCompatTextView appCompatTextView2 = new AppCompatTextView(context);
                this.f802c = appCompatTextView2;
                appCompatTextView2.setSingleLine();
                this.f802c.setEllipsize(TextUtils.TruncateAt.END);
                int i10 = this.f822m;
                if (i10 != 0) {
                    this.f802c.setTextAppearance(context, i10);
                }
                ColorStateList colorStateList = this.f811g0;
                if (colorStateList != null) {
                    this.f802c.setTextColor(colorStateList);
                }
            }
            if (!o(this.f802c)) {
                b(this.f802c, true);
            }
        }
        AppCompatTextView appCompatTextView3 = this.f802c;
        if (appCompatTextView3 != null) {
            appCompatTextView3.setText(charSequence);
        }
        this.f807e0 = charSequence;
    }

    public void setSubtitleTextColor(@NonNull ColorStateList colorStateList) {
        this.f811g0 = colorStateList;
        AppCompatTextView appCompatTextView = this.f802c;
        if (appCompatTextView != null) {
            appCompatTextView.setTextColor(colorStateList);
        }
    }

    public void setTitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            AppCompatTextView appCompatTextView = this.f800b;
            if (appCompatTextView != null && o(appCompatTextView)) {
                removeView(this.f800b);
                this.f819k0.remove(this.f800b);
            }
        } else {
            if (this.f800b == null) {
                Context context = getContext();
                AppCompatTextView appCompatTextView2 = new AppCompatTextView(context);
                this.f800b = appCompatTextView2;
                appCompatTextView2.setSingleLine();
                this.f800b.setEllipsize(TextUtils.TruncateAt.END);
                int i10 = this.f820l;
                if (i10 != 0) {
                    this.f800b.setTextAppearance(context, i10);
                }
                ColorStateList colorStateList = this.f809f0;
                if (colorStateList != null) {
                    this.f800b.setTextColor(colorStateList);
                }
            }
            if (!o(this.f800b)) {
                b(this.f800b, true);
            }
        }
        AppCompatTextView appCompatTextView3 = this.f800b;
        if (appCompatTextView3 != null) {
            appCompatTextView3.setText(charSequence);
        }
        this.f805d0 = charSequence;
    }

    public void setTitleTextColor(@NonNull ColorStateList colorStateList) {
        this.f809f0 = colorStateList;
        AppCompatTextView appCompatTextView = this.f800b;
        if (appCompatTextView != null) {
            appCompatTextView.setTextColor(colorStateList);
        }
    }

    public Toolbar(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f803c0 = 8388627;
        this.f817j0 = new ArrayList();
        this.f819k0 = new ArrayList();
        this.f821l0 = new int[2];
        this.f823m0 = new a0(new q3(this, 0));
        this.f824n0 = new ArrayList();
        this.f826p0 = new xyz.stream.utils.a0(this);
        this.z0 = new s0(this, 3);
        Context context2 = getContext();
        int[] iArr = j.Toolbar;
        p3 p3VarD = p3.d(context2, attributeSet, iArr, i10);
        s1.saveAttributeDataForStyleable(this, context, iArr, attributeSet, p3VarD.f29809b, i10, 0);
        int i11 = j.Toolbar_titleTextAppearance;
        TypedArray typedArray = p3VarD.f29809b;
        this.f820l = typedArray.getResourceId(i11, 0);
        this.f822m = typedArray.getResourceId(j.Toolbar_subtitleTextAppearance, 0);
        this.f803c0 = typedArray.getInteger(j.Toolbar_android_gravity, 8388627);
        this.Q = typedArray.getInteger(j.Toolbar_buttonGravity, 48);
        int dimensionPixelOffset = typedArray.getDimensionPixelOffset(j.Toolbar_titleMargin, 0);
        int i12 = j.Toolbar_titleMargins;
        dimensionPixelOffset = typedArray.hasValue(i12) ? typedArray.getDimensionPixelOffset(i12, dimensionPixelOffset) : dimensionPixelOffset;
        this.V = dimensionPixelOffset;
        this.U = dimensionPixelOffset;
        this.T = dimensionPixelOffset;
        this.S = dimensionPixelOffset;
        int dimensionPixelOffset2 = typedArray.getDimensionPixelOffset(j.Toolbar_titleMarginStart, -1);
        if (dimensionPixelOffset2 >= 0) {
            this.S = dimensionPixelOffset2;
        }
        int dimensionPixelOffset3 = typedArray.getDimensionPixelOffset(j.Toolbar_titleMarginEnd, -1);
        if (dimensionPixelOffset3 >= 0) {
            this.T = dimensionPixelOffset3;
        }
        int dimensionPixelOffset4 = typedArray.getDimensionPixelOffset(j.Toolbar_titleMarginTop, -1);
        if (dimensionPixelOffset4 >= 0) {
            this.U = dimensionPixelOffset4;
        }
        int dimensionPixelOffset5 = typedArray.getDimensionPixelOffset(j.Toolbar_titleMarginBottom, -1);
        if (dimensionPixelOffset5 >= 0) {
            this.V = dimensionPixelOffset5;
        }
        this.R = typedArray.getDimensionPixelSize(j.Toolbar_maxButtonHeight, -1);
        int dimensionPixelOffset6 = typedArray.getDimensionPixelOffset(j.Toolbar_contentInsetStart, Integer.MIN_VALUE);
        int dimensionPixelOffset7 = typedArray.getDimensionPixelOffset(j.Toolbar_contentInsetEnd, Integer.MIN_VALUE);
        int dimensionPixelSize = typedArray.getDimensionPixelSize(j.Toolbar_contentInsetLeft, 0);
        int dimensionPixelSize2 = typedArray.getDimensionPixelSize(j.Toolbar_contentInsetRight, 0);
        d();
        q2 q2Var = this.W;
        q2Var.f29823h = false;
        if (dimensionPixelSize != Integer.MIN_VALUE) {
            q2Var.f29820e = dimensionPixelSize;
            q2Var.f29816a = dimensionPixelSize;
        }
        if (dimensionPixelSize2 != Integer.MIN_VALUE) {
            q2Var.f29821f = dimensionPixelSize2;
            q2Var.f29817b = dimensionPixelSize2;
        }
        if (dimensionPixelOffset6 != Integer.MIN_VALUE || dimensionPixelOffset7 != Integer.MIN_VALUE) {
            q2Var.a(dimensionPixelOffset6, dimensionPixelOffset7);
        }
        this.f799a0 = typedArray.getDimensionPixelOffset(j.Toolbar_contentInsetStartWithNavigation, Integer.MIN_VALUE);
        this.f801b0 = typedArray.getDimensionPixelOffset(j.Toolbar_contentInsetEndWithActions, Integer.MIN_VALUE);
        this.f808f = p3VarD.b(j.Toolbar_collapseIcon);
        this.f810g = typedArray.getText(j.Toolbar_collapseContentDescription);
        CharSequence text = typedArray.getText(j.Toolbar_title);
        if (!TextUtils.isEmpty(text)) {
            setTitle(text);
        }
        CharSequence text2 = typedArray.getText(j.Toolbar_subtitle);
        if (!TextUtils.isEmpty(text2)) {
            setSubtitle(text2);
        }
        this.f816j = getContext();
        setPopupTheme(typedArray.getResourceId(j.Toolbar_popupTheme, 0));
        Drawable drawableB = p3VarD.b(j.Toolbar_navigationIcon);
        if (drawableB != null) {
            setNavigationIcon(drawableB);
        }
        CharSequence text3 = typedArray.getText(j.Toolbar_navigationContentDescription);
        if (!TextUtils.isEmpty(text3)) {
            setNavigationContentDescription(text3);
        }
        Drawable drawableB2 = p3VarD.b(j.Toolbar_logo);
        if (drawableB2 != null) {
            setLogo(drawableB2);
        }
        CharSequence text4 = typedArray.getText(j.Toolbar_logoDescription);
        if (!TextUtils.isEmpty(text4)) {
            setLogoDescription(text4);
        }
        int i13 = j.Toolbar_titleTextColor;
        if (typedArray.hasValue(i13)) {
            setTitleTextColor(p3VarD.a(i13));
        }
        int i14 = j.Toolbar_subtitleTextColor;
        if (typedArray.hasValue(i14)) {
            setSubtitleTextColor(p3VarD.a(i14));
        }
        int i15 = j.Toolbar_menu;
        if (typedArray.hasValue(i15)) {
            m(typedArray.getResourceId(i15, 0));
        }
        p3VarD.e();
    }
}
