package com.revenuecat.purchases.common;

import W.b;
import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.PresentedOfferingContextSerializer;
import com.revenuecat.purchases.ReplacementMode;
import com.revenuecat.purchases.ReplacementModeSerializer;
import com.revenuecat.purchases.models.Period;
import com.revenuecat.purchases.models.PeriodSerializer;
import com.revenuecat.purchases.models.Price;
import com.revenuecat.purchases.models.PricingPhase;
import com.revenuecat.purchases.models.PricingPhaseSerializer;
import com.revenuecat.purchases.models.StoreProduct;
import com.revenuecat.purchases.models.StoreTransaction;
import com.revenuecat.purchases.models.SubscriptionOption;
import com.revenuecat.purchases.models.SubscriptionOptions;
import g5.a;
import i5.g;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import k5.C2416d;
import k5.H;
import k5.L;
import k5.P;
import k5.a0;
import k5.e0;
import k5.r;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import q.AbstractC2761L;
import w4.InterfaceC3141c;
import x4.AbstractC3253s;
import x4.y;

/* JADX INFO: loaded from: classes3.dex */
public final class ReceiptInfo {
    private static final a[] $childSerializers;
    public static final Companion Companion = new Companion(null);
    private final String currency;
    private final String duration;
    private final String formattedPrice;
    private final String marketplace;
    private final Period period;
    private final List<Map<String, String>> platformProductIds;
    private final PresentedOfferingContext presentedOfferingContext;
    private final Double price;
    private final List<PricingPhase> pricingPhases;
    private final List<String> productIDs;
    private final Long purchaseTime;
    private final ReplacementMode replacementMode;
    private final boolean sdkOriginated;
    private final String storeUserID;

    public static final class Companion {
        public /* synthetic */ Companion(h hVar) {
            this();
        }

        public static /* synthetic */ ReceiptInfo from$default(Companion companion, StoreTransaction storeTransaction, StoreProduct storeProduct, Map map, boolean z6, int i6, Object obj) {
            if ((i6 & 8) != 0) {
                z6 = false;
            }
            return companion.from(storeTransaction, storeProduct, map, z6);
        }

        public final ReceiptInfo from(StoreTransaction storeTransaction, StoreProduct storeProduct, Map<String, ? extends SubscriptionOption> map, boolean z6) {
            SubscriptionOption subscriptionOption;
            PlatformProductId platformProductId;
            Price price;
            Price price2;
            Price price3;
            SubscriptionOption subscriptionOption2;
            PlatformProductId platformProductId2;
            Map<String, String> asMap;
            SubscriptionOptions subscriptionOptions;
            SubscriptionOption next;
            o.h(storeTransaction, "storeTransaction");
            if (storeProduct == null || (subscriptionOptions = storeProduct.getSubscriptionOptions()) == null) {
                subscriptionOption = null;
            } else {
                Iterator<SubscriptionOption> it = subscriptionOptions.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        next = null;
                        break;
                    }
                    next = it.next();
                    if (o.c(next.getId(), storeTransaction.getSubscriptionOptionId())) {
                        break;
                    }
                }
                subscriptionOption = next;
            }
            if (subscriptionOption == null || (platformProductId = ReceiptInfoKt.platformProductId(subscriptionOption)) == null) {
                platformProductId = storeProduct != null ? ReceiptInfoKt.platformProductId(storeProduct) : null;
            }
            List<String> productIds = storeTransaction.getProductIds();
            ArrayList arrayList = new ArrayList(AbstractC3253s.G(productIds, 10));
            for (String str : productIds) {
                arrayList.add(o.c(str, platformProductId != null ? platformProductId.getProductId() : null) ? platformProductId.getAsMap() : (map == null || (subscriptionOption2 = map.get(str)) == null || (platformProductId2 = ReceiptInfoKt.platformProductId(subscriptionOption2)) == null || (asMap = platformProductId2.getAsMap()) == null) ? new PlatformProductId(str).getAsMap() : asMap);
            }
            return new ReceiptInfo(storeTransaction.getProductIds(), Long.valueOf(storeTransaction.getPurchaseTime()), storeTransaction.getPresentedOfferingContext(), (storeProduct == null || (price3 = storeProduct.getPrice()) == null) ? null : Double.valueOf(price3.getAmountMicros() / 1000000.0d), (storeProduct == null || (price2 = storeProduct.getPrice()) == null) ? null : price2.getFormatted(), (storeProduct == null || (price = storeProduct.getPrice()) == null) ? null : price.getCurrencyCode(), storeProduct != null ? storeProduct.getPeriod() : null, subscriptionOption != null ? subscriptionOption.getPricingPhases() : null, storeTransaction.getReplacementMode(), arrayList, z6, storeTransaction.getStoreUserID(), storeTransaction.getMarketplace());
        }

        public final a serializer() {
            return ReceiptInfo$$serializer.INSTANCE;
        }

        private Companion() {
        }
    }

    static {
        e0 e0Var = e0.f20048a;
        $childSerializers = new a[]{new C2416d(e0Var), null, null, null, null, null, null, new C2416d(PricingPhaseSerializer.INSTANCE), null, new C2416d(new H(e0Var, b.h0(e0Var))), null, null, null, null};
    }

    @InterfaceC3141c
    public /* synthetic */ ReceiptInfo(int i6, List list, Long l, PresentedOfferingContext presentedOfferingContext, Double d6, String str, String str2, Period period, List list2, ReplacementMode replacementMode, List list3, boolean z6, String str3, String str4, String str5, a0 a0Var) {
        String iso8601;
        String str6 = null;
        if (1 != (i6 & 1)) {
            P.h(i6, 1, ReceiptInfo$$serializer.INSTANCE.getDescriptor());
            throw null;
        }
        this.productIDs = list;
        if ((i6 & 2) == 0) {
            this.purchaseTime = null;
        } else {
            this.purchaseTime = l;
        }
        if ((i6 & 4) == 0) {
            this.presentedOfferingContext = null;
        } else {
            this.presentedOfferingContext = presentedOfferingContext;
        }
        if ((i6 & 8) == 0) {
            this.price = null;
        } else {
            this.price = d6;
        }
        if ((i6 & 16) == 0) {
            this.formattedPrice = null;
        } else {
            this.formattedPrice = str;
        }
        if ((i6 & 32) == 0) {
            this.currency = null;
        } else {
            this.currency = str2;
        }
        if ((i6 & 64) == 0) {
            this.period = null;
        } else {
            this.period = period;
        }
        if ((i6 & 128) == 0) {
            this.pricingPhases = null;
        } else {
            this.pricingPhases = list2;
        }
        if ((i6 & 256) == 0) {
            this.replacementMode = null;
        } else {
            this.replacementMode = replacementMode;
        }
        if ((i6 & 512) == 0) {
            this.platformProductIds = y.f26065a;
        } else {
            this.platformProductIds = list3;
        }
        if ((i6 & 1024) == 0) {
            this.sdkOriginated = false;
        } else {
            this.sdkOriginated = z6;
        }
        if ((i6 & 2048) == 0) {
            this.storeUserID = null;
        } else {
            this.storeUserID = str3;
        }
        if ((i6 & 4096) == 0) {
            this.marketplace = null;
        } else {
            this.marketplace = str4;
        }
        if ((i6 & 8192) != 0) {
            this.duration = str5;
            return;
        }
        Period period2 = this.period;
        if (period2 != null && (iso8601 = period2.getIso8601()) != null && iso8601.length() != 0) {
            str6 = iso8601;
        }
        this.duration = str6;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ ReceiptInfo copy$default(ReceiptInfo receiptInfo, List list, Long l, PresentedOfferingContext presentedOfferingContext, Double d6, String str, String str2, Period period, List list2, ReplacementMode replacementMode, List list3, boolean z6, String str3, String str4, int i6, Object obj) {
        if ((i6 & 1) != 0) {
            list = receiptInfo.productIDs;
        }
        return receiptInfo.copy(list, (i6 & 2) != 0 ? receiptInfo.purchaseTime : l, (i6 & 4) != 0 ? receiptInfo.presentedOfferingContext : presentedOfferingContext, (i6 & 8) != 0 ? receiptInfo.price : d6, (i6 & 16) != 0 ? receiptInfo.formattedPrice : str, (i6 & 32) != 0 ? receiptInfo.currency : str2, (i6 & 64) != 0 ? receiptInfo.period : period, (i6 & 128) != 0 ? receiptInfo.pricingPhases : list2, (i6 & 256) != 0 ? receiptInfo.replacementMode : replacementMode, (i6 & 512) != 0 ? receiptInfo.platformProductIds : list3, (i6 & 1024) != 0 ? receiptInfo.sdkOriginated : z6, (i6 & 2048) != 0 ? receiptInfo.storeUserID : str3, (i6 & 4096) != 0 ? receiptInfo.marketplace : str4);
    }

    public static /* synthetic */ void getDuration$annotations() {
    }

    public static /* synthetic */ void getPeriod$annotations() {
    }

    public static /* synthetic */ void getPresentedOfferingContext$annotations() {
    }

    public static /* synthetic */ void getReplacementMode$annotations() {
    }

    public static final /* synthetic */ void write$Self$purchases_defaultsBc8Release(ReceiptInfo receiptInfo, j5.b bVar, g gVar) {
        String iso8601;
        a[] aVarArr = $childSerializers;
        bVar.z(gVar, 0, aVarArr[0], receiptInfo.productIDs);
        if (bVar.g(gVar) || receiptInfo.purchaseTime != null) {
            bVar.E(gVar, 1, L.f20007a, receiptInfo.purchaseTime);
        }
        if (bVar.g(gVar) || receiptInfo.presentedOfferingContext != null) {
            bVar.E(gVar, 2, PresentedOfferingContextSerializer.INSTANCE, receiptInfo.presentedOfferingContext);
        }
        if (bVar.g(gVar) || receiptInfo.price != null) {
            bVar.E(gVar, 3, r.f20087a, receiptInfo.price);
        }
        if (bVar.g(gVar) || receiptInfo.formattedPrice != null) {
            bVar.E(gVar, 4, e0.f20048a, receiptInfo.formattedPrice);
        }
        if (bVar.g(gVar) || receiptInfo.currency != null) {
            bVar.E(gVar, 5, e0.f20048a, receiptInfo.currency);
        }
        if (bVar.g(gVar) || receiptInfo.period != null) {
            bVar.E(gVar, 6, PeriodSerializer.INSTANCE, receiptInfo.period);
        }
        if (bVar.g(gVar) || receiptInfo.pricingPhases != null) {
            bVar.E(gVar, 7, aVarArr[7], receiptInfo.pricingPhases);
        }
        if (bVar.g(gVar) || receiptInfo.replacementMode != null) {
            bVar.E(gVar, 8, ReplacementModeSerializer.INSTANCE, receiptInfo.replacementMode);
        }
        if (bVar.g(gVar) || !o.c(receiptInfo.platformProductIds, y.f26065a)) {
            bVar.z(gVar, 9, aVarArr[9], receiptInfo.platformProductIds);
        }
        if (bVar.g(gVar) || receiptInfo.sdkOriginated) {
            bVar.v(gVar, 10, receiptInfo.sdkOriginated);
        }
        if (bVar.g(gVar) || receiptInfo.storeUserID != null) {
            bVar.E(gVar, 11, e0.f20048a, receiptInfo.storeUserID);
        }
        if (bVar.g(gVar) || receiptInfo.marketplace != null) {
            bVar.E(gVar, 12, e0.f20048a, receiptInfo.marketplace);
        }
        if (!bVar.g(gVar)) {
            String str = receiptInfo.duration;
            Period period = receiptInfo.period;
            String str2 = null;
            if (period != null && (iso8601 = period.getIso8601()) != null && iso8601.length() != 0) {
                str2 = iso8601;
            }
            if (o.c(str, str2)) {
                return;
            }
        }
        bVar.E(gVar, 13, e0.f20048a, receiptInfo.duration);
    }

    public final List<String> component1() {
        return this.productIDs;
    }

    public final List<Map<String, String>> component10() {
        return this.platformProductIds;
    }

    public final boolean component11() {
        return this.sdkOriginated;
    }

    public final String component12() {
        return this.storeUserID;
    }

    public final String component13() {
        return this.marketplace;
    }

    public final Long component2() {
        return this.purchaseTime;
    }

    public final PresentedOfferingContext component3() {
        return this.presentedOfferingContext;
    }

    public final Double component4() {
        return this.price;
    }

    public final String component5() {
        return this.formattedPrice;
    }

    public final String component6() {
        return this.currency;
    }

    public final Period component7() {
        return this.period;
    }

    public final List<PricingPhase> component8() {
        return this.pricingPhases;
    }

    public final ReplacementMode component9() {
        return this.replacementMode;
    }

    public final ReceiptInfo copy(List<String> productIDs, Long l, PresentedOfferingContext presentedOfferingContext, Double d6, String str, String str2, Period period, List<PricingPhase> list, ReplacementMode replacementMode, List<? extends Map<String, String>> platformProductIds, boolean z6, String str3, String str4) {
        o.h(productIDs, "productIDs");
        o.h(platformProductIds, "platformProductIds");
        return new ReceiptInfo(productIDs, l, presentedOfferingContext, d6, str, str2, period, list, replacementMode, platformProductIds, z6, str3, str4);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof ReceiptInfo)) {
            return false;
        }
        ReceiptInfo receiptInfo = (ReceiptInfo) obj;
        return o.c(this.productIDs, receiptInfo.productIDs) && o.c(this.purchaseTime, receiptInfo.purchaseTime) && o.c(this.presentedOfferingContext, receiptInfo.presentedOfferingContext) && o.c(this.price, receiptInfo.price) && o.c(this.formattedPrice, receiptInfo.formattedPrice) && o.c(this.currency, receiptInfo.currency) && o.c(this.period, receiptInfo.period) && o.c(this.pricingPhases, receiptInfo.pricingPhases) && o.c(this.replacementMode, receiptInfo.replacementMode) && o.c(this.platformProductIds, receiptInfo.platformProductIds) && this.sdkOriginated == receiptInfo.sdkOriginated && o.c(this.storeUserID, receiptInfo.storeUserID) && o.c(this.marketplace, receiptInfo.marketplace);
    }

    public final String getCurrency() {
        return this.currency;
    }

    public final String getDuration() {
        return this.duration;
    }

    public final String getFormattedPrice() {
        return this.formattedPrice;
    }

    public final String getMarketplace() {
        return this.marketplace;
    }

    public final Period getPeriod() {
        return this.period;
    }

    public final List<Map<String, String>> getPlatformProductIds() {
        return this.platformProductIds;
    }

    public final PresentedOfferingContext getPresentedOfferingContext() {
        return this.presentedOfferingContext;
    }

    public final Double getPrice() {
        return this.price;
    }

    public final List<PricingPhase> getPricingPhases() {
        return this.pricingPhases;
    }

    public final List<String> getProductIDs() {
        return this.productIDs;
    }

    public final Long getPurchaseTime() {
        return this.purchaseTime;
    }

    public final ReplacementMode getReplacementMode() {
        return this.replacementMode;
    }

    public final boolean getSdkOriginated() {
        return this.sdkOriginated;
    }

    public final String getStoreUserID() {
        return this.storeUserID;
    }

    public int hashCode() {
        int iHashCode = this.productIDs.hashCode() * 31;
        Long l = this.purchaseTime;
        int iHashCode2 = (iHashCode + (l == null ? 0 : l.hashCode())) * 31;
        PresentedOfferingContext presentedOfferingContext = this.presentedOfferingContext;
        int iHashCode3 = (iHashCode2 + (presentedOfferingContext == null ? 0 : presentedOfferingContext.hashCode())) * 31;
        Double d6 = this.price;
        int iHashCode4 = (iHashCode3 + (d6 == null ? 0 : d6.hashCode())) * 31;
        String str = this.formattedPrice;
        int iHashCode5 = (iHashCode4 + (str == null ? 0 : str.hashCode())) * 31;
        String str2 = this.currency;
        int iHashCode6 = (iHashCode5 + (str2 == null ? 0 : str2.hashCode())) * 31;
        Period period = this.period;
        int iHashCode7 = (iHashCode6 + (period == null ? 0 : period.hashCode())) * 31;
        List<PricingPhase> list = this.pricingPhases;
        int iHashCode8 = (iHashCode7 + (list == null ? 0 : list.hashCode())) * 31;
        ReplacementMode replacementMode = this.replacementMode;
        int iF = com.google.android.recaptcha.internal.a.f(AbstractC2761L.c(this.platformProductIds, (iHashCode8 + (replacementMode == null ? 0 : replacementMode.hashCode())) * 31, 31), 31, this.sdkOriginated);
        String str3 = this.storeUserID;
        int iHashCode9 = (iF + (str3 == null ? 0 : str3.hashCode())) * 31;
        String str4 = this.marketplace;
        return iHashCode9 + (str4 != null ? str4.hashCode() : 0);
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("ReceiptInfo(productIDs=");
        sb.append(this.productIDs);
        sb.append(", purchaseTime=");
        sb.append(this.purchaseTime);
        sb.append(", presentedOfferingContext=");
        sb.append(this.presentedOfferingContext);
        sb.append(", price=");
        sb.append(this.price);
        sb.append(", formattedPrice=");
        sb.append(this.formattedPrice);
        sb.append(", currency=");
        sb.append(this.currency);
        sb.append(", period=");
        sb.append(this.period);
        sb.append(", pricingPhases=");
        sb.append(this.pricingPhases);
        sb.append(", replacementMode=");
        sb.append(this.replacementMode);
        sb.append(", platformProductIds=");
        sb.append(this.platformProductIds);
        sb.append(", sdkOriginated=");
        sb.append(this.sdkOriginated);
        sb.append(", storeUserID=");
        sb.append(this.storeUserID);
        sb.append(", marketplace=");
        return Z0.o.r(sb, this.marketplace, ')');
    }

    /* JADX WARN: Multi-variable type inference failed */
    public ReceiptInfo(List<String> productIDs, Long l, PresentedOfferingContext presentedOfferingContext, Double d6, String str, String str2, Period period, List<PricingPhase> list, ReplacementMode replacementMode, List<? extends Map<String, String>> platformProductIds, boolean z6, String str3, String str4) {
        String iso8601;
        o.h(productIDs, "productIDs");
        o.h(platformProductIds, "platformProductIds");
        this.productIDs = productIDs;
        this.purchaseTime = l;
        this.presentedOfferingContext = presentedOfferingContext;
        this.price = d6;
        this.formattedPrice = str;
        this.currency = str2;
        this.period = period;
        this.pricingPhases = list;
        this.replacementMode = replacementMode;
        this.platformProductIds = platformProductIds;
        this.sdkOriginated = z6;
        this.storeUserID = str3;
        this.marketplace = str4;
        String str5 = null;
        if (period != null && (iso8601 = period.getIso8601()) != null && iso8601.length() != 0) {
            str5 = iso8601;
        }
        this.duration = str5;
    }

    public /* synthetic */ ReceiptInfo(List list, Long l, PresentedOfferingContext presentedOfferingContext, Double d6, String str, String str2, Period period, List list2, ReplacementMode replacementMode, List list3, boolean z6, String str3, String str4, int i6, h hVar) {
        this(list, (i6 & 2) != 0 ? null : l, (i6 & 4) != 0 ? null : presentedOfferingContext, (i6 & 8) != 0 ? null : d6, (i6 & 16) != 0 ? null : str, (i6 & 32) != 0 ? null : str2, (i6 & 64) != 0 ? null : period, (i6 & 128) != 0 ? null : list2, (i6 & 256) != 0 ? null : replacementMode, (i6 & 512) != 0 ? y.f26065a : list3, (i6 & 1024) != 0 ? false : z6, (i6 & 2048) != 0 ? null : str3, (i6 & 4096) != 0 ? null : str4);
    }
}
