package b5;

import L.b;
import S4.d;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import com.google.android.gms.internal.measurement.J1;
import com.google.crypto.tink.shaded.protobuf.AbstractC0479h;
import e0.C0555b;
import e0.c;
import e4.AbstractC0561e;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.plugin.editing.FlutterTextUtils;
import io.sentry.EnumC0738m1;
import io.sentry.ILogger;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public abstract class a {
    public static boolean G(byte[] bArr, byte[] bArr2) {
        if (bArr2 != null && bArr.length >= bArr2.length) {
            for (int i = 0; i < bArr2.length; i++) {
                if (bArr[i] == bArr2[i]) {
                }
            }
            return true;
        }
        return false;
    }

    public static boolean I(String str, File file) throws Throwable {
        FileInputStream fileInputStream;
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("checksum or file cannot be empty");
        }
        FileInputStream fileInputStream2 = null;
        try {
            try {
                fileInputStream = new FileInputStream(file);
            } catch (Throwable th) {
                th = th;
            }
        } catch (FileNotFoundException e2) {
            e = e2;
        } catch (IOException e6) {
            e = e6;
        }
        try {
            boolean zEqualsIgnoreCase = new String(Z4.a.a(J1.s(fileInputStream))).equalsIgnoreCase(str);
            try {
                fileInputStream.close();
                return zEqualsIgnoreCase;
            } catch (IOException e7) {
                throw new IllegalStateException("Cannot close IO stream", e7);
            }
        } catch (FileNotFoundException e8) {
            e = e8;
            throw new IllegalStateException("File not found", e);
        } catch (IOException e9) {
            e = e9;
            throw new IllegalStateException("Unknown IO error", e);
        } catch (Throwable th2) {
            th = th2;
            fileInputStream2 = fileInputStream;
            if (fileInputStream2 != null) {
                try {
                    fileInputStream2.close();
                } catch (IOException e10) {
                    throw new IllegalStateException("Cannot close IO stream", e10);
                }
            }
            throw th;
        }
    }

    public static final boolean a(Object[] objArr, int i, int i5, List list) {
        if (i5 == list.size()) {
            for (int i6 = 0; i6 < i5; i6++) {
                if (AbstractC0983h.a(objArr[i + i6], list.get(i6))) {
                }
            }
            return true;
        }
        return false;
    }

    public static final String b(Object[] objArr, int i, int i5, AbstractC0561e abstractC0561e) {
        StringBuilder sb = new StringBuilder((i5 * 3) + 2);
        sb.append("[");
        for (int i6 = 0; i6 < i5; i6++) {
            if (i6 > 0) {
                sb.append(", ");
            }
            Object obj = objArr[i + i6];
            if (obj == abstractC0561e) {
                sb.append("(this Collection)");
            } else {
                sb.append(obj);
            }
        }
        sb.append("]");
        String string = sb.toString();
        AbstractC0983h.d("toString(...)", string);
        return string;
    }

    public static Object c(Class cls, InvocationHandler invocationHandler) {
        if (invocationHandler == null) {
            return null;
        }
        return cls.cast(Proxy.newProxyInstance(a.class.getClassLoader(), new Class[]{cls}, invocationHandler));
    }

    public static void f(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (RuntimeException e2) {
                throw e2;
            } catch (Exception unused) {
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static long[] g(Serializable serializable) {
        if (!(serializable instanceof int[])) {
            if (serializable instanceof long[]) {
                return (long[]) serializable;
            }
            return null;
        }
        int[] iArr = (int[]) serializable;
        long[] jArr = new long[iArr.length];
        for (int i = 0; i < iArr.length; i++) {
            jArr[i] = iArr[i];
        }
        return jArr;
    }

    public static void h(C0555b c0555b, c cVar, int i) throws IOException {
        byte[] bArr = new byte[8192];
        while (i > 0) {
            int iMin = Math.min(i, 8192);
            int i5 = c0555b.read(bArr, 0, iMin);
            if (i5 != iMin) {
                throw new IOException("Failed to copy the given amount of bytes from the inputstream to the output stream.");
            }
            i -= i5;
            cVar.write(bArr, 0, i5);
        }
    }

    public static void i(InputStream inputStream, OutputStream outputStream) throws IOException {
        byte[] bArr = new byte[8192];
        while (true) {
            int i = inputStream.read(bArr);
            if (i == -1) {
                return;
            } else {
                outputStream.write(bArr, 0, i);
            }
        }
    }

    public static byte[] j(String str) {
        if (str.length() % 2 != 0) {
            throw new IllegalArgumentException("Expected a string of even length");
        }
        int length = str.length() / 2;
        byte[] bArr = new byte[length];
        for (int i = 0; i < length; i++) {
            int i5 = i * 2;
            int iDigit = Character.digit(str.charAt(i5), 16);
            int iDigit2 = Character.digit(str.charAt(i5 + 1), 16);
            if (iDigit == -1 || iDigit2 == -1) {
                throw new IllegalArgumentException("input is not hexadecimal");
            }
            bArr[i] = (byte) ((iDigit * 16) + iDigit2);
        }
        return bArr;
    }

    public static String k(byte[] bArr) {
        StringBuilder sb = new StringBuilder(bArr.length * 2);
        for (byte b2 : bArr) {
            int i = b2 & 255;
            sb.append("0123456789abcdef".charAt(i / 16));
            sb.append("0123456789abcdef".charAt(i % 16));
        }
        return sb.toString();
    }

    public static String l(AbstractC0479h abstractC0479h) {
        StringBuilder sb = new StringBuilder(abstractC0479h.size());
        for (int i = 0; i < abstractC0479h.size(); i++) {
            byte bA = abstractC0479h.a(i);
            if (bA == 34) {
                sb.append("\\\"");
            } else if (bA == 39) {
                sb.append("\\'");
            } else if (bA != 92) {
                switch (bA) {
                    case 7:
                        sb.append("\\a");
                        break;
                    case 8:
                        sb.append("\\b");
                        break;
                    case AndroidTouchProcessor.PointerChange.PAN_ZOOM_END /* 9 */:
                        sb.append("\\t");
                        break;
                    case FlutterTextUtils.LINE_FEED /* 10 */:
                        sb.append("\\n");
                        break;
                    case 11:
                        sb.append("\\v");
                        break;
                    case 12:
                        sb.append("\\f");
                        break;
                    case FlutterTextUtils.CARRIAGE_RETURN /* 13 */:
                        sb.append("\\r");
                        break;
                    default:
                        if (bA < 32 || bA > 126) {
                            sb.append('\\');
                            sb.append((char) (((bA >>> 6) & 3) + 48));
                            sb.append((char) (((bA >>> 3) & 7) + 48));
                            sb.append((char) ((bA & 7) + 48));
                        } else {
                            sb.append((char) bA);
                        }
                        break;
                }
            } else {
                sb.append("\\\\");
            }
        }
        return sb.toString();
    }

    public static int m(int i, int i5) {
        if (i5 < 0) {
            throw new AssertionError("cannot store more than MAX_VALUE elements");
        }
        int iHighestOneBit = i + (i >> 1) + 1;
        if (iHighestOneBit < i5) {
            iHighestOneBit = Integer.highestOneBit(i5 - 1) << 1;
        }
        if (iHighestOneBit < 0) {
            return Integer.MAX_VALUE;
        }
        return iHighestOneBit;
    }

    public static String p(KeyEvent.Callback callback) {
        if (callback == null) {
            return null;
        }
        String canonicalName = callback.getClass().getCanonicalName();
        return canonicalName != null ? canonicalName : callback.getClass().getSimpleName();
    }

    public static int q(int i, View view) {
        Context context = view.getContext();
        TypedValue typedValueD = d.D(i, view.getContext(), view.getClass().getCanonicalName());
        int i5 = typedValueD.resourceId;
        return i5 != 0 ? context.getColor(i5) : typedValueD.data;
    }

    public static int r(Context context, int i, int i5) {
        TypedValue typedValueC = d.C(context, i);
        if (typedValueC == null) {
            return i5;
        }
        int i6 = typedValueC.resourceId;
        return i6 != 0 ? context.getColor(i6) : typedValueC.data;
    }

    public static Object s(Bundle bundle, String str, Class cls) {
        if (Build.VERSION.SDK_INT >= 34) {
            return b.a(bundle, str, cls);
        }
        Parcelable parcelable = bundle.getParcelable(str);
        if (cls.isInstance(parcelable)) {
            return parcelable;
        }
        return null;
    }

    public static boolean w(int i) {
        if (i == 0) {
            return false;
        }
        ThreadLocal threadLocal = G.a.f757a;
        double[] dArr = (double[]) threadLocal.get();
        if (dArr == null) {
            dArr = new double[3];
            threadLocal.set(dArr);
        }
        int iRed = Color.red(i);
        int iGreen = Color.green(i);
        int iBlue = Color.blue(i);
        if (dArr.length != 3) {
            throw new IllegalArgumentException("outXyz must have a length of 3.");
        }
        double d3 = ((double) iRed) / 255.0d;
        double dPow = d3 < 0.04045d ? d3 / 12.92d : Math.pow((d3 + 0.055d) / 1.055d, 2.4d);
        double d6 = ((double) iGreen) / 255.0d;
        double dPow2 = d6 < 0.04045d ? d6 / 12.92d : Math.pow((d6 + 0.055d) / 1.055d, 2.4d);
        double d7 = ((double) iBlue) / 255.0d;
        double dPow3 = d7 < 0.04045d ? d7 / 12.92d : Math.pow((d7 + 0.055d) / 1.055d, 2.4d);
        dArr[0] = ((0.1805d * dPow3) + (0.3576d * dPow2) + (0.4124d * dPow)) * 100.0d;
        double d8 = ((0.0722d * dPow3) + (0.7152d * dPow2) + (0.2126d * dPow)) * 100.0d;
        dArr[1] = d8;
        dArr[2] = ((dPow3 * 0.9505d) + (dPow2 * 0.1192d) + (dPow * 0.0193d)) * 100.0d;
        return d8 / 100.0d > 0.5d;
    }

    public static int y(int i, int i5, float f6) {
        return G.a.b(G.a.d(i5, Math.round(Color.alpha(i5) * f6)), i);
    }

    public static void z(Class cls, Object obj, ILogger iLogger) {
        iLogger.j(EnumC0738m1.DEBUG, "%s is not %s", obj != null ? obj.getClass().getCanonicalName() : "Hint", cls.getCanonicalName());
    }

    public abstract void B(int i);

    public abstract void C(View view, int i, int i5);

    public abstract void D(View view, float f6, float f7);

    public abstract void F(boolean z5);

    public abstract boolean H(int i, View view);

    public abstract int d(int i, View view);

    public abstract int e(int i, View view);

    public abstract Method n(Class cls, Field field);

    public abstract Constructor o(Class cls);

    public abstract String[] t(Class cls);

    public int u(View view) {
        return 0;
    }

    public int v() {
        return 0;
    }

    public abstract boolean x(Class cls);

    public void E(boolean z5) {
    }

    public void A(int i, View view) {
    }
}
