package ඓ.ῲ.K.ᕣ.㳳;

import com.bumptech.glide.Registry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ῲ.ᨨ.㿎.AbstractC1871;

/* renamed from: ඓ.ῲ.K.ᕣ.㳳.ؿ  reason: contains not printable characters */
/* compiled from: ModelLoaderRegistry */
public class C1039 {

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C1040 f4478 = new C1040();

    /* renamed from: K  reason: contains not printable characters */
    public final C1092 f4479;

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ؿ$K  reason: contains not printable characters */
    /* compiled from: ModelLoaderRegistry */
    public static class C1040 {

        /* renamed from: K  reason: contains not printable characters */
        public final Map<Class<?>, C1041<?>> f4480 = new HashMap();

        /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ؿ$K$K  reason: contains not printable characters */
        /* compiled from: ModelLoaderRegistry */
        public static class C1041<Model> {

            /* renamed from: K  reason: contains not printable characters */
            public final List<AbstractC1033<Model, ?>> f4481;

            public C1041(List<AbstractC1033<Model, ?>> list) {
                this.f4481 = list;
            }
        }
    }

    public C1039(AbstractC1871<List<Throwable>> r2) {
        C1092 r0 = new C1092(r2);
        this.f4479 = r0;
    }

    /* JADX DEBUG: Failed to insert an additional move for type inference into block B:6:0x0011 */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX DEBUG: Type inference failed for r0v10. Raw type applied. Possible types: java.util.List<ඓ.ῲ.K.ᕣ.㳳.Ԕ<Model, ?>> */
    /* renamed from: ῲ  reason: contains not printable characters */
    public final synchronized <A> List<AbstractC1033<A, ?>> m2857(Class<A> cls) {
        List list;
        C1040.C1041<?> k = this.f4478.f4480.get(cls);
        list = k == null ? (List<AbstractC1033<A, ?>>) false : (List<AbstractC1033<Model, ?>>) k.f4481;
        if (list == null) {
            list = (List<AbstractC1033<A, ?>>) Collections.unmodifiableList(this.f4479.m2952(cls));
            if (this.f4478.f4480.put(cls, new C1040.C1041<>(list)) != null) {
                throw new IllegalStateException("Already cached loaders for model: " + cls);
            }
        }
        return (List<AbstractC1033<A, ?>>) list;
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized <Model, Data> void m2860(Class<Model> cls, Class<Data> cls2, AbstractC1091<? extends Model, ? extends Data> r4) {
        this.f4479.m2955(cls, cls2, r4);
        this.f4478.f4480.clear();
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized List<Class<?>> m2858(Class<?> cls) {
        return this.f4479.m2951(cls);
    }

    /* renamed from: K  reason: contains not printable characters */
    public <A> List<AbstractC1033<A, ?>> m2859(A a) {
        List<AbstractC1033<A, ?>> r0 = m2857(a.getClass());
        if (!r0.isEmpty()) {
            int size = r0.size();
            List<AbstractC1033<A, ?>> emptyList = Collections.emptyList();
            boolean z = true;
            for (int i = 0; i < size; i++) {
                AbstractC1033<A, ?> r6 = r0.get(i);
                if (r6.m2850(a)) {
                    if (z) {
                        emptyList = new ArrayList<>(size - i);
                        z = false;
                    }
                    emptyList.add(r6);
                }
            }
            if (!emptyList.isEmpty()) {
                return emptyList;
            }
            throw new Registry.NoModelLoaderAvailableException(a, r0);
        }
        throw new Registry.NoModelLoaderAvailableException(a);
    }
}
