package coil;

import A4.d;
import android.content.Context;
import coil.request.Disposable;
import coil.request.ImageRequest;
import w4.InterfaceC3141c;

/* JADX INFO: loaded from: classes.dex */
public final class Coil {
    public static final Coil INSTANCE = new Coil();
    private static ImageLoader imageLoader;
    private static ImageLoaderFactory imageLoaderFactory;

    private Coil() {
    }

    @InterfaceC3141c
    public static final Disposable enqueue(ImageRequest imageRequest) {
        throw new IllegalStateException("Unsupported");
    }

    @InterfaceC3141c
    public static final Object execute(ImageRequest imageRequest, d dVar) {
        throw new IllegalStateException("Unsupported");
    }

    public static final ImageLoader imageLoader(Context context) {
        ImageLoader imageLoader2 = imageLoader;
        return imageLoader2 == null ? INSTANCE.newImageLoader(context) : imageLoader2;
    }

    private final synchronized ImageLoader newImageLoader(Context context) {
        ImageLoader imageLoaderNewImageLoader;
        try {
            ImageLoader imageLoader2 = imageLoader;
            if (imageLoader2 != null) {
                return imageLoader2;
            }
            ImageLoaderFactory imageLoaderFactory2 = imageLoaderFactory;
            if (imageLoaderFactory2 == null || (imageLoaderNewImageLoader = imageLoaderFactory2.newImageLoader()) == null) {
                Object applicationContext = context.getApplicationContext();
                ImageLoaderFactory imageLoaderFactory3 = applicationContext instanceof ImageLoaderFactory ? (ImageLoaderFactory) applicationContext : null;
                imageLoaderNewImageLoader = imageLoaderFactory3 != null ? imageLoaderFactory3.newImageLoader() : ImageLoaders.create(context);
            }
            imageLoaderFactory = null;
            imageLoader = imageLoaderNewImageLoader;
            return imageLoaderNewImageLoader;
        } catch (Throwable th) {
            throw th;
        }
    }

    public static final synchronized void reset() {
        imageLoader = null;
        imageLoaderFactory = null;
    }

    public static final synchronized void setImageLoader(ImageLoader imageLoader2) {
        imageLoaderFactory = null;
        imageLoader = imageLoader2;
    }

    public static final synchronized void setImageLoader(ImageLoaderFactory imageLoaderFactory2) {
        imageLoaderFactory = imageLoaderFactory2;
        imageLoader = null;
    }
}
