package ඓ.ῲ.K.ᕣ.㳳;

import android.util.Base64;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import ඓ.ῲ.K.ؿ.C0821;
import ඓ.ῲ.K.ᕣ.C1121;
import ඓ.ῲ.K.ᕣ.㳳.AbstractC1033;
import ඓ.ῲ.K.ᕣ.㿎.AbstractC1146;

/* renamed from: ඓ.ῲ.K.ᕣ.㳳.ඓ  reason: contains not printable characters */
/* compiled from: DataUrlLoader */
public final class C1047<Model, Data> implements AbstractC1033<Model, Data> {

    /* renamed from: K  reason: contains not printable characters */
    public final AbstractC1051<Data> f4488;

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ඓ$ʬ  reason: contains not printable characters */
    /* compiled from: DataUrlLoader */
    public static final class C1048<Model> implements AbstractC1091<Model, InputStream> {

        /* renamed from: K  reason: contains not printable characters */
        public final AbstractC1051<InputStream> f4489 = new C1049(this);

        @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1091
        /* renamed from: K  reason: contains not printable characters */
        public AbstractC1033<Model, InputStream> m2869(C1092 r2) {
            return new C1047(this.f4489);
        }

        /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ඓ$ʬ$K  reason: contains not printable characters */
        /* compiled from: DataUrlLoader */
        public class C1049 implements AbstractC1051<InputStream> {
            public C1049(C1048 r1) {
            }

            /* renamed from: K  reason: contains not printable characters */
            public void m2872(Object obj) throws IOException {
                ((InputStream) obj).close();
            }

            /* renamed from: K  reason: contains not printable characters */
            public Object m2871(String str) throws IllegalArgumentException {
                if (str.startsWith("data:image")) {
                    int indexOf = str.indexOf(44);
                    if (indexOf == -1) {
                        throw new IllegalArgumentException("Missing comma in data URL.");
                    } else if (str.substring(0, indexOf).endsWith(";base64")) {
                        return new ByteArrayInputStream(Base64.decode(str.substring(indexOf + 1), 0));
                    } else {
                        throw new IllegalArgumentException("Not a base64 image data URL.");
                    }
                } else {
                    throw new IllegalArgumentException("Not a valid image data URL.");
                }
            }

            /* renamed from: K  reason: contains not printable characters */
            public Class<InputStream> m2870() {
                return InputStream.class;
            }
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ඓ$K  reason: contains not printable characters */
    /* compiled from: DataUrlLoader */
    public interface AbstractC1051<Data> {
    }

    public C1047(AbstractC1051<Data> k) {
        this.f4488 = k;
    }

    @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1033
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC1033.C1034<Data> m2867(Model model, int i, int i2, C1121 r5) {
        return new AbstractC1033.C1034<>(new C0821(model), new C1050(model.toString(), this.f4488));
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.㳳.ඓ$ῲ  reason: contains not printable characters */
    /* compiled from: DataUrlLoader */
    public static final class C1050<Data> implements AbstractC1146<Data> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final AbstractC1051<Data> f4490;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final String f4491;

        /* renamed from: 㸾  reason: contains not printable characters */
        public Data f4492;

        public C1050(String str, AbstractC1051<Data> k) {
            this.f4491 = str;
            this.f4490 = k;
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        public void cancel() {
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: ʬ  reason: contains not printable characters */
        public DataSource m2873() {
            return DataSource.LOCAL;
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: ῲ  reason: contains not printable characters */
        public void m2874() {
            try {
                ((C1048.C1049) this.f4490).m2872((Object) this.f4492);
            } catch (IOException unused) {
            }
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: K  reason: contains not printable characters */
        public void m2876(Priority priority, AbstractC1146.AbstractC1147<? super Data> k) {
            try {
                this.f4492 = (Data) ((C1048.C1049) this.f4490).m2871(this.f4491);
                k.m3069((Object) this.f4492);
            } catch (IllegalArgumentException e) {
                k.m3068((Exception) e);
            }
        }

        @Override // ඓ.ῲ.K.ᕣ.㿎.AbstractC1146
        /* renamed from: K  reason: contains not printable characters */
        public Class<Data> m2875() {
            return (Class<Data>) ((C1048.C1049) this.f4490).m2870();
        }
    }

    @Override // ඓ.ῲ.K.ᕣ.㳳.AbstractC1033
    /* renamed from: K  reason: contains not printable characters */
    public boolean m2868(Model model) {
        return model.toString().startsWith("data:image");
    }
}
