package ca.canadapost.module.flex;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
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.LinearLayout;
import android.widget.TextView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.h0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import androidx.fragment.app.p0;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import b8.a;
import ca.canadapost.core.common.customView.l;
import ca.canadapost.core.common.navigation.ui.b;
import ca.canadapost.core.data.flex.model.AdditionalStepBeforeAddLocation;
import ca.canadapost.core.data.flex.model.FlexLocation;
import ca.canadapost.core.data.flex.model.MapLocation;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.model.ValidationError;
import ca.canadapost.module.flex.FindFlexPostOfficeFragment;
import ca.canadapost.module.flex.d;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.messaging.Constants;
import gc.a2;
import gc.b2;
import gc.c2;
import gc.e2;
import gc.y1;
import gc.z1;
import hc.q;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.u0;
import kotlin.jvm.internal.v;
import kotlin.text.y;
import n8.j;
import n8.m;
import rm.c0;
import rm.n0;
import u8.g;
import w8.q0;
import w8.r0;
import w8.w;

@Metadata(d1 = {"\u0000¢\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\r\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\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\t\n\u0002\u0018\u0002\n\u0002\b\u0006\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\u0005\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\u0003\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010%\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u000b\u0018\u0000 ©\u00012\u00020\u00012\u00020\u00022\u00020\u00032\u00020\u0004:\u0001LB\t¢\u0006\u0006\b§\u0001\u0010¨\u0001J\b\u0010\u0006\u001a\u00020\u0005H\u0002J\b\u0010\u0007\u001a\u00020\u0005H\u0002J\b\u0010\b\u001a\u00020\u0005H\u0002J\b\u0010\t\u001a\u00020\u0005H\u0002J\u0010\u0010\f\u001a\u00020\u00052\u0006\u0010\u000b\u001a\u00020\nH\u0002J\b\u0010\r\u001a\u00020\u0005H\u0002J\b\u0010\u000e\u001a\u00020\u0005H\u0002J\u0010\u0010\u000f\u001a\u00020\u00052\u0006\u0010\u000b\u001a\u00020\nH\u0002J\u0010\u0010\u0010\u001a\u00020\u00052\u0006\u0010\u000b\u001a\u00020\nH\u0002J\u0010\u0010\u0013\u001a\u00020\u00052\u0006\u0010\u0012\u001a\u00020\u0011H\u0002J\u0010\u0010\u0014\u001a\u00020\u00052\u0006\u0010\u000b\u001a\u00020\nH\u0002J\u0010\u0010\u0015\u001a\u00020\u00052\u0006\u0010\u0012\u001a\u00020\u0011H\u0002J\b\u0010\u0016\u001a\u00020\u0005H\u0002J\b\u0010\u0017\u001a\u00020\u0005H\u0002J\b\u0010\u0018\u001a\u00020\u0005H\u0003J\u0018\u0010\u001d\u001a\u00020\u001c2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u0019H\u0002J\b\u0010\u001e\u001a\u00020\u0019H\u0002J\b\u0010\u001f\u001a\u00020\u0005H\u0002J\u0010\u0010\"\u001a\u00020\u00052\u0006\u0010!\u001a\u00020 H\u0002J\u001a\u0010'\u001a\u00020\u00052\u0006\u0010$\u001a\u00020#2\b\b\u0002\u0010&\u001a\u00020%H\u0002J\b\u0010(\u001a\u00020\u0005H\u0002J\b\u0010)\u001a\u00020\u0005H\u0002J\u001c\u0010-\u001a\u00020\u00052\u0012\u0010,\u001a\u000e\u0012\u0004\u0012\u00020#\u0012\u0004\u0012\u00020+0*H\u0002J\u0012\u00100\u001a\u0004\u0018\u00010/2\u0006\u0010.\u001a\u00020+H\u0002J\b\u00101\u001a\u00020\u0005H\u0002J\u0016\u00104\u001a\u00020\u00052\f\u00103\u001a\b\u0012\u0004\u0012\u00020\u000502H\u0002J\u0012\u00107\u001a\u0002062\b\b\u0001\u00105\u001a\u00020%H\u0002J\u0010\u00109\u001a\u00020\u00052\u0006\u00108\u001a\u00020\u001cH\u0002J\u0019\u0010>\u001a\u00020\u00052\u0006\u0010;\u001a\u00020:2\u0006\u0010=\u001a\u00020<H\u0096\u0001J\u001b\u0010D\u001a\u00020C2\b\u0010@\u001a\u0004\u0018\u00010?2\u0006\u0010B\u001a\u00020AH\u0096\u0001J#\u0010G\u001a\u00020C2\u0006\u0010E\u001a\u00020C2\b\u0010F\u001a\u0004\u0018\u00010C2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u001b\u0010H\u001a\u00020C2\b\u0010@\u001a\u0004\u0018\u00010?2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0019\u0010I\u001a\u00020C2\u0006\u0010E\u001a\u00020C2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0011\u0010J\u001a\u00020C2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0011\u0010K\u001a\u00020C2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0011\u0010L\u001a\u00020C2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0019\u0010N\u001a\u00020\u00052\u0006\u0010;\u001a\u00020M2\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0019\u0010O\u001a\u00020\u00052\u0006\u0010=\u001a\u00020<2\u0006\u0010;\u001a\u00020MH\u0096\u0001J\u0011\u0010P\u001a\u00020\u00052\u0006\u0010B\u001a\u00020AH\u0096\u0001J\u0019\u0010Q\u001a\u00020\u00052\u0006\u0010=\u001a\u00020<2\u0006\u0010;\u001a\u00020MH\u0096\u0001J\u001b\u0010S\u001a\u00020\u00052\b\u0010R\u001a\u0004\u0018\u00010?2\u0006\u0010B\u001a\u00020AH\u0096\u0001J&\u0010[\u001a\u0004\u0018\u00010Z2\u0006\u0010U\u001a\u00020T2\b\u0010W\u001a\u0004\u0018\u00010V2\b\u0010Y\u001a\u0004\u0018\u00010XH\u0016J\u0012\u0010\\\u001a\u00020\u00052\b\u0010Y\u001a\u0004\u0018\u00010XH\u0016J\u001a\u0010^\u001a\u00020\u00052\u0006\u0010]\u001a\u00020Z2\b\u0010Y\u001a\u0004\u0018\u00010XH\u0016J\b\u0010_\u001a\u00020\u0005H\u0016J\u0010\u0010a\u001a\u00020\u001c2\u0006\u0010\u000b\u001a\u00020`H\u0016J\u0018\u0010e\u001a\u00020\u00052\u0006\u0010c\u001a\u00020b2\u0006\u0010U\u001a\u00020dH\u0016J\u0012\u0010h\u001a\u00020\u00052\b\u0010g\u001a\u0004\u0018\u00010fH\u0016J-\u0010n\u001a\u00020\u00052\u0006\u0010i\u001a\u00020%2\f\u0010k\u001a\b\u0012\u0004\u0012\u00020C0j2\u0006\u0010m\u001a\u00020lH\u0017¢\u0006\u0004\bn\u0010oJ\u0010\u0010q\u001a\u00020\u001c2\u0006\u0010p\u001a\u00020/H\u0016J\b\u0010r\u001a\u00020\u0005H\u0016R\u0016\u0010v\u001a\u00020s8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\bt\u0010uR\u001b\u0010|\u001a\u00020w8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bx\u0010y\u001a\u0004\bz\u0010{R\u0017\u0010\u0080\u0001\u001a\u00020}8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b~\u0010\u007fR$\u0010\u0084\u0001\u001a\u000f\u0012\u0004\u0012\u00020#\u0012\u0004\u0012\u00020+0\u0081\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\b\u0082\u0001\u0010\u0083\u0001R\u001c\u0010\u0088\u0001\u001a\u0005\u0018\u00010\u0085\u00018\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\b\u0086\u0001\u0010\u0087\u0001R\u001b\u0010\u008b\u0001\u001a\u0004\u0018\u00010#8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\b\u0089\u0001\u0010\u008a\u0001R*\u0010\u0093\u0001\u001a\u00030\u008c\u00018\u0006@\u0006X\u0087.¢\u0006\u0018\n\u0006\b\u008d\u0001\u0010\u008e\u0001\u001a\u0006\b\u008f\u0001\u0010\u0090\u0001\"\u0006\b\u0091\u0001\u0010\u0092\u0001R*\u0010\u009b\u0001\u001a\u00030\u0094\u00018\u0006@\u0006X\u0087.¢\u0006\u0018\n\u0006\b\u0095\u0001\u0010\u0096\u0001\u001a\u0006\b\u0097\u0001\u0010\u0098\u0001\"\u0006\b\u0099\u0001\u0010\u009a\u0001R\u0019\u0010\u009e\u0001\u001a\u00020f8\u0002@\u0002X\u0082.¢\u0006\b\n\u0006\b\u009c\u0001\u0010\u009d\u0001R \u0010£\u0001\u001a\u00030\u009f\u00018BX\u0082\u0084\u0002¢\u0006\u000f\n\u0005\b \u0001\u0010y\u001a\u0006\b¡\u0001\u0010¢\u0001R\u0019\u0010¦\u0001\u001a\u00020%8\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\b¤\u0001\u0010¥\u0001¨\u0006ª\u0001"}, d2 = {"Lca/canadapost/module/flex/FindFlexPostOfficeFragment;", "Lu8/b;", "Lb8/a$a;", "Lw8/o;", "Lcom/google/android/gms/maps/GoogleMap$OnMarkerClickListener;", "Lrm/n0;", "z0", "q0", "U0", "R0", "Lca/canadapost/core/data/flex/model/FlexLocation$FlexLocationItem;", "item", "e1", "S0", "V0", "d1", "X0", "", "text", "f1", "a1", "g1", "A0", "h1", "l1", "Landroid/location/Location;", "location1", "location2", "", "B0", "v0", "i1", "Lc8/d;", "mapSearchState", "Q0", "Lca/canadapost/core/data/flex/model/MapLocation;", FirebaseAnalytics.Param.LOCATION, "", "zoomLevel", "C0", "T0", "W0", "", "Lc8/a;", "markerSet", "p0", "placeDetail", "Lcom/google/android/gms/maps/model/Marker;", "o0", "u0", "Lkotlin/Function0;", "stuffToDo", "t0", "id", "Lcom/google/android/gms/maps/model/BitmapDescriptor;", "m1", "showContainer", "k1", "Ll8/c;", Constants.IPC_BUNDLE_KEY_SEND_ERROR, "Landroidx/fragment/app/f;", "fragment", "s0", "Lca/canadapost/core/data/model/ValidationError;", "validationError", "Landroid/content/Context;", "context", "", "m", "code", "message", "n", "i", "j", "h", "d", "a", "Lca/canadapost/core/data/model/ResultWrapper$Error;", "e", "l", "o", "g", "valError", "k", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroid/view/View;", "onCreateView", "onCreate", "view", "onViewCreated", "onResume", "Landroid/view/MenuItem;", "onOptionsItemSelected", "Landroid/view/Menu;", "menu", "Landroid/view/MenuInflater;", "onCreateOptionsMenu", "Lcom/google/android/gms/maps/GoogleMap;", "googleMap", "onMapReady", "requestCode", "", "permissions", "", "grantResults", "onRequestPermissionsResult", "(I[Ljava/lang/String;[I)V", "marker", "onMarkerClick", "onDestroy", "Lhc/q;", "t", "Lhc/q;", "binding", "Lca/canadapost/module/flex/d;", "u", "Lrm/o;", "y0", "()Lca/canadapost/module/flex/d;", "viewModel", "Ljc/c;", "v", "Ljc/c;", "aplBannerService", "", "w", "Ljava/util/Map;", "markersMap", "Landroid/app/AlertDialog;", "x", "Landroid/app/AlertDialog;", "progressDialog", "y", "Lca/canadapost/core/data/flex/model/MapLocation;", "currentSelectedMarker", "Lo8/o;", "z", "Lo8/o;", "x0", "()Lo8/o;", "setTransitionAnimation", "(Lo8/o;)V", "transitionAnimation", "Lp9/h;", "A", "Lp9/h;", "getFeatureFlagRepository", "()Lp9/h;", "setFeatureFlagRepository", "(Lp9/h;)V", "featureFlagRepository", "B", "Lcom/google/android/gms/maps/GoogleMap;", "map", "Lcom/google/android/gms/location/FusedLocationProviderClient;", "C", "w0", "()Lcom/google/android/gms/location/FusedLocationProviderClient;", "fusedLocationProviderClient", "D", "I", "navigationBarPaddingBottom", "<init>", "()V", "E", "flex_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class FindFlexPostOfficeFragment extends u8.b implements a.InterfaceC0176a, w8.o, GoogleMap.OnMarkerClickListener {

    /* renamed from: A, reason: from kotlin metadata */
    public p9.h featureFlagRepository;

    /* renamed from: B, reason: from kotlin metadata */
    private GoogleMap map;

    /* renamed from: C, reason: from kotlin metadata */
    private final rm.o fusedLocationProviderClient;

    /* renamed from: D, reason: from kotlin metadata */
    private int navigationBarPaddingBottom;

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

    /* renamed from: v, reason: collision with root package name and from kotlin metadata */
    private jc.c aplBannerService;

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

    /* renamed from: y, reason: collision with root package name and from kotlin metadata */
    private MapLocation currentSelectedMarker;

    /* renamed from: z, reason: collision with root package name and from kotlin metadata */
    public o8.o transitionAnimation;

    /* renamed from: s, reason: collision with root package name */
    private final /* synthetic */ w8.k f9374s = new w8.k(null, null, null, 7, null);

    /* renamed from: u, reason: collision with root package name and from kotlin metadata */
    private final rm.o viewModel = p0.a(this, kotlin.jvm.internal.p0.b(ca.canadapost.module.flex.d.class), new n(new m(this)), new p());

    /* renamed from: w, reason: collision with root package name and from kotlin metadata */
    private final Map markersMap = new LinkedHashMap();

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

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m137invoke() {
            GoogleMap googleMap = FindFlexPostOfficeFragment.this.map;
            if (googleMap == null) {
                t.y("map");
                googleMap = null;
            }
            googleMap.clear();
            FindFlexPostOfficeFragment.this.markersMap.clear();
        }
    }

    /* 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 FusedLocationProviderClient invoke() {
            FusedLocationProviderClient fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient((Activity) FindFlexPostOfficeFragment.this.requireActivity());
            t.f(fusedLocationProviderClient, "getFusedLocationProviderClient(...)");
            return fusedLocationProviderClient;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class d extends v implements dn.a {

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

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ int f9386r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        d(MapLocation mapLocation, int i10) {
            super(0);
            this.f9385q = mapLocation;
            this.f9386r = i10;
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m138invoke() {
            GoogleMap googleMap = FindFlexPostOfficeFragment.this.map;
            if (googleMap == null) {
                t.y("map");
                googleMap = null;
            }
            googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(this.f9385q.getLatitude(), this.f9385q.getLongitude()), this.f9386r));
        }
    }

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

        public final void a(Boolean bool) {
            if (t.b(bool, Boolean.FALSE) && FindFlexPostOfficeFragment.this.y0().E0()) {
                v4.j a10 = x4.d.a(FindFlexPostOfficeFragment.this);
                a10.V(a2.f19553w, true);
                a10.M(a2.f19554x);
            }
        }

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

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* 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 */ d.C0258d f9389p;

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

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

            /* renamed from: invoke, reason: collision with other method in class */
            public final void m139invoke() {
                d.C0258d c0258d = this.f9389p;
                if (c0258d != null) {
                    c0258d.b();
                }
            }
        }

        f() {
            super(1);
        }

        public final void a(d.C0258d c0258d) {
            Context context = FindFlexPostOfficeFragment.this.getContext();
            if (context != null) {
                FindFlexPostOfficeFragment findFlexPostOfficeFragment = FindFlexPostOfficeFragment.this;
                g.a aVar = u8.g.f36993k;
                String string = context.getString(e2.f19646o);
                t.f(string, "getString(...)");
                u8.g l10 = aVar.l(context, string, findFlexPostOfficeFragment.getString(e2.f19648p));
                l10.n(findFlexPostOfficeFragment.getString(e2.f19638k));
                l10.p(findFlexPostOfficeFragment.getString(e2.f19626e));
                l10.o(new a(c0258d));
                l10.x(context);
            }
        }

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

    /* loaded from: classes4.dex */
    public static final class g extends BottomSheetBehavior.f {
        g() {
        }

        @Override // com.google.android.material.bottomsheet.BottomSheetBehavior.f
        public void b(View bottomSheet, float f10) {
            t.g(bottomSheet, "bottomSheet");
            if (f10 > BitmapDescriptorFactory.HUE_RED) {
                FindFlexPostOfficeFragment.this.R0();
            }
        }

        @Override // com.google.android.material.bottomsheet.BottomSheetBehavior.f
        public void c(View bottomSheet, int i10) {
            t.g(bottomSheet, "bottomSheet");
            if (i10 == 4) {
                FindFlexPostOfficeFragment.this.U0();
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class h extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ c8.d f9391p;

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        h(c8.d dVar, FindFlexPostOfficeFragment findFlexPostOfficeFragment) {
            super(0);
            this.f9391p = dVar;
            this.f9392q = findFlexPostOfficeFragment;
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m140invoke() {
            GoogleMap googleMap = null;
            if (this.f9391p.e() == c8.e.LOCATION_SEARCH) {
                if (this.f9391p.d().isEmpty()) {
                    this.f9392q.C0(this.f9391p.c(), this.f9391p.f());
                    return;
                }
                LatLngBounds.Builder builder = new LatLngBounds.Builder();
                Iterator it = this.f9391p.d().entrySet().iterator();
                while (it.hasNext()) {
                    builder.include(((c8.a) ((Map.Entry) it.next()).getValue()).g().toLatLong());
                }
                LatLngBounds build = builder.build();
                t.f(build, "build(...)");
                GoogleMap googleMap2 = this.f9392q.map;
                if (googleMap2 == null) {
                    t.y("map");
                    googleMap2 = null;
                }
                googleMap2.animateCamera(CameraUpdateFactory.newLatLngBounds(build, 50));
            }
            this.f9392q.p0(this.f9391p.d());
            FlexLocation.FlexLocationItem flexLocationItem = (FlexLocation.FlexLocationItem) this.f9392q.y0().u0().f();
            if (flexLocationItem != null) {
                FindFlexPostOfficeFragment findFlexPostOfficeFragment = this.f9392q;
                findFlexPostOfficeFragment.T0();
                findFlexPostOfficeFragment.e1(flexLocationItem);
            }
            GoogleMap googleMap3 = this.f9392q.map;
            if (googleMap3 == null) {
                t.y("map");
            } else {
                googleMap = googleMap3;
            }
            googleMap.setOnMarkerClickListener(this.f9392q);
        }
    }

    /* loaded from: classes4.dex */
    static final class i implements g0, kotlin.jvm.internal.n {

        /* renamed from: a, reason: collision with root package name */
        private final /* synthetic */ dn.l f9393a;

        i(dn.l function) {
            t.g(function, "function");
            this.f9393a = function;
        }

        @Override // kotlin.jvm.internal.n
        public final rm.i b() {
            return this.f9393a;
        }

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f9393a.invoke(obj);
        }

        public final boolean equals(Object obj) {
            if ((obj instanceof g0) && (obj instanceof kotlin.jvm.internal.n)) {
                return t.b(b(), ((kotlin.jvm.internal.n) obj).b());
            }
            return false;
        }

        public final int hashCode() {
            return b().hashCode();
        }
    }

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

        /* JADX INFO: Access modifiers changed from: private */
        public static final void d(FindFlexPostOfficeFragment this$0) {
            MapLocation c10;
            t.g(this$0, "this$0");
            Location v02 = this$0.v0();
            c8.d dVar = (c8.d) this$0.y0().q0().f();
            if (dVar == null || (c10 = dVar.c()) == null || !this$0.B0(v02, c10.toLocation())) {
                return;
            }
            ca.canadapost.module.flex.d y02 = this$0.y0();
            MapLocation mapLocation = new MapLocation(v02);
            GoogleMap googleMap = this$0.map;
            if (googleMap == null) {
                t.y("map");
                googleMap = null;
            }
            y02.I0(mapLocation, (int) googleMap.getCameraPosition().zoom);
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void g(FindFlexPostOfficeFragment this$0, int i10) {
            t.g(this$0, "this$0");
            if (i10 == 1) {
                this$0.y0().U0();
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void h(FindFlexPostOfficeFragment this$0, LatLng it) {
            t.g(this$0, "this$0");
            t.g(it, "it");
            this$0.y0().U0();
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m141invoke() {
            GoogleMap googleMap = FindFlexPostOfficeFragment.this.map;
            GoogleMap googleMap2 = null;
            if (googleMap == null) {
                t.y("map");
                googleMap = null;
            }
            final FindFlexPostOfficeFragment findFlexPostOfficeFragment = FindFlexPostOfficeFragment.this;
            googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { // from class: ca.canadapost.module.flex.a
                @Override // com.google.android.gms.maps.GoogleMap.OnCameraIdleListener
                public final void onCameraIdle() {
                    FindFlexPostOfficeFragment.j.d(FindFlexPostOfficeFragment.this);
                }
            });
            GoogleMap googleMap3 = FindFlexPostOfficeFragment.this.map;
            if (googleMap3 == null) {
                t.y("map");
                googleMap3 = null;
            }
            final FindFlexPostOfficeFragment findFlexPostOfficeFragment2 = FindFlexPostOfficeFragment.this;
            googleMap3.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() { // from class: ca.canadapost.module.flex.b
                @Override // com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener
                public final void onCameraMoveStarted(int i10) {
                    FindFlexPostOfficeFragment.j.g(FindFlexPostOfficeFragment.this, i10);
                }
            });
            GoogleMap googleMap4 = FindFlexPostOfficeFragment.this.map;
            if (googleMap4 == null) {
                t.y("map");
            } else {
                googleMap2 = googleMap4;
            }
            final FindFlexPostOfficeFragment findFlexPostOfficeFragment3 = FindFlexPostOfficeFragment.this;
            googleMap2.setOnMapClickListener(new GoogleMap.OnMapClickListener() { // from class: ca.canadapost.module.flex.c
                @Override // com.google.android.gms.maps.GoogleMap.OnMapClickListener
                public final void onMapClick(LatLng latLng) {
                    FindFlexPostOfficeFragment.j.h(FindFlexPostOfficeFragment.this, latLng);
                }
            });
        }
    }

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

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m142invoke() {
            c8.d dVar = (c8.d) FindFlexPostOfficeFragment.this.y0().q0().f();
            if (dVar != null) {
                FindFlexPostOfficeFragment.this.Q0(dVar);
            }
            FindFlexPostOfficeFragment.this.l1();
            FindFlexPostOfficeFragment.this.W0();
        }
    }

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

        public final void a(Location location) {
            if (location != null) {
                FindFlexPostOfficeFragment.this.y0().Q0(new MapLocation(location.getLatitude(), location.getLongitude()));
                return;
            }
            c8.d dVar = (c8.d) FindFlexPostOfficeFragment.this.y0().q0().f();
            if (dVar != null) {
                FindFlexPostOfficeFragment.this.y0().Q0(new MapLocation(dVar.c().toLocation()));
            }
        }

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

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

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.fragment.app.f f9397p;

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

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

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

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

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

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

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

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m143invoke() {
            try {
                GoogleMap googleMap = FindFlexPostOfficeFragment.this.map;
                GoogleMap googleMap2 = null;
                if (googleMap == null) {
                    t.y("map");
                    googleMap = null;
                }
                googleMap.setMyLocationEnabled(false);
                GoogleMap googleMap3 = FindFlexPostOfficeFragment.this.map;
                if (googleMap3 == null) {
                    t.y("map");
                } else {
                    googleMap2 = googleMap3;
                }
                UiSettings uiSettings = googleMap2.getUiSettings();
                if (uiSettings == null) {
                    return;
                }
                uiSettings.setMyLocationButtonEnabled(false);
            } catch (SecurityException e10) {
                tr.a.f36618a.c("Exception: %s", e10.getMessage(), e10);
            }
        }
    }

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

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

    public FindFlexPostOfficeFragment() {
        rm.o a10;
        a10 = rm.q.a(new c());
        this.fusedLocationProviderClient = a10;
    }

    private final void A0() {
        if (y0().D0() == null) {
            S0();
        } else {
            y0().O0(Boolean.valueOf(androidx.core.content.a.checkSelfPermission(requireContext(), "android.permission.ACCESS_FINE_LOCATION") == 0));
            h1();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final boolean B0(Location location1, Location location2) {
        return location1.distanceTo(location2) >= 5000.0f;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void C0(MapLocation mapLocation, int i10) {
        t0(new d(mapLocation, i10));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void D0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        w.d(x4.d.a(this$0), a2.f19538h, null, this$0.x0().c(), 2, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void E0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool != null) {
            boolean booleanValue = bool.booleanValue();
            v4.o B = x4.d.a(this$0).B();
            boolean z10 = false;
            if (B != null && B.D() == a2.f19553w) {
                z10 = true;
            }
            if (z10 && booleanValue) {
                w.d(x4.d.a(this$0), a2.f19533c, null, this$0.x0().c(), 2, null);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void F0(FindFlexPostOfficeFragment this$0, FlexLocation.FlexLocationItem flexLocationItem) {
        t.g(this$0, "this$0");
        if (flexLocationItem == null) {
            this$0.k1(false);
            this$0.T0();
        }
        if (flexLocationItem != null) {
            this$0.T0();
            this$0.e1(flexLocationItem);
            this$0.d1(flexLocationItem);
            this$0.X0(flexLocationItem);
            this$0.a1(flexLocationItem);
            this$0.k1(true);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void G0(FindFlexPostOfficeFragment this$0, Event event) {
        boolean C;
        t.g(this$0, "this$0");
        String str = (String) event.getContentIfNotHandled();
        if (str != null) {
            C = y.C(str);
            if (!C) {
                l.a aVar = ca.canadapost.core.common.customView.l.f7730d;
                androidx.fragment.app.k requireActivity = this$0.requireActivity();
                t.f(requireActivity, "requireActivity(...)");
                aVar.a(requireActivity, str);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void H0(FindFlexPostOfficeFragment this$0, Integer num) {
        t.g(this$0, "this$0");
        q qVar = this$0.binding;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        TextView textView = qVar.F;
        u0 u0Var = u0.f26205a;
        String string = this$0.getResources().getString(e2.f19652r);
        t.f(string, "getString(...)");
        String format = String.format(string, Arrays.copyOf(new Object[]{num}, 1));
        t.f(format, "format(...)");
        textView.setText(format);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void I0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        if (t.b(this$0.y0().D0(), Boolean.TRUE)) {
            this$0.i1();
        } else {
            this$0.S0();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void J0(FindFlexPostOfficeFragment 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 u8.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 K0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation = (AdditionalStepBeforeAddLocation) event.getContentIfNotHandled();
        if (additionalStepBeforeAddLocation != null) {
            if (additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.LOGIN) {
                m.a aVar = n8.m.f29859a;
                androidx.fragment.app.k requireActivity = this$0.requireActivity();
                t.f(requireActivity, "requireActivity(...)");
                m.a.b(aVar, requireActivity, null, false, 6, null);
                return;
            }
            if (!(additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.L1AUTH)) {
                if (additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.TANDC) {
                    w.d(x4.d.a(this$0), a2.f19532b, null, this$0.x0().c(), 2, null);
                }
            } else {
                j.a aVar2 = n8.j.f29856a;
                androidx.fragment.app.k requireActivity2 = this$0.requireActivity();
                t.f(requireActivity2, "requireActivity(...)");
                aVar2.a(requireActivity2);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void L0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        jc.c cVar = this$0.aplBannerService;
        if (cVar == null) {
            t.y("aplBannerService");
            cVar = null;
        }
        cVar.j();
        this$0.y0().k0().p(this$0.getViewLifecycleOwner());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void M0(FindFlexPostOfficeFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        x4.d.a(this$0).N(a2.O, androidx.core.os.c.a(c0.a("error_title", this$0.getString(e2.K)), c0.a("error_message", this$0.getString(e2.f19647o0)), c0.a("button_text", this$0.getString(e2.f19634i))));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N0(FindFlexPostOfficeFragment this$0, Event event) {
        MapLocation mapLocation;
        t.g(this$0, "this$0");
        if (event == null || (mapLocation = (MapLocation) event.getContentIfNotHandled()) == null) {
            return;
        }
        this$0.y0().T0(mapLocation);
    }

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

    /* JADX INFO: Access modifiers changed from: private */
    public static final void P0(FindFlexPostOfficeFragment this$0, c8.d dVar) {
        t.g(this$0, "this$0");
        this$0.C();
        t.d(dVar);
        this$0.Q0(dVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void Q0(c8.d dVar) {
        t0(new h(dVar, this));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void R0() {
        if (Build.VERSION.SDK_INT >= 35) {
            q qVar = this.binding;
            q qVar2 = null;
            if (qVar == null) {
                t.y("binding");
                qVar = null;
            }
            if (qVar.C.getPaddingBottom() > 0) {
                q qVar3 = this.binding;
                if (qVar3 == null) {
                    t.y("binding");
                } else {
                    qVar2 = qVar3;
                }
                LinearLayout bottomSheetContainerInner = qVar2.C;
                t.f(bottomSheetContainerInner, "bottomSheetContainerInner");
                bottomSheetContainerInner.setPadding(bottomSheetContainerInner.getPaddingLeft(), bottomSheetContainerInner.getPaddingTop(), bottomSheetContainerInner.getPaddingRight(), 0);
            }
        }
    }

    private final void S0() {
        requestPermissions(new String[]{"android.permission.ACCESS_FINE_LOCATION"}, 1);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void T0() {
        Integer iconResId;
        Marker f10;
        MapLocation mapLocation = this.currentSelectedMarker;
        if (mapLocation != null) {
            c8.a aVar = (c8.a) this.markersMap.get(mapLocation);
            if (aVar != null && (iconResId = aVar.c().getIconResId()) != null && (f10 = aVar.f()) != null) {
                f10.setIcon(m1(iconResId.intValue()));
            }
            this.currentSelectedMarker = null;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void U0() {
        if (Build.VERSION.SDK_INT >= 35) {
            q qVar = this.binding;
            if (qVar == null) {
                t.y("binding");
                qVar = null;
            }
            LinearLayout bottomSheetContainerInner = qVar.C;
            t.f(bottomSheetContainerInner, "bottomSheetContainerInner");
            bottomSheetContainerInner.setPadding(bottomSheetContainerInner.getPaddingLeft(), bottomSheetContainerInner.getPaddingTop(), bottomSheetContainerInner.getPaddingRight(), this.navigationBarPaddingBottom);
        }
    }

    private final void V0() {
        ca.canadapost.module.flex.d y02 = y0();
        b.a aVar = ca.canadapost.core.common.navigation.ui.b.F;
        y02.N0(aVar.a());
        aVar.b(false);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void W0() {
        t0(new j());
    }

    private final void X0(FlexLocation.FlexLocationItem flexLocationItem) {
        if (flexLocationItem.getFlex() == null) {
            CharSequence text = requireActivity().getText(e2.G);
            t.f(text, "getText(...)");
            f1(text);
            return;
        }
        FlexLocation.FlexLocationItem.Flex flex = flexLocationItem.getFlex();
        t.e(flex, "null cannot be cast to non-null type ca.canadapost.core.data.flex.model.FlexLocation.FlexLocationItem.Flex");
        if (!t.b(flex.getStatus(), "ACTIVE")) {
            CharSequence text2 = requireActivity().getText(e2.f19650q);
            t.f(text2, "getText(...)");
            f1(text2);
            return;
        }
        q qVar = this.binding;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.H.B.setText(flex.isSaved() ? requireActivity().getText(e2.E) : requireActivity().getText(e2.f19640l));
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
            qVar3 = null;
        }
        qVar3.H.B.setTextColor(flex.isSaved() ? requireActivity().getColor(y1.f19879c) : requireActivity().getColor(y1.f19877a));
        q qVar4 = this.binding;
        if (qVar4 == null) {
            t.y("binding");
            qVar4 = null;
        }
        qVar4.H.B.setCompoundDrawablesWithIntrinsicBounds(flex.isSaved() ? z1.f19889g : z1.f19887e, 0, 0, 0);
        if (flex.isSaved()) {
            q qVar5 = this.binding;
            if (qVar5 == null) {
                t.y("binding");
            } else {
                qVar2 = qVar5;
            }
            qVar2.H.B.setOnClickListener(new View.OnClickListener() { // from class: gc.s
                @Override // android.view.View.OnClickListener
                public final void onClick(View view) {
                    FindFlexPostOfficeFragment.Y0(FindFlexPostOfficeFragment.this, view);
                }
            });
            return;
        }
        q qVar6 = this.binding;
        if (qVar6 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar6;
        }
        qVar2.H.B.setOnClickListener(new View.OnClickListener() { // from class: gc.t
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                FindFlexPostOfficeFragment.Z0(FindFlexPostOfficeFragment.this, view);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Y0(FindFlexPostOfficeFragment this$0, View view) {
        t.g(this$0, "this$0");
        this$0.y0().V0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Z0(FindFlexPostOfficeFragment this$0, View view) {
        t.g(this$0, "this$0");
        this$0.y0().e0();
    }

    private final void a1(FlexLocation.FlexLocationItem flexLocationItem) {
        if (flexLocationItem.getApl() == null) {
            CharSequence text = requireActivity().getText(e2.f19662z);
            t.f(text, "getText(...)");
            g1(text);
            return;
        }
        FlexLocation.FlexLocationItem.Apl apl = flexLocationItem.getApl();
        t.e(apl, "null cannot be cast to non-null type ca.canadapost.core.data.flex.model.FlexLocation.FlexLocationItem.Apl");
        if (!t.b(apl.getStatus(), "ACTIVE")) {
            CharSequence text2 = requireActivity().getText(e2.f19650q);
            t.f(text2, "getText(...)");
            g1(text2);
            return;
        }
        q qVar = this.binding;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.H.C.setVisibility(0);
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
            qVar3 = null;
        }
        qVar3.H.C.setText(apl.isSaved() ? requireActivity().getText(e2.F) : requireActivity().getText(e2.f19642m));
        q qVar4 = this.binding;
        if (qVar4 == null) {
            t.y("binding");
            qVar4 = null;
        }
        qVar4.H.C.setTextColor(apl.isSaved() ? requireActivity().getColor(y1.f19879c) : requireActivity().getColor(y1.f19877a));
        q qVar5 = this.binding;
        if (qVar5 == null) {
            t.y("binding");
            qVar5 = null;
        }
        qVar5.H.C.setCompoundDrawablesWithIntrinsicBounds(apl.isSaved() ? z1.f19890h : z1.f19886d, 0, 0, 0);
        if (apl.isSaved()) {
            q qVar6 = this.binding;
            if (qVar6 == null) {
                t.y("binding");
            } else {
                qVar2 = qVar6;
            }
            qVar2.H.C.setOnClickListener(new View.OnClickListener() { // from class: gc.v
                @Override // android.view.View.OnClickListener
                public final void onClick(View view) {
                    FindFlexPostOfficeFragment.b1(FindFlexPostOfficeFragment.this, view);
                }
            });
            return;
        }
        q qVar7 = this.binding;
        if (qVar7 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar7;
        }
        qVar2.H.C.setOnClickListener(new View.OnClickListener() { // from class: gc.w
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                FindFlexPostOfficeFragment.c1(FindFlexPostOfficeFragment.this, view);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void b1(FindFlexPostOfficeFragment this$0, View view) {
        t.g(this$0, "this$0");
        this$0.y0().X0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void c1(FindFlexPostOfficeFragment this$0, View view) {
        t.g(this$0, "this$0");
        this$0.y0().g0();
    }

    private final void d1(FlexLocation.FlexLocationItem flexLocationItem) {
        q qVar = this.binding;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.H.A.setVisibility(y0().i0(flexLocationItem) ? 0 : 8);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void e1(FlexLocation.FlexLocationItem flexLocationItem) {
        Marker f10;
        String latitude = flexLocationItem.getLatitude();
        Double j10 = latitude != null ? kotlin.text.w.j(latitude) : null;
        String longitude = flexLocationItem.getLongitude();
        Double j11 = longitude != null ? kotlin.text.w.j(longitude) : null;
        if (j10 == null || j11 == null) {
            return;
        }
        MapLocation mapLocation = new MapLocation(j10.doubleValue(), j11.doubleValue());
        c8.a aVar = (c8.a) this.markersMap.get(mapLocation);
        if (aVar != null) {
            c8.c h10 = aVar.h();
            Integer iconResId = h10 != null ? h10.getIconResId() : null;
            if (iconResId != null && (f10 = aVar.f()) != null) {
                f10.setIcon(m1(iconResId.intValue()));
            }
        }
        this.currentSelectedMarker = mapLocation;
    }

    private final void f1(CharSequence charSequence) {
        q qVar = this.binding;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.H.B.setText(charSequence);
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
            qVar3 = null;
        }
        qVar3.H.B.setTextColor(requireActivity().getColor(y1.f19878b));
        q qVar4 = this.binding;
        if (qVar4 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar4;
        }
        qVar2.H.B.setCompoundDrawablesWithIntrinsicBounds(z1.f19884b, 0, 0, 0);
    }

    private final void g1(CharSequence charSequence) {
        q qVar = this.binding;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.H.C.setText(charSequence);
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
            qVar3 = null;
        }
        qVar3.H.C.setTextColor(requireActivity().getColor(y1.f19880d));
        q qVar4 = this.binding;
        if (qVar4 == null) {
            t.y("binding");
            qVar4 = null;
        }
        qVar4.H.C.setCompoundDrawablesWithIntrinsicBounds(z1.f19888f, 0, 0, 0);
        q qVar5 = this.binding;
        if (qVar5 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar5;
        }
        qVar2.H.C.setVisibility(8);
    }

    private final void h1() {
        t0(new k());
    }

    private final void i1() {
        Task<Location> lastLocation = w0().getLastLocation();
        final l lVar = new l();
        lastLocation.addOnSuccessListener(new OnSuccessListener() { // from class: gc.n
            @Override // com.google.android.gms.tasks.OnSuccessListener
            public final void onSuccess(Object obj) {
                FindFlexPostOfficeFragment.j1(dn.l.this, obj);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void j1(dn.l tmp0, Object obj) {
        t.g(tmp0, "$tmp0");
        tmp0.invoke(obj);
    }

    private final void k1(boolean z10) {
        q qVar = this.binding;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        ViewGroup.LayoutParams layoutParams = qVar.A.getLayoutParams();
        t.e(layoutParams, "null cannot be cast to non-null type androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams");
        CoordinatorLayout.f fVar = (CoordinatorLayout.f) layoutParams;
        ((ViewGroup.MarginLayoutParams) fVar).height = z10 ? -2 : 0;
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar3;
        }
        qVar2.A.setLayoutParams(fVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void l1() {
        t0(new o());
    }

    private final BitmapDescriptor m1(int id2) {
        Drawable f10 = androidx.core.content.res.h.f(getResources(), id2, null);
        if (f10 == null) {
            BitmapDescriptor defaultMarker = BitmapDescriptorFactory.defaultMarker();
            t.f(defaultMarker, "defaultMarker(...)");
            return defaultMarker;
        }
        Bitmap createBitmap = Bitmap.createBitmap(f10.getIntrinsicWidth(), f10.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        t.f(createBitmap, "createBitmap(...)");
        Canvas canvas = new Canvas(createBitmap);
        f10.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        f10.draw(canvas);
        BitmapDescriptor fromBitmap = BitmapDescriptorFactory.fromBitmap(createBitmap);
        t.f(fromBitmap, "fromBitmap(...)");
        return fromBitmap;
    }

    private final Marker o0(c8.a placeDetail) {
        Integer iconResId = placeDetail.c().getIconResId();
        GoogleMap googleMap = null;
        BitmapDescriptor m12 = iconResId != null ? m1(iconResId.intValue()) : null;
        GoogleMap googleMap2 = this.map;
        if (googleMap2 == null) {
            t.y("map");
        } else {
            googleMap = googleMap2;
        }
        return googleMap.addMarker(new MarkerOptions().position(placeDetail.g().toLatLong()).title(placeDetail.j()).snippet(placeDetail.i()).icon(m12).infoWindowAnchor(placeDetail.d(), placeDetail.e()).draggable(placeDetail.b()).zIndex(placeDetail.k()));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void p0(Map map) {
        c8.a aVar;
        Marker f10;
        for (Map.Entry entry : map.entrySet()) {
            if (((c8.a) entry.getValue()).c().getIconResId() != null) {
                if (this.markersMap.get(entry.getKey()) != null && (aVar = (c8.a) this.markersMap.get(entry.getKey())) != null && (f10 = aVar.f()) != null) {
                    f10.remove();
                }
                ((c8.a) entry.getValue()).l(o0((c8.a) entry.getValue()));
                this.markersMap.put(entry.getKey(), entry.getValue());
            }
        }
    }

    private final void q0() {
        q qVar = this.binding;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        s0.A0(qVar.C, new h0() { // from class: gc.u
            @Override // androidx.core.view.h0
            public final androidx.core.view.h1 a(View view, androidx.core.view.h1 h1Var) {
                androidx.core.view.h1 r02;
                r02 = FindFlexPostOfficeFragment.r0(FindFlexPostOfficeFragment.this, view, h1Var);
                return r02;
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final h1 r0(FindFlexPostOfficeFragment this$0, View v10, h1 insets) {
        t.g(this$0, "this$0");
        t.g(v10, "v");
        t.g(insets, "insets");
        androidx.core.graphics.b f10 = insets.f(h1.l.f());
        t.f(f10, "getInsets(...)");
        v10.setPadding(v10.getPaddingLeft(), v10.getPaddingTop(), v10.getPaddingRight(), f10.f3727d);
        this$0.navigationBarPaddingBottom = f10.f3727d;
        return h1.f3850b;
    }

    private final void t0(dn.a aVar) {
        if (this.map != null) {
            aVar.invoke();
        }
    }

    private final void u0() {
        t0(new b());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final Location v0() {
        Location location = new Location("");
        GoogleMap googleMap = this.map;
        GoogleMap googleMap2 = null;
        if (googleMap == null) {
            t.y("map");
            googleMap = null;
        }
        location.setLatitude(googleMap.getCameraPosition().target.latitude);
        GoogleMap googleMap3 = this.map;
        if (googleMap3 == null) {
            t.y("map");
        } else {
            googleMap2 = googleMap3;
        }
        location.setLongitude(googleMap2.getCameraPosition().target.longitude);
        return location;
    }

    private final FusedLocationProviderClient w0() {
        return (FusedLocationProviderClient) this.fusedLocationProviderClient.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final ca.canadapost.module.flex.d y0() {
        return (ca.canadapost.module.flex.d) this.viewModel.getValue();
    }

    private final void z0() {
        Context context = getContext();
        if (context != null) {
            jc.c cVar = new jc.c(context);
            this.aplBannerService = cVar;
            q qVar = this.binding;
            if (qVar == null) {
                t.y("binding");
                qVar = null;
            }
            View x10 = qVar.x();
            t.e(x10, "null cannot be cast to non-null type android.view.ViewGroup");
            cVar.c((ViewGroup) x10);
        }
    }

    @Override // w8.o
    public String a(Context context) {
        t.g(context, "context");
        return this.f9374s.a(context);
    }

    @Override // w8.o
    public String d(Context context) {
        t.g(context, "context");
        return this.f9374s.d(context);
    }

    @Override // w8.o
    public void e(ResultWrapper.Error error, Context context) {
        t.g(error, "error");
        t.g(context, "context");
        this.f9374s.e(error, context);
    }

    @Override // w8.o
    public void g(androidx.fragment.app.f fragment, ResultWrapper.Error error) {
        t.g(fragment, "fragment");
        t.g(error, "error");
        this.f9374s.g(fragment, error);
    }

    @Override // w8.o
    public String h(Context context) {
        t.g(context, "context");
        return this.f9374s.h(context);
    }

    @Override // w8.o
    public String i(ValidationError validationError, Context context) {
        t.g(context, "context");
        return this.f9374s.i(validationError, context);
    }

    @Override // w8.o
    public String j(String code, Context context) {
        t.g(code, "code");
        t.g(context, "context");
        return this.f9374s.j(code, context);
    }

    @Override // w8.o
    public void k(ValidationError validationError, Context context) {
        t.g(context, "context");
        this.f9374s.k(validationError, context);
    }

    @Override // w8.o
    public void l(androidx.fragment.app.f fragment, ResultWrapper.Error error) {
        t.g(fragment, "fragment");
        t.g(error, "error");
        this.f9374s.l(fragment, error);
    }

    @Override // w8.o
    public String m(ValidationError validationError, Context context) {
        t.g(context, "context");
        return this.f9374s.m(validationError, context);
    }

    @Override // w8.o
    public String n(String code, String message, Context context) {
        t.g(code, "code");
        t.g(context, "context");
        return this.f9374s.n(code, message, context);
    }

    @Override // w8.o
    public void o(Context context) {
        t.g(context, "context");
        this.f9374s.o(context);
    }

    @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(c2.f19594c, menu);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        s0(y0(), this);
        androidx.databinding.n h10 = androidx.databinding.f.h(inflater, b2.f19567i, container, false);
        t.f(h10, "inflate(...)");
        q qVar = (q) h10;
        this.binding = qVar;
        q qVar2 = null;
        if (qVar == null) {
            t.y("binding");
            qVar = null;
        }
        qVar.O(getViewLifecycleOwner());
        q qVar3 = this.binding;
        if (qVar3 == null) {
            t.y("binding");
            qVar3 = null;
        }
        qVar3.U(y0());
        z0();
        q qVar4 = this.binding;
        if (qVar4 == null) {
            t.y("binding");
        } else {
            qVar2 = qVar4;
        }
        return qVar2.x();
    }

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

    @Override // b8.a.InterfaceC0176a
    public void onMapReady(GoogleMap googleMap) {
        if (googleMap == null) {
            return;
        }
        this.map = googleMap;
        A0();
    }

    @Override // com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
    public boolean onMarkerClick(Marker marker) {
        t.g(marker, "marker");
        ca.canadapost.module.flex.d y02 = y0();
        LatLng position = marker.getPosition();
        t.f(position, "getPosition(...)");
        y02.J0(new MapLocation(position));
        return true;
    }

    @Override // androidx.fragment.app.f
    public boolean onOptionsItemSelected(MenuItem item) {
        t.g(item, "item");
        if (item.getItemId() == a2.N) {
            y0().K0();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override // androidx.fragment.app.f
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        t.g(permissions, "permissions");
        t.g(grantResults, "grantResults");
        if (requestCode != 1) {
            y0().O0(Boolean.FALSE);
            h1();
            return;
        }
        if ((!(grantResults.length == 0)) && grantResults[0] == 0) {
            y0().O0(Boolean.TRUE);
            h1();
            i1();
        }
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onResume() {
        super.onResume();
        y0().L0();
        androidx.fragment.app.k requireActivity = requireActivity();
        t.e(requireActivity, "null cannot be cast to non-null type ca.canadapost.core.common.navigation.ui.ModuleActivity");
        ((ca.canadapost.core.common.navigation.ui.b) requireActivity).c0();
        V0();
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        if (requireActivity() instanceof FlexActivity) {
            androidx.fragment.app.k activity = getActivity();
            if (activity != null) {
                activity.setTitle(getString(e2.N));
            }
        } else {
            androidx.fragment.app.k activity2 = getActivity();
            if (activity2 != null) {
                activity2.setTitle(getString(e2.f19619a0));
            }
        }
        androidx.fragment.app.f l02 = getChildFragmentManager().l0("map_fragment");
        q qVar = null;
        SupportMapFragment supportMapFragment = l02 instanceof SupportMapFragment ? (SupportMapFragment) l02 : null;
        if (supportMapFragment == null) {
            return;
        }
        Context requireContext = requireContext();
        t.f(requireContext, "requireContext(...)");
        new b8.a(supportMapFragment, this, requireContext);
        y0().z0().j(getViewLifecycleOwner(), new g0() { // from class: gc.x
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.I0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().x0().j(getViewLifecycleOwner(), new g0() { // from class: gc.b0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.N0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().l0().j(getViewLifecycleOwner(), new g0() { // from class: gc.c0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.O0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().q0().j(getViewLifecycleOwner(), new g0() { // from class: gc.d0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.P0(FindFlexPostOfficeFragment.this, (c8.d) obj);
            }
        });
        y0().s0().j(getViewLifecycleOwner(), new g0() { // from class: gc.e0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.D0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().r0().j(getViewLifecycleOwner(), new g0() { // from class: gc.f0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.E0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().u0().j(getViewLifecycleOwner(), new g0() { // from class: gc.o
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.F0(FindFlexPostOfficeFragment.this, (FlexLocation.FlexLocationItem) obj);
            }
        });
        y0().A0().j(getViewLifecycleOwner(), new g0() { // from class: gc.p
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.G0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().n0().j(getViewLifecycleOwner(), new g0() { // from class: gc.q
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.H0(FindFlexPostOfficeFragment.this, (Integer) obj);
            }
        });
        y0().B0().j(getViewLifecycleOwner(), new g0() { // from class: gc.r
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.J0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().t0().j(getViewLifecycleOwner(), new g0() { // from class: gc.y
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.K0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().k0().j(getViewLifecycleOwner(), new g0() { // from class: gc.z
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.L0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().w0().j(getViewLifecycleOwner(), new g0() { // from class: gc.a0
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                FindFlexPostOfficeFragment.M0(FindFlexPostOfficeFragment.this, (Event) obj);
            }
        });
        y0().F0().j(getViewLifecycleOwner(), new i(new e()));
        y0().y0().j(getViewLifecycleOwner(), new i(new f()));
        k1(false);
        q qVar2 = this.binding;
        if (qVar2 == null) {
            t.y("binding");
        } else {
            qVar = qVar2;
        }
        BottomSheetBehavior f02 = BottomSheetBehavior.f0(qVar.B);
        t.f(f02, "from(...)");
        if (y0().m0()) {
            y0().P0(false);
            f02.H0(3);
        }
        if (Build.VERSION.SDK_INT >= 35) {
            q0();
        }
        f02.W(new g());
    }

    public void s0(l8.c error, androidx.fragment.app.f fragment) {
        t.g(error, "error");
        t.g(fragment, "fragment");
        this.f9374s.b(error, fragment);
    }

    public final o8.o x0() {
        o8.o oVar = this.transitionAnimation;
        if (oVar != null) {
            return oVar;
        }
        t.y("transitionAnimation");
        return null;
    }
}
