package eg;

import ca.canadapost.module.track.model.PackageDTPaymentDetails;
import ca.canadapost.module.track.model.PackageDTRefundPaymentDetails;
import ca.canadapost.module.track.model.PackageDetailsDTO;
import ca.canadapost.module.track.model.PackageEligibility;
import ca.canadapost.module.track.model.PackageItemModel;
import java.util.Date;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;

/* loaded from: classes4.dex */
public abstract class c {

    /* renamed from: a, reason: collision with root package name */
    public static final a f17056a = new a(null);

    /* loaded from: classes4.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(k kVar) {
            this();
        }

        public final d a(PackageItemModel item) {
            t.g(item, "item");
            String u10 = new com.google.gson.d().u(item.getDetails());
            String u11 = new com.google.gson.d().u(item.getPackageDTPaymentDetails());
            String u12 = new com.google.gson.d().u(item.getPackageDTRefundPaymentDetails());
            String itemNumber = item.getItemNumber();
            String userDescription = item.getUserDescription();
            long time = item.getModifiedAt().getTime();
            long time2 = item.getCreatedAt().getTime();
            boolean isDnc = item.isDnc();
            boolean isDeleted = item.isDeleted();
            String cloudId = item.getCloudId();
            String u13 = new com.google.gson.d().u(item.getEligibility());
            t.f(u13, "toJson(...)");
            return new d(itemNumber, userDescription, u10, time, time2, isDnc, isDeleted, cloudId, u13, item.getLastUpdatedWithBackend().getTime(), item.getHideDeliveryInstructionNotice(), item.getCurrentDeliveryPreferenceJson(), item.getDutyAndTaxesEmail(), u11, u12, item.isItemSourceSNF(), item.isSNFItemRead(), item.isFlaggedAsNotMine());
        }

        public final PackageItemModel b(d dbItemDao) {
            Object obj;
            Object obj2;
            t.g(dbItemDao, "dbItemDao");
            try {
                PackageEligibility packageEligibility = new PackageEligibility(false, false, false, 7, null);
                String e10 = dbItemDao.e();
                if (e10 != null) {
                    obj2 = new com.google.gson.d().j(e10, PackageDetailsDTO.class);
                    obj = new com.google.gson.d().j(dbItemDao.g(), PackageEligibility.class);
                    t.f(obj, "fromJson(...)");
                } else {
                    obj = packageEligibility;
                    obj2 = null;
                }
                String l10 = dbItemDao.l();
                Object j10 = l10 != null ? new com.google.gson.d().j(l10, PackageDTPaymentDetails.class) : null;
                String m10 = dbItemDao.m();
                return new PackageItemModel(dbItemDao.i(), dbItemDao.d(), new Date(dbItemDao.k()), new Date(dbItemDao.b()), dbItemDao.o(), dbItemDao.n(), dbItemDao.a(), (PackageDetailsDTO) obj2, (PackageEligibility) obj, new Date(dbItemDao.j()), dbItemDao.h(), dbItemDao.c(), dbItemDao.f(), (PackageDTPaymentDetails) j10, (PackageDTRefundPaymentDetails) (m10 != null ? new com.google.gson.d().j(m10, PackageDTRefundPaymentDetails.class) : null), dbItemDao.q(), dbItemDao.r(), dbItemDao.p());
            } catch (Throwable th2) {
                tr.a.f36618a.c("Error while parsing", th2);
                return null;
            }
        }
    }
}
