package com.revenuecat.purchases.storage;

import J4.a;
import V4.H;
import com.revenuecat.purchases.InternalRevenueCatAPI;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes3.dex */
@InternalRevenueCatAPI
public final class KeyedDeferredValueStore<H, T> {
    private final Map<H, H> deferred;
    private final Object lock;

    /* JADX WARN: Illegal instructions before constructor call */
    public KeyedDeferredValueStore() {
        h hVar = null;
        this(hVar, 1, hVar);
    }

    private final H forgettingFailure(H h5, a aVar) {
        H h6 = (H) aVar.invoke();
        h6.invokeOnCompletion(new KeyedDeferredValueStore$forgettingFailure$1$1(this, h5));
        return h6;
    }

    public final Map<H, H> getDeferred() {
        return this.deferred;
    }

    public final H getOrPut(H h5, a task) {
        H hForgettingFailure;
        o.h(task, "task");
        synchronized (this.lock) {
            hForgettingFailure = this.deferred.get(h5);
            if (hForgettingFailure == null) {
                hForgettingFailure = forgettingFailure(h5, task);
                this.deferred.put(h5, hForgettingFailure);
            }
        }
        return hForgettingFailure;
    }

    public KeyedDeferredValueStore(Object lock) {
        o.h(lock, "lock");
        this.lock = lock;
        this.deferred = new LinkedHashMap();
    }

    public /* synthetic */ KeyedDeferredValueStore(Object obj, int i6, h hVar) {
        this((i6 & 1) != 0 ? new Object() { // from class: com.revenuecat.purchases.storage.KeyedDeferredValueStore.1
        } : obj);
    }
}
