package ca.canadapost.module.sfsb;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.databinding.n;
import androidx.fragment.app.f;
import androidx.fragment.app.k;
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.sfsb.SfsbCardMemberFragment;
import java.util.EnumMap;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import rf.m;
import rm.n0;
import rm.o;
import u8.g;
import w8.d0;
import w8.j0;
import w8.l0;
import w8.w;

@Metadata(d1 = {"\u0000R\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\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b!\u0010\"J\b\u0010\u0003\u001a\u00020\u0002H\u0002J\u0018\u0010\b\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u0006H\u0016J\u0010\u0010\f\u001a\u00020\u000b2\u0006\u0010\n\u001a\u00020\tH\u0016J\u0012\u0010\u000f\u001a\u00020\u00022\b\u0010\u000e\u001a\u0004\u0018\u00010\rH\u0016J&\u0010\u0014\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0007\u001a\u00020\u00102\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u000e\u001a\u0004\u0018\u00010\rH\u0016J\u001a\u0010\u0016\u001a\u00020\u00022\u0006\u0010\u0015\u001a\u00020\u00132\b\u0010\u000e\u001a\u0004\u0018\u00010\rH\u0016R\u0016\u0010\u001a\u001a\u00020\u00178\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0018\u0010\u0019R\u001b\u0010 \u001a\u00020\u001b8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u001c\u0010\u001d\u001a\u0004\b\u001e\u0010\u001f¨\u0006#"}, d2 = {"Lca/canadapost/module/sfsb/SfsbCardMemberFragment;", "Lu8/b;", "Lrm/n0;", "T", "Landroid/view/Menu;", "menu", "Landroid/view/MenuInflater;", "inflater", "onCreateOptionsMenu", "Landroid/view/MenuItem;", "item", "", "onOptionsItemSelected", "Landroid/os/Bundle;", "savedInstanceState", "onCreate", "Landroid/view/LayoutInflater;", "Landroid/view/ViewGroup;", "container", "Landroid/view/View;", "onCreateView", "view", "onViewCreated", "Lsf/c;", "s", "Lsf/c;", "binding", "Lrf/m;", "t", "Lrm/o;", "N", "()Lrf/m;", "viewModel", "<init>", "()V", "sfsb_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class SfsbCardMemberFragment extends u8.b {

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private sf.c binding;

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class a extends v implements dn.a {
        a() {
            super(0);
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m178invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m178invoke() {
            SfsbCardMemberFragment.this.N().S();
            Toast.makeText(SfsbCardMemberFragment.this.requireActivity(), rf.e.f34710i, 1).show();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* 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 */ g f10848p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ SfsbCardMemberFragment f10849q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(g gVar, SfsbCardMemberFragment sfsbCardMemberFragment) {
            super(0);
            this.f10848p = gVar;
            this.f10849q = sfsbCardMemberFragment;
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m179invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m179invoke() {
            androidx.appcompat.app.a h10 = this.f10848p.h();
            if (h10 != null) {
                h10.dismiss();
            }
            this.f10849q.N().c0(false);
        }
    }

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: Access modifiers changed from: private */
    public final m N() {
        return (m) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void O(SfsbCardMemberFragment this$0, Boolean bool) {
        t.g(this$0, "this$0");
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        this$0.T();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void P(SfsbCardMemberFragment this$0, String str) {
        Boolean bool;
        t.g(this$0, "this$0");
        if (str == null || (bool = (Boolean) this$0.N().X().f()) == null) {
            return;
        }
        t.d(bool);
        if (bool.booleanValue()) {
            this$0.N().b0(false);
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(CoreConstants.GOOGLE_PASS_SAVE + str));
            if (intent.resolveActivity(this$0.requireActivity().getPackageManager()) != null) {
                this$0.startActivity(intent);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Q(SfsbCardMemberFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        Toast.makeText(this$0.requireActivity(), rf.e.f34703b, 1).show();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void R(SfsbCardMemberFragment this$0, Boolean bool) {
        t.g(this$0, "this$0");
        t.d(bool);
        if (bool.booleanValue()) {
            w.d(x4.d.a(this$0), rf.b.f34685a, null, null, 6, null);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void S(SfsbCardMemberFragment this$0) {
        t.g(this$0, "this$0");
        try {
            bm.b bVar = new bm.b();
            EnumMap enumMap = new EnumMap(yk.g.class);
            enumMap.put((EnumMap) yk.g.CHARACTER_SET, (yk.g) "UTF-8");
            enumMap.put((EnumMap) yk.g.MARGIN, (yk.g) 0);
            Bitmap c10 = bVar.c((String) this$0.N().V().f(), yk.a.CODE_128, l0.c(170), l0.c(60), enumMap);
            sf.c cVar = this$0.binding;
            if (cVar == null) {
                t.y("binding");
                cVar = null;
            }
            cVar.C.setImageBitmap(c10);
        } catch (Exception e10) {
            tr.a.f36618a.d(e10, e10.getMessage(), new Object[0]);
        }
    }

    private final void T() {
        g.a aVar = g.f36993k;
        k requireActivity = requireActivity();
        String string = getString(rf.e.f34709h);
        t.f(string, "getString(...)");
        g l10 = aVar.l(requireActivity, string, getString(rf.e.f34708g));
        l10.n(getString(rf.e.f34707f));
        l10.o(new a());
        l10.p(getString(rf.e.f34704c));
        l10.q(new b(l10, this));
        l10.x(requireActivity());
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setHasOptionsMenu(true);
    }

    @Override // androidx.fragment.app.f
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        t.g(menu, "menu");
        t.g(inflater, "inflater");
        menu.clear();
        inflater.inflate(rf.d.f34701a, menu);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        n h10 = androidx.databinding.f.h(inflater, rf.c.f34698b, container, false);
        t.f(h10, "inflate(...)");
        sf.c cVar = (sf.c) h10;
        this.binding = cVar;
        sf.c cVar2 = null;
        if (cVar == null) {
            t.y("binding");
            cVar = null;
        }
        cVar.O(getViewLifecycleOwner());
        sf.c cVar3 = this.binding;
        if (cVar3 == null) {
            t.y("binding");
            cVar3 = null;
        }
        cVar3.U(N());
        N().a0().j(getViewLifecycleOwner(), new g0() { // from class: rf.i
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SfsbCardMemberFragment.O(SfsbCardMemberFragment.this, (Boolean) obj);
            }
        });
        N().Y().j(getViewLifecycleOwner(), new g0() { // from class: rf.j
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SfsbCardMemberFragment.P(SfsbCardMemberFragment.this, (String) obj);
            }
        });
        N().Z().j(getViewLifecycleOwner(), new g0() { // from class: rf.k
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SfsbCardMemberFragment.Q(SfsbCardMemberFragment.this, (Event) obj);
            }
        });
        N().U().j(getViewLifecycleOwner(), new g0() { // from class: rf.l
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                SfsbCardMemberFragment.R(SfsbCardMemberFragment.this, (Boolean) obj);
            }
        });
        sf.c cVar4 = this.binding;
        if (cVar4 == null) {
            t.y("binding");
        } else {
            cVar2 = cVar4;
        }
        return cVar2.x();
    }

    @Override // androidx.fragment.app.f
    public boolean onOptionsItemSelected(MenuItem item) {
        t.g(item, "item");
        if (item.getItemId() == rf.b.f34693i) {
            N().c0(true);
        }
        return super.onOptionsItemSelected(item);
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        j0.a aVar = j0.f40981a;
        k requireActivity = requireActivity();
        t.f(requireActivity, "requireActivity(...)");
        aVar.d(requireActivity);
        requireActivity().setTitle(getString(rf.e.f34713l));
        new Handler().post(new Runnable() { // from class: rf.h
            @Override // java.lang.Runnable
            public final void run() {
                SfsbCardMemberFragment.S(SfsbCardMemberFragment.this);
            }
        });
        String string = getString(rf.e.f34715n);
        t.f(string, "getString(...)");
        sf.c cVar = this.binding;
        if (cVar == null) {
            t.y("binding");
            cVar = null;
        }
        TextView showYourSfsbCard = cVar.D;
        t.f(showYourSfsbCard, "showYourSfsbCard");
        String string2 = getString(rf.e.f34716o);
        t.f(string2, "getString(...)");
        String string3 = getString(rf.e.f34714m, string);
        t.f(string3, "getString(...)");
        d0.e(showYourSfsbCard, string2, string, string3);
    }
}
