package e;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.app.UiModeManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.location.LocationManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.LocaleList;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.AttributeSet;
import android.util.LongSparseArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.menu.ExpandedMenuView;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.ContentFrameLayout;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.ViewStubCompat;
import androidx.core.view.f3;
import androidx.core.view.g1;
import androidx.core.view.s1;
import androidx.core.view.z1;
import androidx.lifecycle.Lifecycle$State;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.WeakHashMap;
import l.c4;
import l.e4;
import l.f4;
import l.l1;
import l.p3;
import l.w3;

/* JADX INFO: loaded from: classes.dex */
public final class m0 extends w implements k.n, LayoutInflater.Factory2 {
    public static final androidx.collection.s K0 = new androidx.collection.s(0);
    public static final int[] L0 = {R.attr.windowBackground};
    public static final boolean M0 = !"robolectric".equals(Build.FINGERPRINT);
    public h0 A0;
    public boolean B0;
    public int C0;
    public boolean E0;
    public Rect F0;
    public Rect G0;
    public q0 H0;
    public OnBackInvokedDispatcher I0;
    public OnBackInvokedCallback J0;
    public final p Q;
    public c R;
    public j.k S;
    public CharSequence T;
    public l1 U;
    public xyz.stream.utils.j0 V;
    public nb.c W;
    public j.c X;
    public ActionBarContextView Y;
    public PopupWindow Z;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final Object f25283j;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public l0[] f25292o0;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public z1 f25275b0 = null;
    public final x D0 = new x(this, 0);

    public m0(Context context, Window window, p pVar, Object obj) {
        AppCompatActivity appCompatActivityTryUnwrapContext;
        this.f25299v0 = -100;
        this.f25285k = context;
        this.Q = pVar;
        this.f25283j = obj;
        if ((obj instanceof Dialog) && (appCompatActivityTryUnwrapContext = tryUnwrapContext()) != null) {
            this.f25299v0 = ((m0) appCompatActivityTryUnwrapContext.getDelegate()).f25299v0;
        }
        if (this.f25299v0 == -100) {
            androidx.collection.s sVar = K0;
            Integer num = (Integer) sVar.get(obj.getClass().getName());
            if (num != null) {
                this.f25299v0 = num.intValue();
                sVar.remove(obj.getClass().getName());
            }
        }
        if (window != null) {
            n(window);
        }
        l.c0.d();
    }

    @NonNull
    private Configuration createOverrideAppConfiguration(@NonNull Context context, int i10, @Nullable m0.h hVar, @Nullable Configuration configuration, boolean z10) {
        int i11 = i10 != 1 ? i10 != 2 ? z10 ? 0 : context.getApplicationContext().getResources().getConfiguration().uiMode & 48 : 32 : 16;
        Configuration configuration2 = new Configuration();
        configuration2.fontScale = 0.0f;
        if (configuration != null) {
            configuration2.setTo(configuration);
        }
        configuration2.uiMode = i11 | (configuration2.uiMode & (-49));
        if (hVar != null) {
            d0.d(configuration2, hVar);
        }
        return configuration2;
    }

    @NonNull
    private static Configuration generateConfigDelta(@NonNull Configuration configuration, @Nullable Configuration configuration2) {
        Configuration configuration3 = new Configuration();
        configuration3.fontScale = 0.0f;
        if (configuration2 != null && configuration.diff(configuration2) != 0) {
            float f10 = configuration.fontScale;
            float f11 = configuration2.fontScale;
            if (f10 != f11) {
                configuration3.fontScale = f11;
            }
            int i10 = configuration.mcc;
            int i11 = configuration2.mcc;
            if (i10 != i11) {
                configuration3.mcc = i11;
            }
            int i12 = configuration.mnc;
            int i13 = configuration2.mnc;
            if (i12 != i13) {
                configuration3.mnc = i13;
            }
            int i14 = Build.VERSION.SDK_INT;
            d0.a(configuration, configuration2, configuration3);
            int i15 = configuration.touchscreen;
            int i16 = configuration2.touchscreen;
            if (i15 != i16) {
                configuration3.touchscreen = i16;
            }
            int i17 = configuration.keyboard;
            int i18 = configuration2.keyboard;
            if (i17 != i18) {
                configuration3.keyboard = i18;
            }
            int i19 = configuration.keyboardHidden;
            int i20 = configuration2.keyboardHidden;
            if (i19 != i20) {
                configuration3.keyboardHidden = i20;
            }
            int i21 = configuration.navigation;
            int i22 = configuration2.navigation;
            if (i21 != i22) {
                configuration3.navigation = i22;
            }
            int i23 = configuration.navigationHidden;
            int i24 = configuration2.navigationHidden;
            if (i23 != i24) {
                configuration3.navigationHidden = i24;
            }
            int i25 = configuration.orientation;
            int i26 = configuration2.orientation;
            if (i25 != i26) {
                configuration3.orientation = i26;
            }
            int i27 = configuration.screenLayout & 15;
            int i28 = configuration2.screenLayout;
            if (i27 != (i28 & 15)) {
                configuration3.screenLayout |= i28 & 15;
            }
            int i29 = configuration.screenLayout & 192;
            int i30 = configuration2.screenLayout;
            if (i29 != (i30 & 192)) {
                configuration3.screenLayout |= i30 & 192;
            }
            int i31 = configuration.screenLayout & 48;
            int i32 = configuration2.screenLayout;
            if (i31 != (i32 & 48)) {
                configuration3.screenLayout |= i32 & 48;
            }
            int i33 = configuration.screenLayout & 768;
            int i34 = configuration2.screenLayout;
            if (i33 != (i34 & 768)) {
                configuration3.screenLayout |= i34 & 768;
            }
            if (i14 >= 26) {
                if ((configuration.colorMode & 3) != (configuration2.colorMode & 3)) {
                    configuration3.colorMode |= configuration2.colorMode & 3;
                }
                if ((configuration.colorMode & 12) != (configuration2.colorMode & 12)) {
                    configuration3.colorMode |= configuration2.colorMode & 12;
                }
            }
            int i35 = configuration.uiMode & 15;
            int i36 = configuration2.uiMode;
            if (i35 != (i36 & 15)) {
                configuration3.uiMode |= i36 & 15;
            }
            int i37 = configuration.uiMode & 48;
            int i38 = configuration2.uiMode;
            if (i37 != (i38 & 48)) {
                configuration3.uiMode |= i38 & 48;
            }
            int i39 = configuration.screenWidthDp;
            int i40 = configuration2.screenWidthDp;
            if (i39 != i40) {
                configuration3.screenWidthDp = i40;
            }
            int i41 = configuration.screenHeightDp;
            int i42 = configuration2.screenHeightDp;
            if (i41 != i42) {
                configuration3.screenHeightDp = i42;
            }
            int i43 = configuration.smallestScreenWidthDp;
            int i44 = configuration2.smallestScreenWidthDp;
            if (i43 != i44) {
                configuration3.smallestScreenWidthDp = i44;
            }
            int i45 = configuration.densityDpi;
            int i46 = configuration2.densityDpi;
            if (i45 != i46) {
                configuration3.densityDpi = i46;
            }
        }
        return configuration3;
    }

    @Nullable
    private AppCompatActivity tryUnwrapContext() {
        for (Context baseContext = this.f25285k; baseContext != null; baseContext = ((ContextWrapper) baseContext).getBaseContext()) {
            if (baseContext instanceof AppCompatActivity) {
                return (AppCompatActivity) baseContext;
            }
            if (!(baseContext instanceof ContextWrapper)) {
                break;
            }
        }
        return null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    private boolean updateAppConfiguration(int i10, @Nullable m0.h hVar, boolean z10) {
        int i11;
        boolean z11;
        Configuration configurationCreateOverrideAppConfiguration = createOverrideAppConfiguration(this.f25285k, i10, hVar, null, false);
        boolean z12 = this.f25302y0;
        boolean z13 = true;
        Object obj = this.f25283j;
        Object[] objArr = 0;
        Context context = this.f25285k;
        if (z12 || !(obj instanceof Activity)) {
            this.f25302y0 = true;
            i11 = this.f25301x0;
        } else {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager == null) {
                i11 = 0;
            } else {
                try {
                    ActivityInfo activityInfo = packageManager.getActivityInfo(new ComponentName(context, obj.getClass()), Build.VERSION.SDK_INT >= 29 ? 269221888 : 786432);
                    if (activityInfo != null) {
                        this.f25301x0 = activityInfo.configChanges;
                    }
                } catch (PackageManager.NameNotFoundException unused) {
                    this.f25301x0 = 0;
                }
                this.f25302y0 = true;
                i11 = this.f25301x0;
            }
        }
        Configuration configuration = this.f25298u0;
        if (configuration == null) {
            configuration = context.getResources().getConfiguration();
        }
        int i12 = configuration.uiMode & 48;
        int i13 = configurationCreateOverrideAppConfiguration.uiMode & 48;
        m0.h hVarB = d0.b(configuration);
        m0.h hVarB2 = hVar == null ? null : d0.b(configurationCreateOverrideAppConfiguration);
        int i14 = i12 != i13 ? 512 : 0;
        if (hVarB2 != null && !hVarB.equals(hVarB2)) {
            i14 |= 8196;
        }
        if (((~i11) & i14) != 0 && z10 && this.f25295r0 && ((M0 || this.f25296s0) && (obj instanceof Activity) && !((Activity) obj).isChild())) {
            int i15 = Build.VERSION.SDK_INT;
            if (i15 >= 31 && (i14 & 8192) != 0) {
                ((Activity) obj).getWindow().getDecorView().setLayoutDirection(configurationCreateOverrideAppConfiguration.getLayoutDirection());
            }
            Activity activity = (Activity) obj;
            int i16 = androidx.core.app.f.f1549b;
            if (i15 >= 28) {
                activity.recreate();
            } else {
                new Handler(activity.getMainLooper()).post(new androidx.core.app.a(activity, objArr == true ? 1 : 0));
            }
            z11 = true;
        } else {
            z11 = false;
        }
        if (z11 || i14 == 0) {
            z13 = z11;
        } else {
            updateResourcesConfiguration(i13, hVarB2, (i14 & i11) == i14, null);
        }
        if (z13 && (obj instanceof AppCompatActivity)) {
            if ((i14 & 512) != 0) {
                ((AppCompatActivity) obj).onNightModeChanged(i10);
            }
            if ((i14 & 4) != 0) {
                ((AppCompatActivity) obj).onLocalesChanged(hVar);
            }
        }
        if (hVarB2 != null) {
            d0.c(d0.b(context.getResources().getConfiguration()));
        }
        return z13;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0077  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private void updateResourcesConfiguration(int i10, @Nullable m0.h hVar, boolean z10, @Nullable Configuration configuration) {
        Object obj;
        Object obj2;
        Context context = this.f25285k;
        Resources resources = context.getResources();
        Configuration configuration2 = new Configuration(resources.getConfiguration());
        if (configuration != null) {
            configuration2.updateFrom(configuration);
        }
        configuration2.uiMode = i10 | (resources.getConfiguration().uiMode & (-49));
        if (hVar != null) {
            d0.d(configuration2, hVar);
        }
        LongSparseArray longSparseArray = null;
        resources.updateConfiguration(configuration2, null);
        int i11 = Build.VERSION.SDK_INT;
        if (i11 < 26 && i11 < 28) {
            if (!kotlinx.coroutines.y.f29581h) {
                try {
                    Field declaredField = Resources.class.getDeclaredField("mResourcesImpl");
                    kotlinx.coroutines.y.f29580g = declaredField;
                    declaredField.setAccessible(true);
                } catch (NoSuchFieldException unused) {
                }
                kotlinx.coroutines.y.f29581h = true;
            }
            Field field = kotlinx.coroutines.y.f29580g;
            if (field != null) {
                try {
                    obj = field.get(resources);
                } catch (IllegalAccessException unused2) {
                    obj = null;
                }
                if (obj != null) {
                    if (!kotlinx.coroutines.y.f29575b) {
                        try {
                            Field declaredField2 = obj.getClass().getDeclaredField("mDrawableCache");
                            kotlinx.coroutines.y.f29574a = declaredField2;
                            declaredField2.setAccessible(true);
                        } catch (NoSuchFieldException unused3) {
                        }
                        kotlinx.coroutines.y.f29575b = true;
                    }
                    Field field2 = kotlinx.coroutines.y.f29574a;
                    if (field2 != null) {
                        try {
                            obj2 = field2.get(obj);
                        } catch (IllegalAccessException unused4) {
                            obj2 = null;
                        }
                        if (obj2 != null) {
                            if (!kotlinx.coroutines.y.f29577d) {
                                try {
                                    kotlinx.coroutines.y.f29576c = Class.forName("android.content.res.ThemedResourceCache");
                                } catch (ClassNotFoundException unused5) {
                                }
                                kotlinx.coroutines.y.f29577d = true;
                            }
                            Class cls = kotlinx.coroutines.y.f29576c;
                            if (cls != null) {
                                if (!kotlinx.coroutines.y.f29579f) {
                                    try {
                                        Field declaredField3 = cls.getDeclaredField("mUnthemedEntries");
                                        kotlinx.coroutines.y.f29578e = declaredField3;
                                        declaredField3.setAccessible(true);
                                    } catch (NoSuchFieldException unused6) {
                                    }
                                    kotlinx.coroutines.y.f29579f = true;
                                }
                                Field field3 = kotlinx.coroutines.y.f29578e;
                                if (field3 != null) {
                                    try {
                                        longSparseArray = (LongSparseArray) field3.get(obj2);
                                    } catch (IllegalAccessException unused7) {
                                    }
                                    if (longSparseArray != null) {
                                        longSparseArray.clear();
                                    }
                                }
                            }
                        }
                    } else {
                        obj2 = null;
                        if (obj2 != null) {
                        }
                    }
                }
            }
        }
        int i12 = this.f25300w0;
        if (i12 != 0) {
            context.setTheme(i12);
            context.getTheme().applyStyle(this.f25300w0, true);
        }
        if (z10) {
            Object obj3 = this.f25283j;
            if (obj3 instanceof Activity) {
                Activity activity = (Activity) obj3;
                if (activity instanceof androidx.lifecycle.p) {
                    if (((androidx.lifecycle.r) ((androidx.lifecycle.p) activity).getLifecycle()).f2692c.compareTo(Lifecycle$State.f2633c) >= 0) {
                        activity.onConfigurationChanged(configuration2);
                    }
                } else {
                    if (!this.f25296s0 || this.f25297t0) {
                        return;
                    }
                    activity.onConfigurationChanged(configuration2);
                }
            }
        }
    }

    public final boolean A() {
        boolean z10 = this.f25294q0;
        this.f25294q0 = false;
        l0 l0VarW = w(0);
        if (l0VarW.f25269m) {
            if (!z10) {
                q(l0VarW, true);
            }
            return true;
        }
        j.c cVar = this.X;
        if (cVar != null) {
            cVar.a();
            return true;
        }
        x();
        c cVar2 = this.R;
        return cVar2 != null && cVar2.b();
    }

    /* JADX WARN: Code restructure failed: missing block: B:87:0x0172, code lost:
    
        if (r3.f28872g.getCount() > 0) goto L88;
     */
    /* JADX WARN: Removed duplicated region for block: B:100:0x01d0  */
    /* JADX WARN: Removed duplicated region for block: B:104:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void B(l0 l0Var, KeyEvent keyEvent) {
        int i10;
        ViewGroup.LayoutParams layoutParams;
        if (l0Var.f25269m || this.f25297t0) {
            return;
        }
        int i11 = l0Var.f25257a;
        Context context = this.f25285k;
        if (i11 == 0 && (context.getResources().getConfiguration().screenLayout & 15) == 4) {
            return;
        }
        Window.Callback callback = this.f25287l.getCallback();
        int i12 = 1;
        if (callback != null && !callback.onMenuOpened(i11, l0Var.f25264h)) {
            q(l0Var, true);
            return;
        }
        WindowManager windowManager = (WindowManager) context.getSystemService("window");
        if (windowManager == null || !D(l0Var, keyEvent)) {
            return;
        }
        k0 k0Var = l0Var.f25261e;
        if (k0Var != null && !l0Var.f25270n) {
            View view = l0Var.f25263g;
            if (view != null && (layoutParams = view.getLayoutParams()) != null && layoutParams.width == -1) {
                i10 = -1;
            }
            l0Var.f25268l = false;
            WindowManager.LayoutParams layoutParams2 = new WindowManager.LayoutParams(i10, -2, 0, 0, 1002, 8519680, -3);
            layoutParams2.gravity = l0Var.f25259c;
            layoutParams2.windowAnimations = l0Var.f25260d;
            windowManager.addView(l0Var.f25261e, layoutParams2);
            l0Var.f25269m = true;
            if (i11 != 0) {
                F();
                return;
            }
            return;
        }
        if (k0Var == null) {
            x();
            c cVar = this.R;
            Context contextE = cVar != null ? cVar.e() : null;
            if (contextE != null) {
                context = contextE;
            }
            TypedValue typedValue = new TypedValue();
            Resources.Theme themeNewTheme = context.getResources().newTheme();
            themeNewTheme.setTo(context.getTheme());
            themeNewTheme.resolveAttribute(d.a.actionBarPopupTheme, typedValue, true);
            int i13 = typedValue.resourceId;
            if (i13 != 0) {
                themeNewTheme.applyStyle(i13, true);
            }
            themeNewTheme.resolveAttribute(d.a.panelMenuListTheme, typedValue, true);
            int i14 = typedValue.resourceId;
            if (i14 != 0) {
                themeNewTheme.applyStyle(i14, true);
            } else {
                themeNewTheme.applyStyle(d.i.Theme_AppCompat_CompactMenu, true);
            }
            j.e eVar = new j.e(context, 0);
            eVar.getTheme().setTo(themeNewTheme);
            l0Var.f25266j = eVar;
            TypedArray typedArrayObtainStyledAttributes = eVar.obtainStyledAttributes(d.j.AppCompatTheme);
            l0Var.f25258b = typedArrayObtainStyledAttributes.getResourceId(d.j.AppCompatTheme_panelBackground, 0);
            l0Var.f25260d = typedArrayObtainStyledAttributes.getResourceId(d.j.AppCompatTheme_android_windowAnimationStyle, 0);
            typedArrayObtainStyledAttributes.recycle();
            l0Var.f25261e = new k0(this, l0Var.f25266j);
            l0Var.f25259c = 81;
        } else if (l0Var.f25270n && k0Var.getChildCount() > 0) {
            l0Var.f25261e.removeAllViews();
        }
        View view2 = l0Var.f25263g;
        if (view2 == null) {
            if (l0Var.f25264h != null) {
                if (this.W == null) {
                    this.W = new nb.c(this, i12);
                }
                nb.c cVar2 = this.W;
                if (l0Var.f25265i == null) {
                    k.l lVar = new k.l(l0Var.f25266j, d.g.abc_list_menu_item_layout);
                    l0Var.f25265i = lVar;
                    lVar.f28871f = cVar2;
                    k.p pVar = l0Var.f25264h;
                    pVar.b(lVar, pVar.f28880a);
                }
                k.l lVar2 = l0Var.f25265i;
                k0 k0Var2 = l0Var.f25261e;
                if (lVar2.f28869d == null) {
                    lVar2.f28869d = (ExpandedMenuView) lVar2.f28867b.inflate(d.g.abc_expanded_menu_layout, (ViewGroup) k0Var2, false);
                    if (lVar2.f28872g == null) {
                        lVar2.f28872g = new k.k(lVar2);
                    }
                    lVar2.f28869d.setAdapter((ListAdapter) lVar2.f28872g);
                    lVar2.f28869d.setOnItemClickListener(lVar2);
                }
                ExpandedMenuView expandedMenuView = lVar2.f28869d;
                l0Var.f25262f = expandedMenuView;
                if (expandedMenuView != null) {
                }
            }
            l0Var.f25270n = true;
            return;
        }
        l0Var.f25262f = view2;
        if (l0Var.f25262f != null) {
            if (l0Var.f25263g == null) {
                k.l lVar3 = l0Var.f25265i;
                if (lVar3.f28872g == null) {
                    lVar3.f28872g = new k.k(lVar3);
                }
            }
            ViewGroup.LayoutParams layoutParams3 = l0Var.f25262f.getLayoutParams();
            if (layoutParams3 == null) {
                layoutParams3 = new ViewGroup.LayoutParams(-2, -2);
            }
            l0Var.f25261e.setBackgroundResource(l0Var.f25258b);
            ViewParent parent = l0Var.f25262f.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(l0Var.f25262f);
            }
            l0Var.f25261e.addView(l0Var.f25262f, layoutParams3);
            if (!l0Var.f25262f.hasFocus()) {
                l0Var.f25262f.requestFocus();
            }
        }
        l0Var.f25270n = true;
        return;
        i10 = -2;
        l0Var.f25268l = false;
        WindowManager.LayoutParams layoutParams22 = new WindowManager.LayoutParams(i10, -2, 0, 0, 1002, 8519680, -3);
        layoutParams22.gravity = l0Var.f25259c;
        layoutParams22.windowAnimations = l0Var.f25260d;
        windowManager.addView(l0Var.f25261e, layoutParams22);
        l0Var.f25269m = true;
        if (i11 != 0) {
        }
    }

    public final boolean C(l0 l0Var, int i10, KeyEvent keyEvent) {
        k.p pVar;
        if (keyEvent.isSystem()) {
            return false;
        }
        if ((l0Var.f25267k || D(l0Var, keyEvent)) && (pVar = l0Var.f25264h) != null) {
            return pVar.performShortcut(i10, keyEvent, 1);
        }
        return false;
    }

    public final boolean D(l0 l0Var, KeyEvent keyEvent) {
        l1 l1Var;
        l1 l1Var2;
        Resources.Theme themeNewTheme;
        l1 l1Var3;
        l1 l1Var4;
        if (this.f25297t0) {
            return false;
        }
        int i10 = 1;
        if (l0Var.f25267k) {
            return true;
        }
        l0 l0Var2 = this.f25293p0;
        if (l0Var2 != null && l0Var2 != l0Var) {
            q(l0Var2, false);
        }
        Window.Callback callback = this.f25287l.getCallback();
        int i11 = l0Var.f25257a;
        if (callback != null) {
            l0Var.f25263g = callback.onCreatePanelView(i11);
        }
        boolean z10 = i11 == 0 || i11 == 108;
        if (z10 && (l1Var4 = this.U) != null) {
            l1Var4.setMenuPrepared();
        }
        if (l0Var.f25263g == null && (!z10 || !(this.R instanceof u0))) {
            k.p pVar = l0Var.f25264h;
            if (pVar == null || l0Var.f25271o) {
                if (pVar == null) {
                    Context context = this.f25285k;
                    if ((i11 == 0 || i11 == 108) && this.U != null) {
                        TypedValue typedValue = new TypedValue();
                        Resources.Theme theme = context.getTheme();
                        theme.resolveAttribute(d.a.actionBarTheme, typedValue, true);
                        if (typedValue.resourceId != 0) {
                            themeNewTheme = context.getResources().newTheme();
                            themeNewTheme.setTo(theme);
                            themeNewTheme.applyStyle(typedValue.resourceId, true);
                            themeNewTheme.resolveAttribute(d.a.actionBarWidgetTheme, typedValue, true);
                        } else {
                            theme.resolveAttribute(d.a.actionBarWidgetTheme, typedValue, true);
                            themeNewTheme = null;
                        }
                        if (typedValue.resourceId != 0) {
                            if (themeNewTheme == null) {
                                themeNewTheme = context.getResources().newTheme();
                                themeNewTheme.setTo(theme);
                            }
                            themeNewTheme.applyStyle(typedValue.resourceId, true);
                        }
                        if (themeNewTheme != null) {
                            j.e eVar = new j.e(context, 0);
                            eVar.getTheme().setTo(themeNewTheme);
                            context = eVar;
                        }
                    }
                    k.p pVar2 = new k.p(context);
                    pVar2.f28884e = this;
                    k.p pVar3 = l0Var.f25264h;
                    if (pVar2 != pVar3) {
                        if (pVar3 != null) {
                            pVar3.r(l0Var.f25265i);
                        }
                        l0Var.f25264h = pVar2;
                        k.l lVar = l0Var.f25265i;
                        if (lVar != null) {
                            pVar2.b(lVar, pVar2.f28880a);
                        }
                    }
                    if (l0Var.f25264h == null) {
                        return false;
                    }
                }
                if (z10 && (l1Var2 = this.U) != null) {
                    if (this.V == null) {
                        this.V = new xyz.stream.utils.j0(this, i10);
                    }
                    l1Var2.setMenu(l0Var.f25264h, this.V);
                }
                l0Var.f25264h.y();
                if (!callback.onCreatePanelMenu(i11, l0Var.f25264h)) {
                    k.p pVar4 = l0Var.f25264h;
                    if (pVar4 != null) {
                        if (pVar4 != null) {
                            pVar4.r(l0Var.f25265i);
                        }
                        l0Var.f25264h = null;
                    }
                    if (z10 && (l1Var = this.U) != null) {
                        l1Var.setMenu(null, this.V);
                    }
                    return false;
                }
                l0Var.f25271o = false;
            }
            l0Var.f25264h.y();
            Bundle bundle = l0Var.f25272p;
            if (bundle != null) {
                l0Var.f25264h.s(bundle);
                l0Var.f25272p = null;
            }
            if (!callback.onPreparePanel(0, l0Var.f25263g, l0Var.f25264h)) {
                if (z10 && (l1Var3 = this.U) != null) {
                    l1Var3.setMenu(null, this.V);
                }
                l0Var.f25264h.x();
                return false;
            }
            l0Var.f25264h.setQwertyMode(KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() != 1);
            l0Var.f25264h.x();
        }
        l0Var.f25267k = true;
        l0Var.f25268l = false;
        this.f25293p0 = l0Var;
        return true;
    }

    public final void E() {
        if (this.f25276c0) {
            throw new AndroidRuntimeException("Window feature must be requested before adding content");
        }
    }

    public final void F() {
        OnBackInvokedCallback onBackInvokedCallback;
        if (Build.VERSION.SDK_INT >= 33) {
            boolean z10 = false;
            if (this.I0 != null && (w(0).f25269m || this.X != null)) {
                z10 = true;
            }
            if (z10 && this.J0 == null) {
                this.J0 = f0.b(this.I0, this);
            } else {
                if (z10 || (onBackInvokedCallback = this.J0) == null) {
                    return;
                }
                f0.c(this.I0, onBackInvokedCallback);
                this.J0 = null;
            }
        }
    }

    @Override // e.w
    public final Context a(Context context) {
        this.f25295r0 = true;
        int i10 = this.f25299v0;
        if (i10 == -100) {
            i10 = w.f25348b;
        }
        int iZ = z(context, i10);
        int i11 = 0;
        if (w.c(context) && w.c(context)) {
            if (Build.VERSION.SDK_INT < 33) {
                synchronized (w.f25355i) {
                    try {
                        m0.h hVar = w.f25349c;
                        if (hVar == null) {
                            if (w.f25350d == null) {
                                w.f25350d = m0.h.forLanguageTags(androidx.core.app.k.b(context));
                            }
                            if (!((m0.j) w.f25350d.f30287a).f30288a.isEmpty()) {
                                w.f25349c = w.f25350d;
                            }
                        } else if (!hVar.equals(w.f25350d)) {
                            m0.h hVar2 = w.f25349c;
                            w.f25350d = hVar2;
                            androidx.core.app.k.a(context, ((m0.j) hVar2.f30287a).f30288a.toLanguageTags());
                        }
                    } finally {
                    }
                }
            } else if (!w.f25352f) {
                w.f25347a.execute(new q(context, i11));
            }
        }
        m0.h hVarCalculateApplicationLocales = calculateApplicationLocales(context);
        if (context instanceof ContextThemeWrapper) {
            try {
                ((ContextThemeWrapper) context).applyOverrideConfiguration(createOverrideAppConfiguration(context, iZ, hVarCalculateApplicationLocales, null, false));
                return context;
            } catch (IllegalStateException unused) {
            }
        }
        if (context instanceof j.e) {
            try {
                ((j.e) context).a(createOverrideAppConfiguration(context, iZ, hVarCalculateApplicationLocales, null, false));
                return context;
            } catch (IllegalStateException unused2) {
            }
        }
        if (!M0) {
            return context;
        }
        Configuration configuration = new Configuration();
        configuration.uiMode = -1;
        configuration.fontScale = 0.0f;
        Configuration configuration2 = context.createConfigurationContext(configuration).getResources().getConfiguration();
        Configuration configuration3 = context.getResources().getConfiguration();
        configuration2.uiMode = configuration3.uiMode;
        Configuration configurationCreateOverrideAppConfiguration = createOverrideAppConfiguration(context, iZ, hVarCalculateApplicationLocales, !configuration2.equals(configuration3) ? generateConfigDelta(configuration2, configuration3) : null, true);
        j.e eVar = new j.e(context, d.i.Theme_AppCompat_Empty);
        eVar.a(configurationCreateOverrideAppConfiguration);
        try {
            if (context.getTheme() != null) {
                Resources.Theme theme = eVar.getTheme();
                if (Build.VERSION.SDK_INT >= 29) {
                    androidx.core.app.b0.m(theme);
                } else {
                    synchronized (i0.q.f26510a) {
                        if (!i0.q.f26512c) {
                            try {
                                Method declaredMethod = Resources.Theme.class.getDeclaredMethod("rebase", new Class[0]);
                                i0.q.f26511b = declaredMethod;
                                declaredMethod.setAccessible(true);
                            } catch (NoSuchMethodException unused3) {
                            }
                            i0.q.f26512c = true;
                        }
                        Method method = i0.q.f26511b;
                        if (method != null) {
                            try {
                                method.invoke(theme, new Object[0]);
                            } catch (IllegalAccessException | InvocationTargetException unused4) {
                                i0.q.f26511b = null;
                            }
                        }
                    }
                }
            }
        } catch (NullPointerException unused5) {
        }
        return eVar;
    }

    @Override // e.w
    public final void b() {
        if (this.R != null) {
            x();
            if (this.R.g()) {
                return;
            }
            y(0);
        }
    }

    @Nullable
    public m0.h calculateApplicationLocales(@NonNull Context context) {
        m0.h requestedAppLocales;
        m0.h hVar;
        if (Build.VERSION.SDK_INT >= 33 || (requestedAppLocales = w.getRequestedAppLocales()) == null) {
            return null;
        }
        m0.h hVarB = d0.b(context.getApplicationContext().getResources().getConfiguration());
        m0.i iVar = requestedAppLocales.f30287a;
        if (((m0.j) iVar).f30288a.isEmpty()) {
            hVar = m0.h.f30286b;
        } else {
            LinkedHashSet linkedHashSet = new LinkedHashSet();
            int i10 = 0;
            while (i10 < ((m0.j) hVarB.f30287a).f30288a.size() + ((m0.j) iVar).f30288a.size()) {
                Locale locale = i10 < ((m0.j) iVar).f30288a.size() ? requestedAppLocales.get(i10) : hVarB.get(i10 - ((m0.j) iVar).f30288a.size());
                if (locale != null) {
                    linkedHashSet.add(locale);
                }
                i10++;
            }
            hVar = new m0.h(new m0.j(new LocaleList((Locale[]) linkedHashSet.toArray(new Locale[linkedHashSet.size()]))));
        }
        return ((m0.j) hVar.f30287a).f30288a.isEmpty() ? hVarB : hVar;
    }

    @Override // e.w
    public final View createView(View view, String str, Context context, AttributeSet attributeSet) {
        if (this.H0 == null) {
            int[] iArr = d.j.AppCompatTheme;
            Context context2 = this.f25285k;
            TypedArray typedArrayObtainStyledAttributes = context2.obtainStyledAttributes(iArr);
            String string = typedArrayObtainStyledAttributes.getString(d.j.AppCompatTheme_viewInflaterClass);
            typedArrayObtainStyledAttributes.recycle();
            if (string == null) {
                this.H0 = new q0();
            } else {
                try {
                    this.H0 = (q0) context2.getClassLoader().loadClass(string).getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
                } catch (Throwable unused) {
                    this.H0 = new q0();
                }
            }
        }
        q0 q0Var = this.H0;
        int i10 = c4.f29659a;
        return q0Var.createView(view, str, context, attributeSet, false, false, true, false);
    }

    @Override // e.w
    public final void d(Bundle bundle) {
        String parentActivityName;
        this.f25295r0 = true;
        m(false, true);
        u();
        Object obj = this.f25283j;
        if (obj instanceof Activity) {
            try {
                parentActivityName = androidx.core.app.y.getParentActivityName((Activity) obj);
            } catch (IllegalArgumentException unused) {
                parentActivityName = null;
            }
            if (parentActivityName != null) {
                c cVar = this.R;
                if (cVar == null) {
                    this.E0 = true;
                } else {
                    cVar.n(true);
                }
            }
            synchronized (w.f25354h) {
                w.g(this);
                w.f25353g.add(new WeakReference(this));
            }
        }
        this.f25298u0 = new Configuration(this.f25285k.getResources().getConfiguration());
        this.f25296s0 = true;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x004d  */
    @Override // e.w
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void e() {
        if (this.f25283j instanceof Activity) {
            synchronized (w.f25354h) {
                w.g(this);
            }
        }
        if (this.B0) {
            this.f25287l.getDecorView().removeCallbacks(this.D0);
        }
        this.f25297t0 = true;
        if (this.f25299v0 != -100) {
            Object obj = this.f25283j;
            if ((obj instanceof Activity) && ((Activity) obj).isChangingConfigurations()) {
                K0.put(this.f25283j.getClass().getName(), Integer.valueOf(this.f25299v0));
            } else {
                K0.remove(this.f25283j.getClass().getName());
            }
        }
        c cVar = this.R;
        if (cVar != null) {
            cVar.j();
        }
        h0 h0Var = this.z0;
        if (h0Var != null) {
            h0Var.a();
        }
        h0 h0Var2 = this.A0;
        if (h0Var2 != null) {
            h0Var2.a();
        }
    }

    @Override // k.n
    public final boolean f(k.p pVar, MenuItem menuItem) {
        l0 l0Var;
        Window.Callback callback = this.f25287l.getCallback();
        if (callback != null && !this.f25297t0) {
            k.p pVarK = pVar.k();
            l0[] l0VarArr = this.f25292o0;
            int length = l0VarArr != null ? l0VarArr.length : 0;
            int i10 = 0;
            while (true) {
                if (i10 < length) {
                    l0Var = l0VarArr[i10];
                    if (l0Var != null && l0Var.f25264h == pVarK) {
                        break;
                    }
                    i10++;
                } else {
                    l0Var = null;
                    break;
                }
            }
            if (l0Var != null) {
                return callback.onMenuItemSelected(l0Var.f25257a, menuItem);
            }
        }
        return false;
    }

    @Override // e.w
    @Nullable
    public <T extends View> T findViewById(@IdRes int i10) {
        t();
        return (T) this.f25287l.findViewById(i10);
    }

    @Override // e.w
    public final Context getContextForDelegate() {
        return this.f25285k;
    }

    @Override // e.w
    public final d getDrawerToggleDelegate() {
        return new xyz.stream.utils.f0(this, 1);
    }

    @Override // e.w
    public final c getSupportActionBar() {
        x();
        return this.R;
    }

    @Override // e.w
    public final boolean h(int i10) {
        if (i10 == 8) {
            i10 = 108;
        } else if (i10 == 9) {
            i10 = 109;
        }
        if (this.f25290m0 && i10 == 108) {
            return false;
        }
        if (this.f25282i0 && i10 == 1) {
            this.f25282i0 = false;
        }
        if (i10 == 1) {
            E();
            this.f25290m0 = true;
            return true;
        }
        if (i10 == 2) {
            E();
            this.f25280g0 = true;
            return true;
        }
        if (i10 == 5) {
            E();
            this.f25281h0 = true;
            return true;
        }
        if (i10 == 10) {
            E();
            this.f25286k0 = true;
            return true;
        }
        if (i10 == 108) {
            E();
            this.f25282i0 = true;
            return true;
        }
        if (i10 != 109) {
            return this.f25287l.requestFeature(i10);
        }
        E();
        this.f25284j0 = true;
        return true;
    }

    @Override // e.w
    public final void i(int i10) {
        t();
        ViewGroup viewGroup = (ViewGroup) this.f25277d0.findViewById(R.id.content);
        viewGroup.removeAllViews();
        LayoutInflater.from(this.f25285k).inflate(i10, viewGroup);
        this.f25289m.a(this.f25287l.getCallback());
    }

    @Override // e.w
    public final void j(View view) {
        t();
        ViewGroup viewGroup = (ViewGroup) this.f25277d0.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view);
        this.f25289m.a(this.f25287l.getCallback());
    }

    @Override // e.w
    public final void k(View view, ViewGroup.LayoutParams layoutParams) {
        t();
        ViewGroup viewGroup = (ViewGroup) this.f25277d0.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view, layoutParams);
        this.f25289m.a(this.f25287l.getCallback());
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x0048, code lost:
    
        if (r6.g() != false) goto L20;
     */
    @Override // k.n
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void l(k.p pVar) {
        ActionMenuView actionMenuView;
        l.p pVar2;
        l1 l1Var = this.U;
        if (l1Var != null) {
            ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) l1Var;
            actionBarOverlayLayout.e();
            Toolbar toolbar = ((w3) actionBarOverlayLayout.f613e).f29883a;
            if (toolbar.getVisibility() == 0 && (actionMenuView = toolbar.f798a) != null && actionMenuView.V) {
                if (ViewConfiguration.get(this.f25285k).hasPermanentMenuKey()) {
                    ActionBarOverlayLayout actionBarOverlayLayout2 = (ActionBarOverlayLayout) this.U;
                    actionBarOverlayLayout2.e();
                    ActionMenuView actionMenuView2 = ((w3) actionBarOverlayLayout2.f613e).f29883a.f798a;
                    if (actionMenuView2 != null) {
                        l.p pVar3 = actionMenuView2.W;
                        if (pVar3 != null) {
                            if (pVar3.Y == null) {
                            }
                        }
                    }
                }
                Window.Callback callback = this.f25287l.getCallback();
                ActionBarOverlayLayout actionBarOverlayLayout3 = (ActionBarOverlayLayout) this.U;
                actionBarOverlayLayout3.e();
                if (((w3) actionBarOverlayLayout3.f613e).f29883a.p()) {
                    ActionBarOverlayLayout actionBarOverlayLayout4 = (ActionBarOverlayLayout) this.U;
                    actionBarOverlayLayout4.e();
                    ActionMenuView actionMenuView3 = ((w3) actionBarOverlayLayout4.f613e).f29883a.f798a;
                    if (actionMenuView3 != null && (pVar2 = actionMenuView3.W) != null) {
                        pVar2.e();
                    }
                    if (this.f25297t0) {
                        return;
                    }
                    callback.onPanelClosed(108, w(0).f25264h);
                    return;
                }
                if (callback == null || this.f25297t0) {
                    return;
                }
                if (this.B0 && (1 & this.C0) != 0) {
                    View decorView = this.f25287l.getDecorView();
                    x xVar = this.D0;
                    decorView.removeCallbacks(xVar);
                    xVar.run();
                }
                l0 l0VarW = w(0);
                k.p pVar4 = l0VarW.f25264h;
                if (pVar4 == null || l0VarW.f25271o || !callback.onPreparePanel(0, l0VarW.f25263g, pVar4)) {
                    return;
                }
                callback.onMenuOpened(108, l0VarW.f25264h);
                ActionBarOverlayLayout actionBarOverlayLayout5 = (ActionBarOverlayLayout) this.U;
                actionBarOverlayLayout5.e();
                ((w3) actionBarOverlayLayout5.f613e).f29883a.v();
                return;
            }
        }
        l0 l0VarW2 = w(0);
        l0VarW2.f25270n = true;
        q(l0VarW2, false);
        B(l0VarW2, null);
    }

    public final boolean m(boolean z10, boolean z11) {
        if (this.f25297t0) {
            return false;
        }
        int i10 = this.f25299v0;
        if (i10 == -100) {
            i10 = w.f25348b;
        }
        Context context = this.f25285k;
        int iZ = z(context, i10);
        m0.h hVarCalculateApplicationLocales = Build.VERSION.SDK_INT < 33 ? calculateApplicationLocales(context) : null;
        if (!z11 && hVarCalculateApplicationLocales != null) {
            hVarCalculateApplicationLocales = d0.b(context.getResources().getConfiguration());
        }
        boolean zUpdateAppConfiguration = updateAppConfiguration(iZ, hVarCalculateApplicationLocales, z10);
        if (i10 == 0) {
            v(context).c();
        } else {
            h0 h0Var = this.z0;
            if (h0Var != null) {
                h0Var.a();
            }
        }
        if (i10 == 3) {
            if (this.A0 == null) {
                this.A0 = new h0(this, context);
            }
            this.A0.c();
        } else {
            h0 h0Var2 = this.A0;
            if (h0Var2 != null) {
                h0Var2.a();
            }
        }
        return zUpdateAppConfiguration;
    }

    public final void n(Window window) {
        if (this.f25287l != null) {
            throw new IllegalStateException("AppCompat has already installed itself into the Window");
        }
        Window.Callback callback = window.getCallback();
        if (callback instanceof g0) {
            throw new IllegalStateException("AppCompat has already installed itself into the Window");
        }
        g0 g0Var = new g0(this, callback);
        this.f25289m = g0Var;
        window.setCallback(g0Var);
        int[] iArr = L0;
        Context context = this.f25285k;
        p3 p3Var = new p3(context, context.obtainStyledAttributes((AttributeSet) null, iArr));
        Drawable drawableC = p3Var.c(0);
        if (drawableC != null) {
            window.setBackgroundDrawable(drawableC);
        }
        p3Var.e();
        this.f25287l = window;
        if (Build.VERSION.SDK_INT < 33 || this.I0 != null) {
            return;
        }
        setOnBackInvokedDispatcher(null);
    }

    public final void o(int i10, l0 l0Var, k.p pVar) {
        if (pVar == null) {
            if (l0Var == null && i10 >= 0) {
                l0[] l0VarArr = this.f25292o0;
                if (i10 < l0VarArr.length) {
                    l0Var = l0VarArr[i10];
                }
            }
            if (l0Var != null) {
                pVar = l0Var.f25264h;
            }
        }
        if ((l0Var == null || l0Var.f25269m) && !this.f25297t0) {
            g0 g0Var = this.f25289m;
            Window.Callback callback = this.f25287l.getCallback();
            g0Var.getClass();
            try {
                g0Var.f25199e = true;
                callback.onPanelClosed(i10, pVar);
            } finally {
                g0Var.f25199e = false;
            }
        }
    }

    @Override // android.view.LayoutInflater.Factory
    public final View onCreateView(String str, Context context, AttributeSet attributeSet) {
        return createView(null, str, context, attributeSet);
    }

    public final void p(k.p pVar) {
        l.p pVar2;
        if (this.f25291n0) {
            return;
        }
        this.f25291n0 = true;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) this.U;
        actionBarOverlayLayout.e();
        ActionMenuView actionMenuView = ((w3) actionBarOverlayLayout.f613e).f29883a.f798a;
        if (actionMenuView != null && (pVar2 = actionMenuView.W) != null) {
            pVar2.e();
            l.j jVar = pVar2.X;
            if (jVar != null && jVar.b()) {
                jVar.f28955j.dismiss();
            }
        }
        Window.Callback callback = this.f25287l.getCallback();
        if (callback != null && !this.f25297t0) {
            callback.onPanelClosed(108, pVar);
        }
        this.f25291n0 = false;
    }

    public final void q(l0 l0Var, boolean z10) {
        k0 k0Var;
        l1 l1Var;
        if (z10 && l0Var.f25257a == 0 && (l1Var = this.U) != null) {
            ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) l1Var;
            actionBarOverlayLayout.e();
            if (((w3) actionBarOverlayLayout.f613e).f29883a.p()) {
                p(l0Var.f25264h);
                return;
            }
        }
        WindowManager windowManager = (WindowManager) this.f25285k.getSystemService("window");
        if (windowManager != null && l0Var.f25269m && (k0Var = l0Var.f25261e) != null) {
            windowManager.removeView(k0Var);
            if (z10) {
                o(l0Var.f25257a, l0Var, null);
            }
        }
        l0Var.f25267k = false;
        l0Var.f25268l = false;
        l0Var.f25269m = false;
        l0Var.f25262f = null;
        l0Var.f25270n = true;
        if (this.f25293p0 == l0Var) {
            this.f25293p0 = null;
        }
        if (l0Var.f25257a == 0) {
            F();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:67:0x00f2  */
    /* JADX WARN: Removed duplicated region for block: B:99:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean r(KeyEvent keyEvent) {
        View decorView;
        boolean zV;
        ActionMenuView actionMenuView;
        l.p pVar;
        Object obj = this.f25283j;
        if (((obj instanceof androidx.core.view.u) || (obj instanceof o0)) && (decorView = this.f25287l.getDecorView()) != null && androidx.core.view.v.a(decorView, keyEvent)) {
            return true;
        }
        if (keyEvent.getKeyCode() == 82) {
            g0 g0Var = this.f25289m;
            Window.Callback callback = this.f25287l.getCallback();
            g0Var.getClass();
            try {
                g0Var.f25198d = true;
                if (callback.dispatchKeyEvent(keyEvent)) {
                    return true;
                }
            } finally {
                g0Var.f25198d = false;
            }
        }
        int keyCode = keyEvent.getKeyCode();
        if (keyEvent.getAction() == 0) {
            if (keyCode == 4) {
                this.f25294q0 = (keyEvent.getFlags() & 128) != 0;
            } else if (keyCode == 82) {
                if (keyEvent.getRepeatCount() != 0) {
                    return true;
                }
                l0 l0VarW = w(0);
                if (l0VarW.f25269m) {
                    return true;
                }
                D(l0VarW, keyEvent);
                return true;
            }
        } else if (keyCode != 4) {
            if (keyCode == 82) {
                if (this.X != null) {
                    return true;
                }
                l0 l0VarW2 = w(0);
                l1 l1Var = this.U;
                Context context = this.f25285k;
                if (l1Var != null) {
                    ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) l1Var;
                    actionBarOverlayLayout.e();
                    Toolbar toolbar = ((w3) actionBarOverlayLayout.f613e).f29883a;
                    if (toolbar.getVisibility() != 0 || (actionMenuView = toolbar.f798a) == null || !actionMenuView.V || ViewConfiguration.get(context).hasPermanentMenuKey()) {
                        boolean z10 = l0VarW2.f25269m;
                        if (z10 || l0VarW2.f25268l) {
                            q(l0VarW2, true);
                            zV = z10;
                            if (!zV) {
                                return true;
                            }
                        } else {
                            if (!l0VarW2.f25267k) {
                                return true;
                            }
                            if (l0VarW2.f25271o) {
                                l0VarW2.f25267k = false;
                                if (!D(l0VarW2, keyEvent)) {
                                    return true;
                                }
                            }
                            B(l0VarW2, keyEvent);
                        }
                    } else {
                        ActionBarOverlayLayout actionBarOverlayLayout2 = (ActionBarOverlayLayout) this.U;
                        actionBarOverlayLayout2.e();
                        if (((w3) actionBarOverlayLayout2.f613e).f29883a.p()) {
                            ActionBarOverlayLayout actionBarOverlayLayout3 = (ActionBarOverlayLayout) this.U;
                            actionBarOverlayLayout3.e();
                            ActionMenuView actionMenuView2 = ((w3) actionBarOverlayLayout3.f613e).f29883a.f798a;
                            if (actionMenuView2 == null || (pVar = actionMenuView2.W) == null || !pVar.e()) {
                                return true;
                            }
                        } else {
                            if (this.f25297t0 || !D(l0VarW2, keyEvent)) {
                                return true;
                            }
                            ActionBarOverlayLayout actionBarOverlayLayout4 = (ActionBarOverlayLayout) this.U;
                            actionBarOverlayLayout4.e();
                            zV = ((w3) actionBarOverlayLayout4.f613e).f29883a.v();
                            if (!zV) {
                            }
                        }
                    }
                }
                AudioManager audioManager = (AudioManager) context.getApplicationContext().getSystemService("audio");
                if (audioManager == null) {
                    return true;
                }
                audioManager.playSoundEffect(0);
                return true;
            }
        } else if (A()) {
            return true;
        }
        return false;
    }

    public final void s(int i10) {
        l0 l0VarW = w(i10);
        if (l0VarW.f25264h != null) {
            Bundle bundle = new Bundle();
            l0VarW.f25264h.u(bundle);
            if (bundle.size() > 0) {
                l0VarW.f25272p = bundle;
            }
            l0VarW.f25264h.y();
            l0VarW.f25264h.clear();
        }
        l0VarW.f25271o = true;
        l0VarW.f25270n = true;
        if ((i10 == 108 || i10 == 0) && this.U != null) {
            l0 l0VarW2 = w(0);
            l0VarW2.f25267k = false;
            D(l0VarW2, null);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x002b  */
    @Override // e.w
    @RequiresApi(33)
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void setOnBackInvokedDispatcher(@Nullable OnBackInvokedDispatcher onBackInvokedDispatcher) {
        OnBackInvokedCallback onBackInvokedCallback;
        super.setOnBackInvokedDispatcher(onBackInvokedDispatcher);
        OnBackInvokedDispatcher onBackInvokedDispatcher2 = this.I0;
        if (onBackInvokedDispatcher2 != null && (onBackInvokedCallback = this.J0) != null) {
            f0.c(onBackInvokedDispatcher2, onBackInvokedCallback);
            this.J0 = null;
        }
        if (onBackInvokedDispatcher == null) {
            Object obj = this.f25283j;
            if (!(obj instanceof Activity) || ((Activity) obj).getWindow() == null) {
                this.I0 = onBackInvokedDispatcher;
            } else {
                this.I0 = f0.a((Activity) obj);
            }
        }
        F();
    }

    @Override // e.w
    public final void setSupportActionBar(Toolbar toolbar) {
        Object obj = this.f25283j;
        if (obj instanceof Activity) {
            x();
            c cVar = this.R;
            if (cVar instanceof y0) {
                throw new IllegalStateException("This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.");
            }
            this.S = null;
            if (cVar != null) {
                cVar.j();
            }
            this.R = null;
            if (toolbar != null) {
                u0 u0Var = new u0(toolbar, obj instanceof Activity ? ((Activity) obj).getTitle() : this.T, this.f25289m);
                this.R = u0Var;
                this.f25289m.setActionBarCallback(u0Var.f25338c);
                toolbar.setBackInvokedCallbackEnabled(true);
            } else {
                this.f25289m.setActionBarCallback(null);
            }
            b();
        }
    }

    @Override // e.w
    public final void setTitle(CharSequence charSequence) {
        this.T = charSequence;
        l1 l1Var = this.U;
        if (l1Var != null) {
            l1Var.setWindowTitle(charSequence);
            return;
        }
        c cVar = this.R;
        if (cVar != null) {
            cVar.r(charSequence);
            return;
        }
        TextView textView = this.f25278e0;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:28:0x0045  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0049  */
    @Override // e.w
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final j.c startSupportActionMode(j.b bVar) {
        j.c cVarOnWindowStartingSupportActionMode;
        ViewGroup viewGroup;
        j.c cVar;
        if (bVar == null) {
            throw new IllegalArgumentException("ActionMode callback can not be null.");
        }
        j.c cVar2 = this.X;
        if (cVar2 != null) {
            cVar2.a();
        }
        b0 b0Var = new b0(this, bVar);
        x();
        c cVar3 = this.R;
        p pVar = this.Q;
        if (cVar3 != null) {
            j.c cVarT = cVar3.t(b0Var);
            this.X = cVarT;
            if (cVarT != null && pVar != null) {
                pVar.onSupportActionModeStarted(cVarT);
            }
        }
        if (this.X == null) {
            z1 z1Var = this.f25275b0;
            if (z1Var != null) {
                z1Var.b();
            }
            j.c cVar4 = this.X;
            if (cVar4 != null) {
                cVar4.a();
            }
            if (pVar == null || this.f25297t0) {
                cVarOnWindowStartingSupportActionMode = null;
                if (cVarOnWindowStartingSupportActionMode == null) {
                    this.X = cVarOnWindowStartingSupportActionMode;
                } else {
                    int i10 = 1;
                    if (this.Y == null) {
                        boolean z10 = this.f25288l0;
                        Context context = this.f25285k;
                        if (z10) {
                            TypedValue typedValue = new TypedValue();
                            Resources.Theme theme = context.getTheme();
                            theme.resolveAttribute(d.a.actionBarTheme, typedValue, true);
                            if (typedValue.resourceId != 0) {
                                Resources.Theme themeNewTheme = context.getResources().newTheme();
                                themeNewTheme.setTo(theme);
                                themeNewTheme.applyStyle(typedValue.resourceId, true);
                                j.e eVar = new j.e(context, 0);
                                eVar.getTheme().setTo(themeNewTheme);
                                context = eVar;
                            }
                            this.Y = new ActionBarContextView(context);
                            PopupWindow popupWindow = new PopupWindow(context, (AttributeSet) null, d.a.actionModePopupWindowStyle);
                            this.Z = popupWindow;
                            popupWindow.setWindowLayoutType(2);
                            this.Z.setContentView(this.Y);
                            this.Z.setWidth(-1);
                            context.getTheme().resolveAttribute(d.a.actionBarSize, typedValue, true);
                            this.Y.setContentHeight(TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics()));
                            this.Z.setHeight(-2);
                            this.f25274a0 = new x(this, i10);
                        } else {
                            ViewStubCompat viewStubCompat = (ViewStubCompat) this.f25277d0.findViewById(d.f.action_mode_bar_stub);
                            if (viewStubCompat != null) {
                                x();
                                c cVar5 = this.R;
                                Context contextE = cVar5 != null ? cVar5.e() : null;
                                if (contextE != null) {
                                    context = contextE;
                                }
                                viewStubCompat.setLayoutInflater(LayoutInflater.from(context));
                                this.Y = (ActionBarContextView) viewStubCompat.a();
                            }
                        }
                    }
                    if (this.Y != null) {
                        z1 z1Var2 = this.f25275b0;
                        if (z1Var2 != null) {
                            z1Var2.b();
                        }
                        this.Y.h();
                        Context context2 = this.Y.getContext();
                        ActionBarContextView actionBarContextView = this.Y;
                        j.f fVar = new j.f();
                        fVar.f28442c = context2;
                        fVar.f28443d = actionBarContextView;
                        fVar.f28444e = b0Var;
                        k.p pVar2 = new k.p(actionBarContextView.getContext());
                        pVar2.f28891l = 1;
                        fVar.f28447h = pVar2;
                        pVar2.f28884e = fVar;
                        if (b0Var.f25187a.c(fVar, pVar2)) {
                            fVar.h();
                            this.Y.f(fVar);
                            this.X = fVar;
                            if (this.f25276c0 && (viewGroup = this.f25277d0) != null && viewGroup.isLaidOut()) {
                                this.Y.setAlpha(0.0f);
                                z1 z1VarA = s1.a(this.Y);
                                z1VarA.a(1.0f);
                                this.f25275b0 = z1VarA;
                                z1VarA.setListener(new z(this, i10));
                            } else {
                                this.Y.setAlpha(1.0f);
                                this.Y.setVisibility(0);
                                if (this.Y.getParent() instanceof View) {
                                    View view = (View) this.Y.getParent();
                                    WeakHashMap weakHashMap = s1.f1815a;
                                    g1.c(view);
                                }
                            }
                            if (this.Z != null) {
                                this.f25287l.getDecorView().post(this.f25274a0);
                            }
                        } else {
                            this.X = null;
                        }
                    }
                }
                cVar = this.X;
                if (cVar != null && pVar != null) {
                    pVar.onSupportActionModeStarted(cVar);
                }
                F();
                this.X = this.X;
            } else {
                try {
                    cVarOnWindowStartingSupportActionMode = pVar.onWindowStartingSupportActionMode(b0Var);
                } catch (AbstractMethodError unused) {
                    cVarOnWindowStartingSupportActionMode = null;
                }
                if (cVarOnWindowStartingSupportActionMode == null) {
                }
                cVar = this.X;
                if (cVar != null) {
                    pVar.onSupportActionModeStarted(cVar);
                }
                F();
                this.X = this.X;
            }
        }
        F();
        return this.X;
    }

    public final void t() {
        ViewGroup viewGroup;
        if (this.f25276c0) {
            return;
        }
        int[] iArr = d.j.AppCompatTheme;
        Context context = this.f25285k;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(iArr);
        int i10 = d.j.AppCompatTheme_windowActionBar;
        if (!typedArrayObtainStyledAttributes.hasValue(i10)) {
            typedArrayObtainStyledAttributes.recycle();
            throw new IllegalStateException("You need to use a Theme.AppCompat theme (or descendant) with this activity.");
        }
        if (typedArrayObtainStyledAttributes.getBoolean(d.j.AppCompatTheme_windowNoTitle, false)) {
            h(1);
        } else if (typedArrayObtainStyledAttributes.getBoolean(i10, false)) {
            h(108);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(d.j.AppCompatTheme_windowActionBarOverlay, false)) {
            h(109);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(d.j.AppCompatTheme_windowActionModeOverlay, false)) {
            h(10);
        }
        this.f25288l0 = typedArrayObtainStyledAttributes.getBoolean(d.j.AppCompatTheme_android_windowIsFloating, false);
        typedArrayObtainStyledAttributes.recycle();
        u();
        this.f25287l.getDecorView();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(context);
        if (this.f25290m0) {
            viewGroup = this.f25286k0 ? (ViewGroup) layoutInflaterFrom.inflate(d.g.abc_screen_simple_overlay_action_mode, (ViewGroup) null) : (ViewGroup) layoutInflaterFrom.inflate(d.g.abc_screen_simple, (ViewGroup) null);
        } else if (this.f25288l0) {
            viewGroup = (ViewGroup) layoutInflaterFrom.inflate(d.g.abc_dialog_title_material, (ViewGroup) null);
            this.f25284j0 = false;
            this.f25282i0 = false;
        } else if (this.f25282i0) {
            TypedValue typedValue = new TypedValue();
            context.getTheme().resolveAttribute(d.a.actionBarTheme, typedValue, true);
            viewGroup = (ViewGroup) LayoutInflater.from(typedValue.resourceId != 0 ? new j.e(context, typedValue.resourceId) : context).inflate(d.g.abc_screen_toolbar, (ViewGroup) null);
            l1 l1Var = (l1) viewGroup.findViewById(d.f.decor_content_parent);
            this.U = l1Var;
            l1Var.setWindowCallback(this.f25287l.getCallback());
            if (this.f25284j0) {
                ((ActionBarOverlayLayout) this.U).d(109);
            }
            if (this.f25280g0) {
                ((ActionBarOverlayLayout) this.U).d(2);
            }
            if (this.f25281h0) {
                ((ActionBarOverlayLayout) this.U).d(5);
            }
        } else {
            viewGroup = null;
        }
        if (viewGroup == null) {
            throw new IllegalArgumentException("AppCompat does not support the current theme features: { windowActionBar: " + this.f25282i0 + ", windowActionBarOverlay: " + this.f25284j0 + ", android:windowIsFloating: " + this.f25288l0 + ", windowActionModeOverlay: " + this.f25286k0 + ", windowNoTitle: " + this.f25290m0 + " }");
        }
        s1.setOnApplyWindowInsetsListener(viewGroup, new y(this));
        if (this.U == null) {
            this.f25278e0 = (TextView) viewGroup.findViewById(d.f.title);
        }
        boolean z10 = f4.f29682a;
        try {
            Method method = viewGroup.getClass().getMethod("makeOptionalFitsSystemWindows", new Class[0]);
            if (!method.isAccessible()) {
                method.setAccessible(true);
            }
            method.invoke(viewGroup, new Object[0]);
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
        }
        ContentFrameLayout contentFrameLayout = (ContentFrameLayout) viewGroup.findViewById(d.f.action_bar_activity_content);
        ViewGroup viewGroup2 = (ViewGroup) this.f25287l.findViewById(R.id.content);
        if (viewGroup2 != null) {
            while (viewGroup2.getChildCount() > 0) {
                View childAt = viewGroup2.getChildAt(0);
                viewGroup2.removeViewAt(0);
                contentFrameLayout.addView(childAt);
            }
            viewGroup2.setId(-1);
            contentFrameLayout.setId(R.id.content);
            if (viewGroup2 instanceof FrameLayout) {
                ((FrameLayout) viewGroup2).setForeground(null);
            }
        }
        this.f25287l.setContentView(viewGroup);
        contentFrameLayout.setAttachListener(new xyz.stream.utils.a0(this));
        this.f25277d0 = viewGroup;
        Object obj = this.f25283j;
        CharSequence title = obj instanceof Activity ? ((Activity) obj).getTitle() : this.T;
        if (!TextUtils.isEmpty(title)) {
            l1 l1Var2 = this.U;
            if (l1Var2 != null) {
                l1Var2.setWindowTitle(title);
            } else {
                c cVar = this.R;
                if (cVar != null) {
                    cVar.r(title);
                } else {
                    TextView textView = this.f25278e0;
                    if (textView != null) {
                        textView.setText(title);
                    }
                }
            }
        }
        ContentFrameLayout contentFrameLayout2 = (ContentFrameLayout) this.f25277d0.findViewById(R.id.content);
        View decorView = this.f25287l.getDecorView();
        contentFrameLayout2.setDecorPadding(decorView.getPaddingLeft(), decorView.getPaddingTop(), decorView.getPaddingRight(), decorView.getPaddingBottom());
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(d.j.AppCompatTheme);
        typedArrayObtainStyledAttributes2.getValue(d.j.AppCompatTheme_windowMinWidthMajor, contentFrameLayout2.getMinWidthMajor());
        typedArrayObtainStyledAttributes2.getValue(d.j.AppCompatTheme_windowMinWidthMinor, contentFrameLayout2.getMinWidthMinor());
        int i11 = d.j.AppCompatTheme_windowFixedWidthMajor;
        if (typedArrayObtainStyledAttributes2.hasValue(i11)) {
            typedArrayObtainStyledAttributes2.getValue(i11, contentFrameLayout2.getFixedWidthMajor());
        }
        int i12 = d.j.AppCompatTheme_windowFixedWidthMinor;
        if (typedArrayObtainStyledAttributes2.hasValue(i12)) {
            typedArrayObtainStyledAttributes2.getValue(i12, contentFrameLayout2.getFixedWidthMinor());
        }
        int i13 = d.j.AppCompatTheme_windowFixedHeightMajor;
        if (typedArrayObtainStyledAttributes2.hasValue(i13)) {
            typedArrayObtainStyledAttributes2.getValue(i13, contentFrameLayout2.getFixedHeightMajor());
        }
        int i14 = d.j.AppCompatTheme_windowFixedHeightMinor;
        if (typedArrayObtainStyledAttributes2.hasValue(i14)) {
            typedArrayObtainStyledAttributes2.getValue(i14, contentFrameLayout2.getFixedHeightMinor());
        }
        typedArrayObtainStyledAttributes2.recycle();
        contentFrameLayout2.requestLayout();
        this.f25276c0 = true;
        l0 l0VarW = w(0);
        if (this.f25297t0 || l0VarW.f25264h != null) {
            return;
        }
        y(108);
    }

    public final void u() {
        if (this.f25287l == null) {
            Object obj = this.f25283j;
            if (obj instanceof Activity) {
                n(((Activity) obj).getWindow());
            }
        }
        if (this.f25287l == null) {
            throw new IllegalStateException("We have not been given a Window");
        }
    }

    public final int updateStatusGuard(@Nullable f3 f3Var, @Nullable Rect rect) {
        boolean z10;
        boolean z11;
        int color;
        int iD = f3Var != null ? f3Var.d() : rect != null ? rect.top : 0;
        ActionBarContextView actionBarContextView = this.Y;
        if (actionBarContextView == null || !(actionBarContextView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
            z10 = false;
        } else {
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.Y.getLayoutParams();
            if (this.Y.isShown()) {
                if (this.F0 == null) {
                    this.F0 = new Rect();
                    this.G0 = new Rect();
                }
                Rect rect2 = this.F0;
                Rect rect3 = this.G0;
                if (f3Var == null) {
                    rect2.set(rect);
                } else {
                    rect2.set(f3Var.b(), f3Var.d(), f3Var.c(), f3Var.a());
                }
                ViewGroup viewGroup = this.f25277d0;
                if (Build.VERSION.SDK_INT >= 29) {
                    boolean z12 = f4.f29682a;
                    e4.a(viewGroup, rect2, rect3);
                } else {
                    if (!f4.f29682a) {
                        f4.f29682a = true;
                        try {
                            Method declaredMethod = View.class.getDeclaredMethod("computeFitSystemWindows", Rect.class, Rect.class);
                            f4.f29683b = declaredMethod;
                            if (!declaredMethod.isAccessible()) {
                                f4.f29683b.setAccessible(true);
                            }
                        } catch (NoSuchMethodException unused) {
                        }
                    }
                    Method method = f4.f29683b;
                    if (method != null) {
                        try {
                            method.invoke(viewGroup, rect2, rect3);
                        } catch (Exception unused2) {
                        }
                    }
                }
                int i10 = rect2.top;
                int i11 = rect2.left;
                int i12 = rect2.right;
                f3 rootWindowInsets = s1.getRootWindowInsets(this.f25277d0);
                int iB = rootWindowInsets == null ? 0 : rootWindowInsets.b();
                int iC = rootWindowInsets == null ? 0 : rootWindowInsets.c();
                if (marginLayoutParams.topMargin == i10 && marginLayoutParams.leftMargin == i11 && marginLayoutParams.rightMargin == i12) {
                    z11 = false;
                } else {
                    marginLayoutParams.topMargin = i10;
                    marginLayoutParams.leftMargin = i11;
                    marginLayoutParams.rightMargin = i12;
                    z11 = true;
                }
                Context context = this.f25285k;
                if (i10 <= 0 || this.f25279f0 != null) {
                    View view = this.f25279f0;
                    if (view != null) {
                        ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
                        int i13 = marginLayoutParams2.height;
                        int i14 = marginLayoutParams.topMargin;
                        if (i13 != i14 || marginLayoutParams2.leftMargin != iB || marginLayoutParams2.rightMargin != iC) {
                            marginLayoutParams2.height = i14;
                            marginLayoutParams2.leftMargin = iB;
                            marginLayoutParams2.rightMargin = iC;
                            this.f25279f0.setLayoutParams(marginLayoutParams2);
                        }
                    }
                } else {
                    View view2 = new View(context);
                    this.f25279f0 = view2;
                    view2.setVisibility(8);
                    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, marginLayoutParams.topMargin, 51);
                    layoutParams.leftMargin = iB;
                    layoutParams.rightMargin = iC;
                    this.f25277d0.addView(this.f25279f0, -1, layoutParams);
                }
                View view3 = this.f25279f0;
                z = view3 != null;
                if (z && view3.getVisibility() != 0) {
                    View view4 = this.f25279f0;
                    if ((view4.getWindowSystemUiVisibility() & 8192) != 0) {
                        int i15 = d.c.abc_decor_view_status_guard_light;
                        Object obj = g0.d.f26125a;
                        color = context.getColor(i15);
                    } else {
                        int i16 = d.c.abc_decor_view_status_guard;
                        Object obj2 = g0.d.f26125a;
                        color = context.getColor(i16);
                    }
                    view4.setBackgroundColor(color);
                }
                if (!this.f25286k0 && z) {
                    iD = 0;
                }
                z10 = z;
                z = z11;
            } else if (marginLayoutParams.topMargin != 0) {
                marginLayoutParams.topMargin = 0;
                z10 = false;
            } else {
                z10 = false;
                z = false;
            }
            if (z) {
                this.Y.setLayoutParams(marginLayoutParams);
            }
        }
        View view5 = this.f25279f0;
        if (view5 != null) {
            view5.setVisibility(z10 ? 0 : 8);
        }
        return iD;
    }

    public final j0 v(Context context) {
        if (this.z0 == null) {
            if (xyz.stream.utils.t.f36170f == null) {
                Context applicationContext = context.getApplicationContext();
                xyz.stream.utils.t.f36170f = new xyz.stream.utils.t(applicationContext, (LocationManager) applicationContext.getSystemService("location"));
            }
            this.z0 = new h0(this, xyz.stream.utils.t.f36170f);
        }
        return this.z0;
    }

    public final l0 w(int i10) {
        l0[] l0VarArr = this.f25292o0;
        if (l0VarArr == null || l0VarArr.length <= i10) {
            l0[] l0VarArr2 = new l0[i10 + 1];
            if (l0VarArr != null) {
                System.arraycopy(l0VarArr, 0, l0VarArr2, 0, l0VarArr.length);
            }
            this.f25292o0 = l0VarArr2;
            l0VarArr = l0VarArr2;
        }
        l0 l0Var = l0VarArr[i10];
        if (l0Var != null) {
            return l0Var;
        }
        l0 l0Var2 = new l0();
        l0Var2.f25257a = i10;
        l0Var2.f25270n = false;
        l0VarArr[i10] = l0Var2;
        return l0Var2;
    }

    public final void x() {
        t();
        if (this.f25282i0 && this.R == null) {
            Object obj = this.f25283j;
            if (obj instanceof Activity) {
                this.R = new y0(this.f25284j0, (Activity) obj);
            } else if (obj instanceof Dialog) {
                this.R = new y0((Dialog) obj);
            }
            c cVar = this.R;
            if (cVar != null) {
                cVar.n(this.E0);
            }
        }
    }

    public final void y(int i10) {
        this.C0 = (1 << i10) | this.C0;
        if (this.B0) {
            return;
        }
        View decorView = this.f25287l.getDecorView();
        WeakHashMap weakHashMap = s1.f1815a;
        decorView.postOnAnimation(this.D0);
        this.B0 = true;
    }

    public final int z(Context context, int i10) {
        if (i10 == -100) {
            return -1;
        }
        if (i10 != -1) {
            if (i10 == 0) {
                if (((UiModeManager) context.getApplicationContext().getSystemService("uimode")).getNightMode() == 0) {
                    return -1;
                }
                return v(context).b();
            }
            if (i10 != 1 && i10 != 2) {
                if (i10 != 3) {
                    throw new IllegalStateException("Unknown value set for night mode. Please use one of the MODE_NIGHT values from AppCompatDelegate.");
                }
                if (this.A0 == null) {
                    this.A0 = new h0(this, context);
                }
                return this.A0.b();
            }
        }
        return i10;
    }
}
