package ca.canadapost.module.epostprofile.userprofile;

import android.app.AlertDialog;
import android.os.Build;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.h0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import androidx.fragment.app.f;
import androidx.fragment.app.p0;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import ca.canadapost.core.data.model.CoreConstants;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.module.epostprofile.userprofile.SetNForgotAcceptTnCDialogFragment;
import cc.p1;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import ob.i;
import ob.j;
import ob.l;
import rm.c0;
import rm.o;
import u8.n;
import w8.q0;
import w8.r0;
import w8.y;
import x4.d;
import zb.a3;

@Metadata(d1 = {"\u0000V\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b(\u0010)J&\u0010\t\u001a\u0004\u0018\u00010\b2\u0006\u0010\u0003\u001a\u00020\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u00042\b\u0010\u0007\u001a\u0004\u0018\u00010\u0006H\u0016J\u001a\u0010\f\u001a\u00020\u000b2\u0006\u0010\n\u001a\u00020\b2\b\u0010\u0007\u001a\u0004\u0018\u00010\u0006H\u0016J\n\u0010\u000e\u001a\u0004\u0018\u00010\rH\u0016J\n\u0010\u0010\u001a\u0004\u0018\u00010\u000fH\u0016J\b\u0010\u0011\u001a\u00020\u000bH\u0016R\u0016\u0010\u0015\u001a\u00020\u00128\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0013\u0010\u0014R\"\u0010\u001d\u001a\u00020\u00168\u0006@\u0006X\u0087.¢\u0006\u0012\n\u0004\b\u0017\u0010\u0018\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\u001b\u0010#\u001a\u00020\u001e8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u001f\u0010 \u001a\u0004\b!\u0010\"R\u0018\u0010'\u001a\u0004\u0018\u00010$8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b%\u0010&¨\u0006*"}, d2 = {"Lca/canadapost/module/epostprofile/userprofile/SetNForgotAcceptTnCDialogFragment;", "Lca/canadapost/core/common/ui/b;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroid/view/View;", "onCreateView", "view", "Lrm/n0;", "onViewCreated", "Landroidx/appcompat/widget/Toolbar;", "C", "", "B", "onDestroy", "Lzb/a3;", "p", "Lzb/a3;", "binding", "Landroidx/lifecycle/c1$c;", "q", "Landroidx/lifecycle/c1$c;", "L", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Lcc/p1;", "r", "Lrm/o;", "K", "()Lcc/p1;", "viewModel", "Landroid/app/AlertDialog;", "s", "Landroid/app/AlertDialog;", "progressDialog", "<init>", "()V", "epostprofile_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class SetNForgotAcceptTnCDialogFragment extends ca.canadapost.core.common.ui.b {

    /* renamed from: p, reason: collision with root package name and from kotlin metadata */
    private a3 binding;

    /* renamed from: q, reason: collision with root package name and from kotlin metadata */
    public c1.c viewModelFactory;

    /* renamed from: r, reason: collision with root package name and from kotlin metadata */
    private final o viewModel = p0.a(this, kotlin.jvm.internal.p0.b(p1.class), new b(new a(this)), new c());

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private AlertDialog progressDialog;

    /* loaded from: classes4.dex */
    public static final class a extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ f f8955p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public a(f fVar) {
            super(0);
            this.f8955p = fVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final f invoke() {
            return this.f8955p;
        }
    }

    /* loaded from: classes4.dex */
    public static final class b extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ dn.a f8956p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(dn.a aVar) {
            super(0);
            this.f8956p = aVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            d1 viewModelStore = ((e1) this.f8956p.invoke()).getViewModelStore();
            t.f(viewModelStore, "ownerProducer().viewModelStore");
            return viewModelStore;
        }
    }

    /* loaded from: classes4.dex */
    static final class c extends v implements dn.a {
        c() {
            super(0);
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final c1.c invoke() {
            return SetNForgotAcceptTnCDialogFragment.this.L();
        }
    }

    private final p1 K() {
        return (p1) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void M(SetNForgotAcceptTnCDialogFragment this$0, Event event) {
        t.g(this$0, "this$0");
        r0 r0Var = (r0) event.getContentIfNotHandled();
        if (r0Var != null) {
            if (r0Var.a() != q0.ON) {
                AlertDialog alertDialog = this$0.progressDialog;
                if (alertDialog != null) {
                    alertDialog.dismiss();
                }
                this$0.progressDialog = null;
                return;
            }
            AlertDialog a10 = new n(r0Var.b()).a(this$0.getContext());
            this$0.progressDialog = a10;
            if (a10 != null) {
                a10.show();
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N(SetNForgotAcceptTnCDialogFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        this$0.dismiss();
        d.a(this$0).N(i.I0, androidx.core.os.c.a(c0.a("error_title", this$0.getString(l.V2)), c0.a("error_message", this$0.getString(l.H2)), c0.a("button_text", this$0.getString(l.G1))));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void O(SetNForgotAcceptTnCDialogFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        y.c(this$0, CoreConstants.ONCLICKAGREE, CoreConstants.AGREE.TRUE.getValue());
        this$0.dismiss();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void P(SetNForgotAcceptTnCDialogFragment this$0, String it) {
        t.g(this$0, "this$0");
        t.g(it, "it");
        Toolbar C = this$0.C();
        if (C == null) {
            return;
        }
        C.setTitle(it);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final h1 Q(View v10, h1 windowInsets) {
        t.g(v10, "v");
        t.g(windowInsets, "windowInsets");
        androidx.core.graphics.b f10 = windowInsets.f(h1.l.f());
        t.f(f10, "getInsets(...)");
        ViewGroup.LayoutParams layoutParams = v10.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        }
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        marginLayoutParams.bottomMargin = f10.f3727d;
        v10.setLayoutParams(marginLayoutParams);
        return h1.f3850b;
    }

    @Override // ca.canadapost.core.common.ui.b
    public String B() {
        return null;
    }

    @Override // ca.canadapost.core.common.ui.b
    public Toolbar C() {
        a3 a3Var = this.binding;
        if (a3Var == null) {
            t.y("binding");
            a3Var = null;
        }
        u7.c appBarBinding = a3Var.A.getAppBarBinding();
        if (appBarBinding != null) {
            return appBarBinding.B;
        }
        return null;
    }

    public final c1.c L() {
        c1.c cVar = this.viewModelFactory;
        if (cVar != null) {
            return cVar;
        }
        t.y("viewModelFactory");
        return null;
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        androidx.databinding.n h10 = androidx.databinding.f.h(inflater, j.f31203b0, container, false);
        t.f(h10, "inflate(...)");
        a3 a3Var = (a3) h10;
        this.binding = a3Var;
        a3 a3Var2 = null;
        if (a3Var == null) {
            t.y("binding");
            a3Var = null;
        }
        a3Var.U(K());
        a3 a3Var3 = this.binding;
        if (a3Var3 == null) {
            t.y("binding");
            a3Var3 = null;
        }
        a3Var3.O(this);
        a3 a3Var4 = this.binding;
        if (a3Var4 == null) {
            t.y("binding");
        } else {
            a3Var2 = a3Var4;
        }
        return a3Var2.x();
    }

    @Override // androidx.fragment.app.f
    public void onDestroy() {
        super.onDestroy();
        AlertDialog alertDialog = this.progressDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
        }
    }

    @Override // ca.canadapost.core.common.ui.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        a3 a3Var = null;
        this.progressDialog = new n(null, 1, null).a(getContext());
        K().b0().j(getViewLifecycleOwner(), new g0() { // from class: cc.j1
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SetNForgotAcceptTnCDialogFragment.M(SetNForgotAcceptTnCDialogFragment.this, (Event) obj);
            }
        });
        K().Z().j(getViewLifecycleOwner(), new g0() { // from class: cc.k1
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SetNForgotAcceptTnCDialogFragment.N(SetNForgotAcceptTnCDialogFragment.this, (Event) obj);
            }
        });
        K().U().j(this, new g0() { // from class: cc.l1
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SetNForgotAcceptTnCDialogFragment.O(SetNForgotAcceptTnCDialogFragment.this, (Event) obj);
            }
        });
        K().X().j(this, new g0() { // from class: cc.m1
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SetNForgotAcceptTnCDialogFragment.P(SetNForgotAcceptTnCDialogFragment.this, (String) obj);
            }
        });
        a3 a3Var2 = this.binding;
        if (a3Var2 == null) {
            t.y("binding");
            a3Var2 = null;
        }
        a3Var2.C.setMovementMethod(LinkMovementMethod.getInstance());
        if (Build.VERSION.SDK_INT >= 35) {
            a3 a3Var3 = this.binding;
            if (a3Var3 == null) {
                t.y("binding");
            } else {
                a3Var = a3Var3;
            }
            s0.A0(a3Var.B, new h0() { // from class: cc.n1
                @Override // androidx.core.view.h0
                public final androidx.core.view.h1 a(View view2, androidx.core.view.h1 h1Var) {
                    androidx.core.view.h1 Q;
                    Q = SetNForgotAcceptTnCDialogFragment.Q(view2, h1Var);
                    return Q;
                }
            });
        }
    }
}
