package m8;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import ca.canadapost.core.data.model.CoreConstants;
import kotlin.jvm.internal.t;
import kotlin.text.y;
import net.sqlcipher.database.SQLiteDatabase;
import rm.n0;

/* loaded from: classes.dex */
public class a {

    /* renamed from: f */
    public static final C0652a f28723f = new C0652a(null);

    /* renamed from: g */
    public static final int f28724g = 8;

    /* renamed from: a */
    private Integer f28725a;

    /* renamed from: b */
    private Bundle f28726b;

    /* renamed from: c */
    private Intent f28727c;

    /* renamed from: d */
    private String f28728d;

    /* renamed from: e */
    private Class f28729e;

    /* renamed from: m8.a$a */
    /* loaded from: classes.dex */
    public static final class C0652a {
        private C0652a() {
        }

        public /* synthetic */ C0652a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    public static /* synthetic */ void b(a aVar, Activity activity, androidx.fragment.app.f fVar, int i10, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: navigate");
        }
        if ((i10 & 2) != 0) {
            fVar = null;
        }
        aVar.a(activity, fVar);
    }

    public static /* synthetic */ void d(a aVar, Activity activity, androidx.fragment.app.f fVar, int i10, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: navigateClearStack");
        }
        if ((i10 & 2) != 0) {
            fVar = null;
        }
        aVar.c(activity, fVar);
    }

    private final void j(Activity activity) {
        n0 n0Var;
        Integer num = this.f28725a;
        if (num != null) {
            activity.startActivityForResult(this.f28727c, num.intValue());
            n0Var = n0.f34904a;
        } else {
            n0Var = null;
        }
        if (n0Var == null) {
            activity.startActivity(this.f28727c);
        }
    }

    private final void k(androidx.fragment.app.f fVar) {
        n0 n0Var;
        Integer num = this.f28725a;
        if (num != null) {
            fVar.startActivityForResult(this.f28727c, num.intValue());
            n0Var = n0.f34904a;
        } else {
            n0Var = null;
        }
        if (n0Var == null) {
            fVar.startActivity(this.f28727c);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x0059, code lost:
    
        if (r2 != false) goto L50;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a(Activity activity, androidx.fragment.app.f fVar) {
        boolean A;
        boolean A2;
        t.g(activity, "activity");
        if (this.f28727c == null) {
            Intent intent = new Intent();
            this.f28727c = intent;
            intent.addFlags(131072);
            Intent intent2 = this.f28727c;
            if (intent2 != null) {
                intent2.addFlags(65536);
            }
        }
        Intent intent3 = this.f28727c;
        if (intent3 != null) {
            intent3.setPackage(activity.getPackageName());
            String str = this.f28728d;
            if (str != null) {
                intent3.setAction(str);
            }
            Class<?> cls = this.f28729e;
            if (cls != null) {
                intent3.setClass(activity, cls);
            }
            Bundle bundle = this.f28726b;
            if (bundle != null) {
                intent3.putExtra(CoreConstants.FRAG_ARGS, bundle);
            }
            A = y.A(intent3.getAction(), "android.settings.APP_NOTIFICATION_SETTINGS", false, 2, null);
            if (!A) {
                A2 = y.A(intent3.getAction(), "android.settings.APPLICATION_DETAILS_SETTINGS", false, 2, null);
            }
            intent3.setPackage(null);
        }
        if (fVar != null) {
            k(fVar);
        } else {
            j(activity);
        }
        activity.overridePendingTransition(0, 0);
    }

    public final void c(Activity activity, androidx.fragment.app.f fVar) {
        t.g(activity, "activity");
        if (this.f28727c == null) {
            Intent intent = new Intent();
            this.f28727c = intent;
            intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
            Intent intent2 = this.f28727c;
            if (intent2 != null) {
                intent2.addFlags(32768);
            }
            Intent intent3 = this.f28727c;
            if (intent3 != null) {
                intent3.addFlags(67108864);
            }
        }
        Intent intent4 = this.f28727c;
        if (intent4 != null) {
            intent4.setPackage(activity.getPackageName());
            String str = this.f28728d;
            if (str != null) {
                intent4.setAction(str);
            }
            Bundle bundle = this.f28726b;
            if (bundle != null) {
                intent4.putExtra(CoreConstants.FRAG_ARGS, bundle);
            }
        }
        if (fVar != null) {
            k(fVar);
        } else {
            j(activity);
        }
    }

    public final a e(String action) {
        t.g(action, "action");
        this.f28728d = action;
        return this;
    }

    public final a f(Bundle bundle) {
        this.f28726b = bundle;
        return this;
    }

    public final a g(Class cls) {
        t.g(cls, "cls");
        this.f28729e = cls;
        return this;
    }

    public final a h(Intent intent) {
        t.g(intent, "intent");
        this.f28727c = intent;
        return this;
    }

    public final a i(int i10) {
        this.f28725a = Integer.valueOf(i10);
        return this;
    }
}
