package defpackage;

import android.os.Bundle;
import android.os.Parcelable;
import androidx.fragment.app.ab;
import androidx.lifecycle.ak;
import androidx.view.NavBackStackEntry;
import androidx.view.bc;
import androidx.view.fragment.NavHostFragment;
import androidx.view.i;
import defpackage.ua8;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class f91 implements ua8.c {
    public final /* synthetic */ int a;
    public final /* synthetic */ Object b;

    public /* synthetic */ f91(Object obj, int i) {
        this.a = i;
        this.b = obj;
    }

    @Override // ua8.c
    public final Bundle a() {
        Bundle bundle;
        switch (this.a) {
            case 0:
                return j91.b((j91) this.b);
            case 1:
                return ((ab) this.b).bb();
            case 2:
                hj6 hj6Var = (hj6) this.b;
                LinkedHashMap linkedHashMap = hj6Var.o;
                LinkedHashMap linkedHashMap2 = hj6Var.n;
                ds dsVar = hj6Var.g;
                ArrayList<String> arrayList = new ArrayList<>();
                Bundle bundle2 = new Bundle();
                for (Map.Entry entry : wo5.n(hj6Var.w.a).entrySet()) {
                    String str = (String) entry.getKey();
                    Bundle bundleH = ((bc) entry.getValue()).h();
                    if (bundleH != null) {
                        arrayList.add(str);
                        bundle2.putBundle(str, bundleH);
                    }
                }
                if (arrayList.isEmpty()) {
                    bundle = null;
                } else {
                    bundle = new Bundle();
                    bundle2.putStringArrayList("android-support-nav:controller:navigatorState:names", arrayList);
                    bundle.putBundle("android-support-nav:controller:navigatorState", bundle2);
                }
                if (!dsVar.isEmpty()) {
                    if (bundle == null) {
                        bundle = new Bundle();
                    }
                    Parcelable[] parcelableArr = new Parcelable[dsVar.c];
                    Iterator<E> it = dsVar.iterator();
                    int i = 0;
                    while (it.hasNext()) {
                        parcelableArr[i] = new i((NavBackStackEntry) it.next());
                        i++;
                    }
                    bundle.putParcelableArray("android-support-nav:controller:backStack", parcelableArr);
                }
                if (!linkedHashMap2.isEmpty()) {
                    if (bundle == null) {
                        bundle = new Bundle();
                    }
                    int[] iArr = new int[linkedHashMap2.size()];
                    ArrayList<String> arrayList2 = new ArrayList<>();
                    int i2 = 0;
                    for (Map.Entry entry2 : linkedHashMap2.entrySet()) {
                        int iIntValue = ((Number) entry2.getKey()).intValue();
                        String str2 = (String) entry2.getValue();
                        iArr[i2] = iIntValue;
                        arrayList2.add(str2);
                        i2++;
                    }
                    bundle.putIntArray("android-support-nav:controller:backStackDestIds", iArr);
                    bundle.putStringArrayList("android-support-nav:controller:backStackIds", arrayList2);
                }
                if (!linkedHashMap.isEmpty()) {
                    if (bundle == null) {
                        bundle = new Bundle();
                    }
                    ArrayList<String> arrayList3 = new ArrayList<>();
                    for (Map.Entry entry3 : linkedHashMap.entrySet()) {
                        String str3 = (String) entry3.getKey();
                        ds dsVar2 = (ds) entry3.getValue();
                        arrayList3.add(str3);
                        Parcelable[] parcelableArr2 = new Parcelable[dsVar2.c];
                        int i3 = 0;
                        for (Object obj : dsVar2) {
                            int i4 = i3 + 1;
                            if (i3 < 0) {
                                y41.bm();
                                throw null;
                            }
                            parcelableArr2[i3] = (i) obj;
                            i3 = i4;
                        }
                        bundle.putParcelableArray(n41.n("android-support-nav:controller:backStackStates:", str3), parcelableArr2);
                    }
                    bundle.putStringArrayList("android-support-nav:controller:backStackStates", arrayList3);
                }
                if (hj6Var.f) {
                    if (bundle == null) {
                        bundle = new Bundle();
                    }
                    bundle.putBoolean("android-support-nav:controller:deepLinkHandled", hj6Var.f);
                }
                if (bundle != null) {
                    return bundle;
                }
                Bundle bundle3 = Bundle.EMPTY;
                cr4.f(bundle3, "EMPTY");
                return bundle3;
            case 3:
                NavHostFragment navHostFragment = (NavHostFragment) this.b;
                cr4.g(navHostFragment, "this$0");
                int i5 = navHostFragment.c;
                if (i5 != 0) {
                    return uk0.a(new q07("android-support-nav:fragment:graphId", Integer.valueOf(i5)));
                }
                Bundle bundle4 = Bundle.EMPTY;
                cr4.f(bundle4, "{\n                    Bu…e.EMPTY\n                }");
                return bundle4;
            default:
                return ak.a((ak) this.b);
        }
    }
}
