package com.bumptech.glide;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import com.bumptech.glide.c;
import com.bumptech.glide.load.data.ParcelFileDescriptorRewinder;
import com.bumptech.glide.load.data.k;
import ei.f;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import ph.a;
import ph.b;
import ph.d;
import ph.e;
import ph.g;
import ph.l;
import ph.o;
import ph.s;
import ph.u;
import ph.v;
import ph.w;
import ph.x;
import ph.y;
import qh.a;
import qh.b;
import qh.c;
import qh.d;
import qh.e;
import sh.a0;
import sh.b0;
import sh.p;
import sh.t;
import sh.v;
import sh.x;
import sh.y;
import th.a;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes4.dex */
public abstract class j {

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public class a implements f.b {

        /* renamed from: a, reason: collision with root package name */
        private boolean f12540a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ b f12541b;

        /* renamed from: c, reason: collision with root package name */
        final /* synthetic */ List f12542c;

        /* renamed from: d, reason: collision with root package name */
        final /* synthetic */ zh.a f12543d;

        a(b bVar, List list, zh.a aVar) {
            this.f12541b = bVar;
            this.f12542c = list;
            this.f12543d = aVar;
        }

        @Override // ei.f.b
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public i get() {
            if (this.f12540a) {
                throw new IllegalStateException("Recursive Registry initialization! In your AppGlideModule and LibraryGlideModules, Make sure you're using the provided Registry rather calling glide.getRegistry()!");
            }
            t5.a.a("Glide registry");
            this.f12540a = true;
            try {
                return j.a(this.f12541b, this.f12542c, this.f12543d);
            } finally {
                this.f12540a = false;
                t5.a.b();
            }
        }
    }

    static i a(b bVar, List list, zh.a aVar) {
        mh.d f10 = bVar.f();
        mh.b e10 = bVar.e();
        Context applicationContext = bVar.i().getApplicationContext();
        e g10 = bVar.i().g();
        i iVar = new i();
        b(applicationContext, iVar, f10, e10, g10);
        c(applicationContext, bVar, iVar, list, aVar);
        return iVar;
    }

    private static void b(Context context, i iVar, mh.d dVar, mh.b bVar, e eVar) {
        jh.j gVar;
        jh.j yVar;
        i iVar2;
        Class cls;
        iVar.o(new sh.k());
        iVar.o(new p());
        Resources resources = context.getResources();
        List g10 = iVar.g();
        wh.a aVar = new wh.a(context, g10, dVar, bVar);
        jh.j m10 = b0.m(dVar);
        sh.m mVar = new sh.m(iVar.g(), resources.getDisplayMetrics(), dVar, bVar);
        if (eVar.a(c.b.class)) {
            yVar = new t();
            gVar = new sh.h();
        } else {
            gVar = new sh.g(mVar);
            yVar = new y(mVar, bVar);
        }
        iVar.e("Animation", InputStream.class, Drawable.class, uh.a.f(g10, bVar));
        iVar.e("Animation", ByteBuffer.class, Drawable.class, uh.a.a(g10, bVar));
        uh.e eVar2 = new uh.e(context);
        sh.c cVar = new sh.c(bVar);
        xh.a aVar2 = new xh.a();
        xh.d dVar2 = new xh.d();
        ContentResolver contentResolver = context.getContentResolver();
        iVar.c(ByteBuffer.class, new ph.c()).c(InputStream.class, new u(bVar)).e("Bitmap", ByteBuffer.class, Bitmap.class, gVar).e("Bitmap", InputStream.class, Bitmap.class, yVar);
        if (ParcelFileDescriptorRewinder.c()) {
            iVar.e("Bitmap", ParcelFileDescriptor.class, Bitmap.class, new v(mVar));
        }
        iVar.e("Bitmap", ParcelFileDescriptor.class, Bitmap.class, m10).e("Bitmap", AssetFileDescriptor.class, Bitmap.class, b0.c(dVar)).b(Bitmap.class, Bitmap.class, w.a.a()).e("Bitmap", Bitmap.class, Bitmap.class, new a0()).d(Bitmap.class, cVar).e("BitmapDrawable", ByteBuffer.class, BitmapDrawable.class, new sh.a(resources, gVar)).e("BitmapDrawable", InputStream.class, BitmapDrawable.class, new sh.a(resources, yVar)).e("BitmapDrawable", ParcelFileDescriptor.class, BitmapDrawable.class, new sh.a(resources, m10)).d(BitmapDrawable.class, new sh.b(dVar, cVar)).e("Animation", InputStream.class, wh.c.class, new wh.j(g10, aVar, bVar)).e("Animation", ByteBuffer.class, wh.c.class, aVar).d(wh.c.class, new wh.d()).b(hh.a.class, hh.a.class, w.a.a()).e("Bitmap", hh.a.class, Bitmap.class, new wh.h(dVar)).a(Uri.class, Drawable.class, eVar2).a(Uri.class, Bitmap.class, new x(eVar2, dVar)).p(new a.C0858a()).b(File.class, ByteBuffer.class, new d.b()).b(File.class, InputStream.class, new g.e()).a(File.class, File.class, new vh.a()).b(File.class, ParcelFileDescriptor.class, new g.b()).b(File.class, File.class, w.a.a()).p(new k.a(bVar));
        if (ParcelFileDescriptorRewinder.c()) {
            iVar2 = iVar;
            cls = AssetFileDescriptor.class;
            iVar2.p(new ParcelFileDescriptorRewinder.a());
        } else {
            iVar2 = iVar;
            cls = AssetFileDescriptor.class;
        }
        o g11 = ph.f.g(context);
        o c10 = ph.f.c(context);
        o e10 = ph.f.e(context);
        Class cls2 = Integer.TYPE;
        iVar2.b(cls2, InputStream.class, g11).b(Integer.class, InputStream.class, g11).b(cls2, cls, c10).b(Integer.class, cls, c10).b(cls2, Drawable.class, e10).b(Integer.class, Drawable.class, e10).b(Uri.class, InputStream.class, ph.t.f(context)).b(Uri.class, cls, ph.t.e(context));
        s.c cVar2 = new s.c(resources);
        s.a aVar3 = new s.a(resources);
        s.b bVar2 = new s.b(resources);
        iVar2.b(Integer.class, Uri.class, cVar2).b(cls2, Uri.class, cVar2).b(Integer.class, cls, aVar3).b(cls2, cls, aVar3).b(Integer.class, InputStream.class, bVar2).b(cls2, InputStream.class, bVar2);
        iVar2.b(String.class, InputStream.class, new e.c()).b(Uri.class, InputStream.class, new e.c()).b(String.class, InputStream.class, new v.c()).b(String.class, ParcelFileDescriptor.class, new v.b()).b(String.class, cls, new v.a()).b(Uri.class, InputStream.class, new a.c(context.getAssets())).b(Uri.class, cls, new a.b(context.getAssets())).b(Uri.class, InputStream.class, new b.a(context)).b(Uri.class, InputStream.class, new c.a(context));
        iVar2.b(Uri.class, InputStream.class, new d.c(context));
        iVar2.b(Uri.class, ParcelFileDescriptor.class, new d.b(context));
        iVar2.b(Uri.class, InputStream.class, new x.d(contentResolver)).b(Uri.class, ParcelFileDescriptor.class, new x.b(contentResolver)).b(Uri.class, cls, new x.a(contentResolver)).b(Uri.class, InputStream.class, new y.a()).b(URL.class, InputStream.class, new e.a()).b(Uri.class, File.class, new l.a(context)).b(ph.h.class, InputStream.class, new a.C0788a()).b(byte[].class, ByteBuffer.class, new b.a()).b(byte[].class, InputStream.class, new b.d()).b(Uri.class, Uri.class, w.a.a()).b(Drawable.class, Drawable.class, w.a.a()).a(Drawable.class, Drawable.class, new uh.f()).q(Bitmap.class, BitmapDrawable.class, new xh.b(resources)).q(Bitmap.class, byte[].class, aVar2).q(Drawable.class, byte[].class, new xh.c(dVar, aVar2, dVar2)).q(wh.c.class, byte[].class, dVar2);
        jh.j d10 = b0.d(dVar);
        iVar2.a(ByteBuffer.class, Bitmap.class, d10);
        iVar2.a(ByteBuffer.class, BitmapDrawable.class, new sh.a(resources, d10));
    }

    private static void c(Context context, b bVar, i iVar, List list, zh.a aVar) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
            zh.b bVar2 = (zh.b) it.next();
            try {
                bVar2.b(context, bVar, iVar);
            } catch (AbstractMethodError e10) {
                throw new IllegalStateException("Attempting to register a Glide v3 module. If you see this, you or one of your dependencies may be including Glide v3 even though you're using Glide v4. You'll need to find and remove (or update) the offending dependency. The v3 module name is: " + bVar2.getClass().getName(), e10);
            }
        }
        if (aVar != null) {
            aVar.a(context, bVar, iVar);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static f.b d(b bVar, List list, zh.a aVar) {
        return new a(bVar, list, aVar);
    }
}
