package qa;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.text.DateFormat;
import java.text.Normalizer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

/* loaded from: classes.dex */
public abstract class d {

    /* renamed from: a, reason: collision with root package name */
    private static final HashMap f33519a;

    /* renamed from: b, reason: collision with root package name */
    public static final org.joda.time.format.b f33520b;

    /* renamed from: c, reason: collision with root package name */
    public static final org.joda.time.format.b f33521c;

    /* renamed from: d, reason: collision with root package name */
    public static final org.joda.time.format.b f33522d;

    /* renamed from: e, reason: collision with root package name */
    private static final org.joda.time.format.b f33523e;

    /* renamed from: f, reason: collision with root package name */
    private static final org.joda.time.format.b f33524f;

    /* renamed from: g, reason: collision with root package name */
    private static final org.joda.time.format.b f33525g;

    static {
        HashMap hashMap = new HashMap();
        f33519a = hashMap;
        hashMap.put("AU", "\\d{4}");
        hashMap.put("CA", "^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$");
        hashMap.put("CN", "\\d{6}");
        hashMap.put("FR", "\\d{2}[ ]?\\d{3}");
        hashMap.put("HK", "");
        hashMap.put("JP", "\\d{3}-\\d{4}");
        hashMap.put("KR", "\\d{3}[\\-]\\d{3}");
        hashMap.put("ES", "\\d{5}");
        hashMap.put("TH", "\\d{5}");
        hashMap.put("GB", "GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\\d[\\dA-Z]?[ ]?\\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\\d{1,4}");
        hashMap.put("US", "\\b[0-9]{5}(?:-[0-9]{4})?\\b");
        f33520b = org.joda.time.format.a.b("MMM dd, yyyy");
        f33521c = org.joda.time.format.a.b("yyyy-MM-dd");
        f33522d = org.joda.time.format.a.b("MMM dd, yyyy");
        f33523e = org.joda.time.format.a.b("yyyy-MM-dd").u(DateTimeZone.h(TimeZone.getDefault()));
        f33524f = org.joda.time.format.a.b("yyyyMMdd").u(DateTimeZone.h(TimeZone.getDefault()));
        f33525g = org.joda.time.format.a.b("HH:mm:ss").u(DateTimeZone.h(TimeZone.getDefault()));
    }

    public static Bitmap a(String str) {
        try {
            byte[] decode = Base64.decode(str, 0);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
            return BitmapFactory.decodeByteArray(decode, 0, decode.length, options);
        } catch (Exception unused) {
            return null;
        }
    }

    public static String b(String str) {
        StringBuilder sb2 = new StringBuilder(str.toLowerCase());
        boolean z10 = true;
        for (int i10 = 0; i10 < sb2.length(); i10++) {
            char charAt = sb2.charAt(i10);
            if (z10 && charAt >= 'a' && charAt <= 'z') {
                sb2.setCharAt(i10, (char) (charAt - ' '));
            } else if (charAt == ' ') {
                z10 = true;
            }
            z10 = false;
        }
        return sb2.toString();
    }

    public static String c(Date date) {
        if (date != null) {
            return f33523e.i(new DateTime(date.getTime()));
        }
        return null;
    }

    public static String d(Date date, Locale locale) {
        if (date == null) {
            return null;
        }
        DateFormat dateInstance = DateFormat.getDateInstance(2, locale);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(date.getTime());
        return dateInstance.format(calendar.getTime()).replace(String.valueOf(calendar.get(1)), "").replace(",", "").trim();
    }

    public static String e(String str) {
        return Normalizer.normalize(str, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
    }

    public static String f(String str, Locale locale) {
        return new SimpleDateFormat("h:mm a", locale).format(Long.valueOf(f33525g.e(str).getMillis())).replace("AM", "am").replace("PM", "pm").replace("a.m.", "am").replace("p.m.", "pm");
    }

    public static boolean g(String str) {
        return str == null || str.isEmpty();
    }

    public static boolean h(String str) {
        return str == null || str.length() <= 0;
    }

    public static boolean i(String str) {
        if (h(str)) {
            return false;
        }
        return Pattern.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z](?:[a-z-]*[a-z]){1,}", 2).matcher(str).matches();
    }

    public static boolean j(String str) {
        if (h(str) || str.matches(".*\\s.*")) {
            return false;
        }
        return Pattern.compile("^(?=.*?[0-9])(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[^a-zA-Z0-9]).{8,32}$").matcher(str).matches();
    }

    public static boolean k(String str) {
        if (h(str)) {
            return false;
        }
        return Pattern.compile("^(\\d{3})[-]?(\\d{3})[-]?(\\d{4})$").matcher(str).matches();
    }

    public static boolean l(String str) {
        if (h(str)) {
            return false;
        }
        return Pattern.compile("^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$", 2).matcher(str.trim()).matches();
    }

    public static boolean m(String str) {
        if (h(str)) {
            return false;
        }
        return Pattern.compile("\\b[0-9]{5}(?:-[0-9]{4})?\\b", 2).matcher(str.trim()).matches();
    }

    public static boolean n(String str) {
        return (h(str) || str.matches(".*\\s.*")) ? false : true;
    }

    public static List o(String str, Class cls) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return (List) objectMapper.readValue(str, objectMapper.getTypeFactory().constructCollectionType(List.class, (Class<?>) cls));
        } catch (Exception unused) {
            return null;
        }
    }

    public static Object p(String str, Class cls) {
        try {
            return new ObjectMapper().readValue(str, cls);
        } catch (Exception unused) {
            return null;
        }
    }

    public static String q(Map map) {
        StringBuffer stringBuffer = new StringBuffer();
        if (map != null) {
            boolean z10 = false;
            for (Map.Entry entry : map.entrySet()) {
                if (z10) {
                    stringBuffer.append("\n");
                }
                stringBuffer.append(entry);
                z10 = true;
            }
        }
        return stringBuffer.toString();
    }

    public static boolean r(String str, String str2) {
        if (h(str)) {
            return false;
        }
        return Pattern.compile(str2, 2).matcher(str).matches();
    }

    public static String s(Object obj) {
        try {
            return new ObjectMapper().writeValueAsString(obj);
        } catch (JsonProcessingException unused) {
            return null;
        }
    }

    public static DateTime t(String str) {
        try {
            DateTime e10 = f33523e.e(str);
            if (e10 != null) {
                return e10;
            }
        } catch (Exception unused) {
        }
        try {
            DateTime e11 = f33524f.e(str);
            if (e11 != null) {
                return e11;
            }
            return null;
        } catch (Exception unused2) {
            return null;
        }
    }

    public static String u(String str) {
        return str.replaceAll("\\s+", " ");
    }
}
