package com.bumptech.glide;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewParent;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import com.google.android.gms.measurement.internal.u1;
import com.google.crypto.tink.shaded.protobuf.ByteString;
import com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.coroutines.Continuation;
import ma.i0;
import ma.l0;
import ma.n0;
import ma.p0;
import ra.d1;
import ra.h1;
import ra.o0;
import ra.y0;
import xyz.stream.utils.e0;

/* JADX INFO: loaded from: classes.dex */
public abstract class f implements l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static l8.g f5561a = null;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static volatile boolean f5562b = true;

    /* JADX WARN: Multi-variable type inference failed */
    public static AnimatorSet a(g9.g gVar, float f10, float f11, float f12) {
        ObjectAnimator objectAnimatorOfObject = ObjectAnimator.ofObject(gVar, g9.d.f26329a, g9.c.f26327b, new g9.f(f10, f11, f12));
        g9.f revealInfo = gVar.getRevealInfo();
        if (revealInfo == null) {
            throw new IllegalStateException("Caller must set a non-null RevealInfo before calling this.");
        }
        Animator animatorCreateCircularReveal = ViewAnimationUtils.createCircularReveal((View) gVar, (int) f10, (int) f11, revealInfo.f26333c, f12);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(objectAnimatorOfObject, animatorCreateCircularReveal);
        return animatorSet;
    }

    public static h b(int i10) {
        return i10 != 0 ? i10 != 1 ? new com.google.android.material.shape.p() : new com.google.android.material.shape.e() : new com.google.android.material.shape.p();
    }

    public static byte[] c(byte[] bArr) {
        if (bArr.length != 16) {
            throw new IllegalArgumentException("value must be a block.");
        }
        byte[] bArr2 = new byte[16];
        for (int i10 = 0; i10 < 16; i10++) {
            byte b10 = (byte) ((bArr[i10] << 1) & 254);
            bArr2[i10] = b10;
            if (i10 < 15) {
                bArr2[i10] = (byte) (((byte) ((bArr[i10 + 1] >> 7) & 1)) | b10);
            }
        }
        bArr2[15] = (byte) (((byte) ((bArr[0] >> 7) & 135)) ^ bArr2[15]);
        return bArr2;
    }

    public static byte[] d(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 i10 = 0; i10 < length; i10++) {
            int i11 = i10 * 2;
            int iDigit = Character.digit(str.charAt(i11), 16);
            int iDigit2 = Character.digit(str.charAt(i11 + 1), 16);
            if (iDigit == -1 || iDigit2 == -1) {
                throw new IllegalArgumentException("input is not hexadecimal");
            }
            bArr[i10] = (byte) ((iDigit * 16) + iDigit2);
        }
        return bArr;
    }

    public static boolean e(Object obj, Object obj2) {
        if ((obj instanceof byte[]) && (obj2 instanceof byte[])) {
            return Arrays.equals((byte[]) obj, (byte[]) obj2);
        }
        if ((obj instanceof int[]) && (obj2 instanceof int[])) {
            return Arrays.equals((int[]) obj, (int[]) obj2);
        }
        if ((obj instanceof long[]) && (obj2 instanceof long[])) {
            return Arrays.equals((long[]) obj, (long[]) obj2);
        }
        if ((obj instanceof double[]) && (obj2 instanceof double[])) {
            return Arrays.equals((double[]) obj, (double[]) obj2);
        }
        if ((obj instanceof Object[]) && (obj2 instanceof Object[])) {
            Object[] objArr = (Object[]) obj;
            Object[] objArr2 = (Object[]) obj2;
            if (objArr.length == objArr2.length) {
                Iterable cVar = new xd.c(0, objArr.length - 1, 1);
                if ((cVar instanceof Collection) && ((Collection) cVar).isEmpty()) {
                    return true;
                }
                Iterator it = cVar.iterator();
                while (((xd.b) it).f34812c) {
                    int iB = ((xd.b) it).b();
                    if (!e(objArr[iB], objArr2[iB])) {
                    }
                }
                return true;
            }
            return false;
        }
        if ((obj instanceof List) && (obj2 instanceof List)) {
            List list = (List) obj;
            List list2 = (List) obj2;
            if (list.size() == list2.size()) {
                Collection collection = (Collection) obj;
                nb.g.i(collection, "<this>");
                Iterable cVar2 = new xd.c(0, collection.size() - 1, 1);
                if ((cVar2 instanceof Collection) && ((Collection) cVar2).isEmpty()) {
                    return true;
                }
                Iterator it2 = cVar2.iterator();
                while (((xd.b) it2).f34812c) {
                    int iB2 = ((xd.b) it2).b();
                    if (!e(list.get(iB2), list2.get(iB2))) {
                    }
                }
                return true;
            }
            return false;
        }
        if (!(obj instanceof Map) || !(obj2 instanceof Map)) {
            return nb.g.c(obj, obj2);
        }
        Map map = (Map) obj;
        Map map2 = (Map) obj2;
        if (map.size() == map2.size()) {
            if (map.isEmpty()) {
                return true;
            }
            for (Map.Entry entry : map.entrySet()) {
                if (!map2.containsKey(entry.getKey()) || !e(entry.getValue(), map2.get(entry.getKey()))) {
                }
            }
            return true;
        }
        return false;
    }

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

    public static e0 g(String str) {
        da.l lVar;
        ma.r rVar = ma.r.f30551b;
        synchronized (rVar) {
            if (!rVar.f30552a.containsKey(str)) {
                throw new GeneralSecurityException("Name " + str + " does not exist");
            }
            lVar = (da.l) rVar.f30552a.get(str);
        }
        return new e0(lVar);
    }

    public static float h(int i10, String[] strArr) {
        float f10 = Float.parseFloat(strArr[i10]);
        if (f10 >= 0.0f && f10 <= 1.0f) {
            return f10;
        }
        throw new IllegalArgumentException("Motion easing control point value must be between 0 and 1; instead got: " + f10);
    }

    public static long i(double d10) {
        if (!k(d10)) {
            throw new IllegalArgumentException("not a normal value");
        }
        int exponent = Math.getExponent(d10);
        long jDoubleToRawLongBits = Double.doubleToRawLongBits(d10) & 4503599627370495L;
        return exponent == -1023 ? jDoubleToRawLongBits << 1 : jDoubleToRawLongBits | 4503599627370496L;
    }

    public static boolean k(double d10) {
        return Math.getExponent(d10) <= 1023;
    }

    public static boolean l(String str, String str2) {
        return str.startsWith(str2.concat("(")) && str.endsWith(")");
    }

    public static da.l m(byte[] bArr) throws GeneralSecurityException {
        try {
            y0 y0VarM = y0.M(bArr, com.google.crypto.tink.shaded.protobuf.q.a());
            ma.t tVar = ma.t.f30555b;
            ta.a aVarA = p0.a(y0VarM.I());
            i0 i0Var = new i0(y0VarM, aVarA);
            n0 n0Var = (n0) tVar.f30556a.get();
            n0Var.getClass();
            return !n0Var.f30544d.containsKey(new l0(i0.class, aVarA)) ? new ma.k(i0Var) : tVar.b(i0Var);
        } catch (IOException e10) {
            throw new GeneralSecurityException("Failed to parse proto", e10);
        }
    }

    public static da.h n(a5.d dVar, da.a aVar, byte[] bArr) throws GeneralSecurityException, IOException {
        InputStream inputStream = dVar.f375a;
        try {
            o0 o0VarH = o0.H(inputStream, com.google.crypto.tink.shaded.protobuf.q.a());
            inputStream.close();
            if (o0VarH.F().size() == 0) {
                throw new GeneralSecurityException("empty keyset");
            }
            try {
                d1 d1VarL = d1.L(aVar.b(o0VarH.F().k(), bArr), com.google.crypto.tink.shaded.protobuf.q.a());
                if (d1VarL == null || d1VarL.G() <= 0) {
                    throw new GeneralSecurityException("empty keyset");
                }
                return da.h.b(d1VarL);
            } catch (InvalidProtocolBufferException unused) {
                throw new GeneralSecurityException("invalid keyset, corrupted key material");
            }
        } catch (Throwable th) {
            inputStream.close();
            throw th;
        }
    }

    public static int o(Context context, int i10, int i11) {
        TypedValue typedValueResolve = q9.c.resolve(context, i10);
        return (typedValueResolve == null || typedValueResolve.type != 16) ? i11 : typedValueResolve.data;
    }

    public static TimeInterpolator p(Context context, int i10, Interpolator interpolator) {
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(i10, typedValue, true)) {
            return interpolator;
        }
        if (typedValue.type != 3) {
            throw new IllegalArgumentException("Motion easing theme attribute must be an @interpolator resource for ?attr/motionEasing*Interpolator attributes or a string for ?attr/motionEasing* attributes.");
        }
        String strValueOf = String.valueOf(typedValue.string);
        if (!l(strValueOf, "cubic-bezier") && !l(strValueOf, "path")) {
            return AnimationUtils.loadInterpolator(context, typedValue.resourceId);
        }
        if (!l(strValueOf, "cubic-bezier")) {
            if (l(strValueOf, "path")) {
                return new PathInterpolator(j0.g.c(u1.h(strValueOf, 1, 5)));
            }
            throw new IllegalArgumentException("Invalid motion easing type: ".concat(strValueOf));
        }
        String[] strArrSplit = strValueOf.substring(13, strValueOf.length() - 1).split(",");
        if (strArrSplit.length == 4) {
            return new PathInterpolator(h(0, strArrSplit), h(1, strArrSplit), h(2, strArrSplit), h(3, strArrSplit));
        }
        throw new IllegalArgumentException("Motion easing theme attribute must have 4 control points if using bezier curve format; instead got: " + strArrSplit.length);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static byte[] q(ea.c cVar) {
        return cVar instanceof ma.k ? ((ma.k) cVar).f30532a.f30529b.e() : ((i0) ma.t.f30555b.h(cVar)).f30529b.e();
    }

    public static void r(da.h hVar, xyz.stream.utils.f fVar, da.a aVar, byte[] bArr) throws IOException {
        d1 d1VarD = hVar.d();
        byte[] bArrA = aVar.a(d1VarD.e(), bArr);
        ra.n0 n0VarG = o0.G();
        ByteString byteStringG = ByteString.g(0, bArrA.length, bArrA);
        n0VarG.f();
        o0.D((o0) n0VarG.f23982b, byteStringG);
        h1 h1VarA = da.m.a(d1VarD);
        n0VarG.f();
        o0.E((o0) n0VarG.f23982b, h1VarA);
        if (!((SharedPreferences.Editor) fVar.f36132b).putString((String) fVar.f36133c, f(((o0) n0VarG.c()).e())).commit()) {
            throw new IOException("Failed to write to SharedPreferences");
        }
    }

    public static void s(da.h hVar, xyz.stream.utils.f fVar) throws IOException {
        if (!((SharedPreferences.Editor) fVar.f36132b).putString((String) fVar.f36133c, f(hVar.d().e())).commit()) {
            throw new IOException("Failed to write to SharedPreferences");
        }
    }

    public static void t(View view, float f10) {
        Drawable background = view.getBackground();
        if (background instanceof com.google.android.material.shape.k) {
            ((com.google.android.material.shape.k) background).w(f10);
        }
    }

    public static void u(View view) {
        Drawable background = view.getBackground();
        if (background instanceof com.google.android.material.shape.k) {
            v(view, (com.google.android.material.shape.k) background);
        }
    }

    public static void v(View view, com.google.android.material.shape.k kVar) {
        if (kVar.t()) {
            float elevation = 0.0f;
            for (ViewParent parent = view.getParent(); parent instanceof View; parent = parent.getParent()) {
                elevation += ((View) parent).getElevation();
            }
            com.google.android.material.shape.h hVar = kVar.f23095b;
            if (hVar.f23073f != elevation) {
                hVar.f23073f = elevation;
                kVar.H();
            }
        }
    }

    public static List w(Throwable th) {
        return hb.a.m0(th.getClass().getSimpleName(), th.toString(), "Cause: " + th.getCause() + ", Stacktrace: " + Log.getStackTraceString(th));
    }

    public static void x(int i10, Object[] objArr) {
        for (int i11 = 0; i11 < i10; i11++) {
            if (objArr[i11] == null) {
                throw new NullPointerException(defpackage.e.n(new StringBuilder(String.valueOf(i11).length() + 9), "at index ", i11));
            }
        }
    }

    public abstract Object j(androidx.privacysandbox.ads.adservices.topics.a aVar, Continuation continuation);
}
