package o;

import android.content.ClipDescription;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.MissingFormatArgumentException;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Jn, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0247Jn implements InterfaceC2439sb0, E2, InterfaceC3051yx, InterfaceC1481iT, InterfaceC1491ib0, XC, LN {
    public final /* synthetic */ int l;
    public Object m;

    public /* synthetic */ C0247Jn(int i, Object obj) {
        this.l = i;
        this.m = obj;
    }

    public static boolean s(Bundle bundle) {
        return "1".equals(bundle.getString("gcm.n.e")) || "1".equals(bundle.getString("gcm.n.e".replace("gcm.n.", "gcm.notification.")));
    }

    public static C2534tb0 u(B00 b00, C2891xG c2891xG, C2899xO c2899xO, C2994yO c2994yO) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(c2891xG.a.getResources(), c2994yO.a);
        Map map = c2994yO.b;
        Object obj = map.get("coil#disk_cache_key");
        String str = obj instanceof String ? (String) obj : null;
        Object obj2 = map.get("coil#is_sampled");
        Boolean bool = obj2 instanceof Boolean ? (Boolean) obj2 : null;
        boolean z = false;
        boolean zBooleanValue = bool != null ? bool.booleanValue() : false;
        Bitmap.Config[] configArr = AbstractC1345h.a;
        if (b00 != null && b00.g) {
            z = true;
        }
        return new C2534tb0(bitmapDrawable, c2891xG, 1, c2899xO, str, zBooleanValue, z);
    }

    public static void y(String str) {
        if (str.startsWith("gcm.n.")) {
            str.substring(6);
        }
    }

    public void a(C2420sK c2420sK) {
        if (!c2420sK.G()) {
            AbstractC2133pH.b("DepthSortedSet.add called on an unattached node");
        }
        ((S90) this.m).add(c2420sK);
    }

    @Override // o.XC
    public Object apply() {
        return (E1) this.m;
    }

    @Override // o.InterfaceC1491ib0
    public void b(C2899xO c2899xO, Bitmap bitmap, Map map) {
        ((C1254g2) this.m).i(c2899xO, bitmap, map, AbstractC1904ms0.i(bitmap));
    }

    public String c(Object obj) throws IOException {
        StringWriter stringWriter = new StringWriter();
        try {
            C2040oJ c2040oJ = (C2040oJ) this.m;
            C2514tJ c2514tJ = new C2514tJ(stringWriter, c2040oJ.a, c2040oJ.b, c2040oJ.c, c2040oJ.d);
            c2514tJ.h(obj);
            c2514tJ.j();
            c2514tJ.b.flush();
        } catch (IOException unused) {
        }
        return stringWriter.toString();
    }

    public boolean d(String str) {
        String strQ = q(str);
        return "1".equals(strQ) || Boolean.parseBoolean(strQ);
    }

    @Override // o.InterfaceC1491ib0
    public C2994yO e(C2899xO c2899xO) {
        return null;
    }

    /* JADX WARN: Code restructure failed: missing block: B:54:0x00b3, code lost:
    
        if (r7 != false) goto L44;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:104:0x0158 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:44:0x0090  */
    /* JADX WARN: Type inference failed for: r9v11 */
    /* JADX WARN: Type inference failed for: r9v12 */
    /* JADX WARN: Type inference failed for: r9v13 */
    /* JADX WARN: Type inference failed for: r9v16 */
    /* JADX WARN: Type inference failed for: r9v17 */
    /* JADX WARN: Type inference failed for: r9v21 */
    /* JADX WARN: Type inference failed for: r9v22 */
    /* JADX WARN: Type inference failed for: r9v8 */
    /* JADX WARN: Type inference failed for: r9v9 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public o.C2994yO g(o.C2891xG r18, o.C2899xO r19, o.S80 r20, int r21) {
        /*
            Method dump skipped, instructions count: 346
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0247Jn.g(o.xG, o.xO, o.S80, int):o.yO");
    }

    @Override // o.CZ
    public Object get() {
        return new C3126zm0((Context) ((G0) this.m).m, new C2616uQ(25), new C2616uQ(23), 12);
    }

    @Override // o.E2
    public void h(Bundle bundle) {
        ((B2) ((A2) this.m)).a("clx", "_ae", bundle);
    }

    public AbstractC2912xa0 i() {
        return (AbstractC2912xa0) ((Ba0) this.m).getValue();
    }

    public InterfaceC3007ya0 j() {
        C2004nv c2004nvA = C2004nv.a();
        if (c2004nvA.c() == 1) {
            return new IG(true);
        }
        MV mvX = AbstractC0752ap.X(Boolean.FALSE);
        c2004nvA.h(new C1040dq(mvX, this));
        return mvX;
    }

    public Integer k(String str) {
        String strQ = q(str);
        if (TextUtils.isEmpty(strQ)) {
            return null;
        }
        try {
            return Integer.valueOf(Integer.parseInt(strQ));
        } catch (NumberFormatException unused) {
            y(str);
            return null;
        }
    }

    public JSONArray l(String str) {
        String strQ = q(str);
        if (TextUtils.isEmpty(strQ)) {
            return null;
        }
        try {
            return new JSONArray(strQ);
        } catch (JSONException unused) {
            y(str);
            return null;
        }
    }

    public int[] m() throws JSONException {
        JSONArray jSONArrayL = l("gcm.n.light_settings");
        if (jSONArrayL == null) {
            return null;
        }
        int[] iArr = new int[3];
        try {
            if (jSONArrayL.length() != 3) {
                throw new JSONException("lightSettings don't have all three fields");
            }
            int color = Color.parseColor(jSONArrayL.optString(0));
            if (color == -16777216) {
                throw new IllegalArgumentException("Transparent color is invalid");
            }
            iArr[0] = color;
            iArr[1] = jSONArrayL.optInt(1);
            iArr[2] = jSONArrayL.optInt(2);
            return iArr;
        } catch (IllegalArgumentException e) {
            jSONArrayL.toString();
            e.getMessage();
            return null;
        } catch (JSONException unused) {
            jSONArrayL.toString();
            return null;
        }
    }

    public Object[] n(String str) {
        JSONArray jSONArrayL = l(str.concat("_loc_args"));
        if (jSONArrayL == null) {
            return null;
        }
        int length = jSONArrayL.length();
        String[] strArr = new String[length];
        for (int i = 0; i < length; i++) {
            strArr[i] = jSONArrayL.optString(i);
        }
        return strArr;
    }

    public String o(String str) {
        return q(str.concat("_loc_key"));
    }

    public String p(Resources resources, String str, String str2) {
        String strQ = q(str2);
        if (!TextUtils.isEmpty(strQ)) {
            return strQ;
        }
        String strO = o(str2);
        if (TextUtils.isEmpty(strO)) {
            return null;
        }
        int identifier = resources.getIdentifier(strO, "string", str);
        if (identifier == 0) {
            y(str2.concat("_loc_key"));
            return null;
        }
        Object[] objArrN = n(str2);
        if (objArrN == null) {
            return resources.getString(identifier);
        }
        try {
            return resources.getString(identifier, objArrN);
        } catch (MissingFormatArgumentException unused) {
            y(str2);
            Arrays.toString(objArrN);
            return null;
        }
    }

    public String q(String str) {
        Bundle bundle = (Bundle) this.m;
        if (!bundle.containsKey(str) && str.startsWith("gcm.n.")) {
            String strReplace = !str.startsWith("gcm.n.") ? str : str.replace("gcm.n.", "gcm.notification.");
            if (bundle.containsKey(strReplace)) {
                str = strReplace;
            }
        }
        return bundle.getString(str);
    }

    public long[] r() throws JSONException {
        JSONArray jSONArrayL = l("gcm.n.vibrate_timings");
        if (jSONArrayL == null) {
            return null;
        }
        try {
            if (jSONArrayL.length() <= 1) {
                throw new JSONException("vibrateTimings have invalid length");
            }
            int length = jSONArrayL.length();
            long[] jArr = new long[length];
            for (int i = 0; i < length; i++) {
                jArr[i] = jSONArrayL.optLong(i);
            }
            return jArr;
        } catch (NumberFormatException | JSONException unused) {
            jSONArrayL.toString();
            return null;
        }
    }

    public C2899xO t(C2891xG c2891xG, Object obj, NU nu, C0282Kw c0282Kw) {
        String string;
        Map linkedHashMap;
        c2891xG.getClass();
        List list = c2891xG.e;
        List list2 = ((C2961y00) this.m).d.c;
        int size = list2.size();
        int i = 0;
        while (true) {
            if (i < size) {
                C3001yV c3001yV = (C3001yV) list2.get(i);
                C0620Xx c0620Xx = (C0620Xx) c3001yV.l;
                if (((Class) c3001yV.m).isAssignableFrom(obj.getClass())) {
                    switch (c0620Xx.a) {
                        case 0:
                            File file = (File) obj;
                            string = file.getPath() + ':' + file.lastModified();
                            break;
                        default:
                            Uri uri = (Uri) obj;
                            if (!F3.c(uri.getScheme(), "android.resource")) {
                                string = uri.toString();
                                break;
                            } else {
                                StringBuilder sb = new StringBuilder();
                                sb.append(uri);
                                sb.append('-');
                                Configuration configuration = nu.a.getResources().getConfiguration();
                                Bitmap.Config[] configArr = AbstractC1345h.a;
                                sb.append(configuration.uiMode & 48);
                                string = sb.toString();
                                break;
                            }
                    }
                    if (string != null) {
                    }
                }
                i++;
            } else {
                string = null;
            }
        }
        if (string == null) {
            return null;
        }
        Map map = c2891xG.s.l;
        boolean zIsEmpty = map.isEmpty();
        C0358Nv c0358Nv = C0358Nv.l;
        if (zIsEmpty) {
            linkedHashMap = c0358Nv;
        } else {
            linkedHashMap = new LinkedHashMap();
            Iterator it = map.entrySet().iterator();
            if (it.hasNext()) {
                ((Map.Entry) it.next()).getValue().getClass();
                throw new ClassCastException();
            }
        }
        if (list.isEmpty() && linkedHashMap.isEmpty()) {
            return new C2899xO(string, c0358Nv);
        }
        LinkedHashMap linkedHashMap2 = new LinkedHashMap(linkedHashMap);
        if (!list.isEmpty()) {
            if (list.size() > 0) {
                list.get(0).getClass();
                throw new ClassCastException();
            }
            linkedHashMap2.put("coil#transformation_size", nu.c.toString());
        }
        return new C2899xO(string, linkedHashMap2);
    }

    @Override // o.InterfaceC2439sb0
    public Pc0 then(Object obj) {
        switch (this.l) {
            case 0:
                C2975y70 c2975y70 = (C2975y70) obj;
                C0324Mn c0324Mn = ((CallableC0273Kn) this.m).e;
                return c2975y70 == null ? AbstractC0752ap.K(null) : AbstractC0752ap.j0(Arrays.asList(C0324Mn.a(c0324Mn), c0324Mn.m.u((ExecutorC0014Ao) c0324Mn.e.m, null)));
            default:
                C2975y70 c2975y702 = (C2975y70) obj;
                C3040yr c3040yr = (C3040yr) this.m;
                if (c2975y702 == null) {
                    return AbstractC0752ap.K(null);
                }
                C0324Mn c0324Mn2 = (C0324Mn) c3040yr.n;
                C0324Mn.a(c0324Mn2);
                c0324Mn2.m.u((ExecutorC0014Ao) c0324Mn2.e.m, null);
                c0324Mn2.q.d(null);
                return AbstractC0752ap.K(null);
        }
    }

    public String toString() {
        switch (this.l) {
            case ConnectionResult.SERVICE_INVALID /* 9 */:
                return ((S90) this.m).toString();
            default:
                return super.toString();
        }
    }

    public Bundle v() {
        Bundle bundle = (Bundle) this.m;
        Bundle bundle2 = new Bundle(bundle);
        for (String str : bundle.keySet()) {
            if (!str.startsWith("google.c.a.") && !str.equals("from")) {
                bundle2.remove(str);
            }
        }
        return bundle2;
    }

    public boolean w(C2420sK c2420sK) {
        if (!c2420sK.G()) {
            AbstractC2133pH.b("DepthSortedSet.remove called on an unattached node");
        }
        return ((S90) this.m).remove(c2420sK);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:13:0x0024  */
    /* JADX WARN: Type inference failed for: r3v4, types: [o.xq] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void x(o.AbstractC2912xa0 r6) {
        /*
            r5 = this;
            java.lang.Object r0 = r5.m
            o.Ba0 r0 = (o.Ba0) r0
        L4:
            java.lang.Object r1 = r0.getValue()
            r2 = r1
            o.xa0 r2 = (o.AbstractC2912xa0) r2
            boolean r3 = r2 instanceof o.C1251g00
            if (r3 == 0) goto L11
            r3 = 1
            goto L17
        L11:
            o.Gh0 r3 = o.Gh0.b
            boolean r3 = o.F3.c(r2, r3)
        L17:
            if (r3 == 0) goto L1a
            goto L24
        L1a:
            boolean r3 = r2 instanceof o.C0611Xo
            if (r3 == 0) goto L26
            int r3 = r6.a
            int r4 = r2.a
            if (r3 <= r4) goto L2a
        L24:
            r2 = r6
            goto L2a
        L26:
            boolean r3 = r2 instanceof o.C2577ty
            if (r3 == 0) goto L39
        L2a:
            o.xq r3 = o.F3.f
            if (r1 != 0) goto L2f
            r1 = r3
        L2f:
            if (r2 != 0) goto L32
            r2 = r3
        L32:
            boolean r1 = r0.i(r1, r2)
            if (r1 == 0) goto L4
            return
        L39:
            o.pj r6 = new o.pj
            r6.<init>()
            throw r6
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0247Jn.x(o.xa0):void");
    }

    public /* synthetic */ C0247Jn(int i, Object obj, Object obj2) {
        this.l = i;
        this.m = obj;
    }

    public C0247Jn(int i) {
        this.l = i;
        switch (i) {
            case 6:
                break;
            case 7:
                this.m = AbstractC0940cn0.o(Looper.getMainLooper());
                break;
            case ConnectionResult.SERVICE_INVALID /* 9 */:
                this.m = new S90(As0.b);
                break;
            case 10:
                this.m = new ConcurrentHashMap(16);
                break;
            case ConnectionResult.SERVICE_UPDATING /* 18 */:
                this.m = null;
                break;
            default:
                this.m = AbstractC0752ap.h(Gh0.b);
                break;
        }
    }

    public C0247Jn(Bundle bundle) {
        this.l = 29;
        if (bundle != null) {
            this.m = new Bundle(bundle);
            return;
        }
        throw new NullPointerException("data");
    }

    public C0247Jn(TextView textView) {
        this.l = 14;
        this.m = new C0099Dv(textView);
    }

    public C0247Jn(EditText editText) {
        this.l = 13;
        this.m = new C3031ym0(editText);
    }

    public C0247Jn(Uri uri, ClipDescription clipDescription, Uri uri2) {
        this.l = 19;
        if (Build.VERSION.SDK_INT >= 25) {
            this.m = new C3082zH(uri, clipDescription, uri2);
        } else {
            this.m = new C3126zm0(uri, clipDescription, uri2, 19);
        }
    }

    @Override // o.InterfaceC1491ib0
    public void f(int i) {
    }
}
