package ca.canadapost.module.track.workers;

import android.content.Context;
import androidx.work.CoroutineWorker;
import androidx.work.ListenableWorker;
import androidx.work.WorkerParameters;
import dn.p;
import fg.c;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.d;
import kotlin.coroutines.jvm.internal.l;
import kotlin.jvm.internal.t;
import rm.n0;
import rm.y;
import tp.a1;
import tp.i;
import tp.i0;
import tp.m0;
import y7.f;

@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\r\u001a\u00020\f\u0012\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b\u0010\u0010\u0011J\u0010\u0010\u0003\u001a\u00020\u0002H\u0096@¢\u0006\u0004\b\u0003\u0010\u0004R\"\u0010\u000b\u001a\u00020\u00058\u0006@\u0006X\u0087.¢\u0006\u0012\n\u0004\b\u0006\u0010\u0007\u001a\u0004\b\u0006\u0010\b\"\u0004\b\t\u0010\n¨\u0006\u0012"}, d2 = {"Lca/canadapost/module/track/workers/PurgeDeletedItemsWorker;", "Landroidx/work/CoroutineWorker;", "Landroidx/work/ListenableWorker$a;", "r", "(Lvm/d;)Ljava/lang/Object;", "Lfg/c;", "x", "Lfg/c;", "()Lfg/c;", "setTrackRepository", "(Lfg/c;)V", "trackRepository", "Landroid/content/Context;", "appContext", "Landroidx/work/WorkerParameters;", "workerParams", "<init>", "(Landroid/content/Context;Landroidx/work/WorkerParameters;)V", "track_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class PurgeDeletedItemsWorker extends CoroutineWorker {

    /* renamed from: x, reason: collision with root package name and from kotlin metadata */
    public c trackRepository;

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

        /* renamed from: p, reason: collision with root package name */
        /* synthetic */ Object f11315p;

        /* renamed from: r, reason: collision with root package name */
        int f11317r;

        a(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f11315p = obj;
            this.f11317r |= Integer.MIN_VALUE;
            return PurgeDeletedItemsWorker.this.r(this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class b extends l implements p {

        /* renamed from: p, reason: collision with root package name */
        int f11318p;

        b(vm.d dVar) {
            super(2, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new b(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f11318p;
            try {
                if (i10 == 0) {
                    y.b(obj);
                    c x10 = PurgeDeletedItemsWorker.this.x();
                    this.f11318p = 1;
                    if (x10.G(this) == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                return ListenableWorker.a.e();
            } catch (Exception e10) {
                tr.a.f36618a.c("Error updating latest for track packages", e10);
                return ListenableWorker.a.a();
            }
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((b) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public PurgeDeletedItemsWorker(Context appContext, WorkerParameters workerParams) {
        super(appContext, workerParams);
        t.g(appContext, "appContext");
        t.g(workerParams, "workerParams");
        f.a(this, appContext);
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    @Override // androidx.work.CoroutineWorker
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object r(vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f11317r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f11317r = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f11315p;
                f10 = wm.d.f();
                i10 = aVar.f11317r;
                if (i10 != 0) {
                    y.b(obj);
                    i0 b10 = a1.b();
                    b bVar = new b(null);
                    aVar.f11317r = 1;
                    obj = i.g(b10, bVar, aVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                t.f(obj, "withContext(...)");
                return obj;
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f11315p;
        f10 = wm.d.f();
        i10 = aVar.f11317r;
        if (i10 != 0) {
        }
        t.f(obj2, "withContext(...)");
        return obj2;
    }

    public final c x() {
        c cVar = this.trackRepository;
        if (cVar != null) {
            return cVar;
        }
        t.y("trackRepository");
        return null;
    }
}
