package androidx.view.fragment;

import android.app.Dialog;
import android.view.View;
import android.view.Window;
import androidx.fragment.app.l;
import androidx.fragment.app.o;
import androidx.media3.container.NalUnitUtil;
import androidx.view.bb;
import androidx.view.j;
import defpackage.cr4;
import defpackage.n41;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\u0002\n\u0000¨\u0006\u0000"}, d2 = {"navigation-fragment_release"}, k = 2, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class d {
    public static final j a(o oVar) {
        Dialog dialog;
        Window window;
        cr4.g(oVar, "<this>");
        for (o parentFragment = oVar; parentFragment != null; parentFragment = parentFragment.getParentFragment()) {
            if (parentFragment instanceof NavHostFragment) {
                return ((NavHostFragment) parentFragment).j();
            }
            o oVar2 = parentFragment.getParentFragmentManager().aa;
            if (oVar2 instanceof NavHostFragment) {
                return ((NavHostFragment) oVar2).j();
            }
        }
        View view = oVar.getView();
        if (view != null) {
            return bb.a(view);
        }
        View decorView = null;
        l lVar = oVar instanceof l ? (l) oVar : null;
        if (lVar != null && (dialog = lVar.getDialog()) != null && (window = dialog.getWindow()) != null) {
            decorView = window.getDecorView();
        }
        if (decorView != null) {
            return bb.a(decorView);
        }
        throw new IllegalStateException(n41.m("Fragment ", oVar, " does not have a NavController set"));
    }
}
