package l;

import android.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.view.View;
import com.google.android.gms.internal.ads.bk0;
import com.google.android.gms.internal.ads.gf0;
import com.google.android.gms.internal.ads.gk0;
import com.google.android.gms.internal.ads.hk0;
import com.google.android.gms.internal.ads.na0;
import com.google.android.gms.internal.ads.sw1;
import com.google.android.gms.internal.ads.te0;
import com.google.android.gms.internal.ads.tw1;
import com.google.android.gms.internal.ads.uw1;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import xyz.stream.api.entity.SeriesEntity;
import xyz.stream.view.OnItemListener;

/* JADX INFO: loaded from: classes.dex */
public final class b0 implements n2, m7.f, OnItemListener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Object f29639a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f29640b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f29641c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f29642d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f29643e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f29644f;

    public /* synthetic */ b0() {
        this.f29639a = null;
        this.f29640b = null;
        this.f29641c = null;
        this.f29642d = null;
        this.f29643e = null;
        this.f29644f = tw1.f17013d;
    }

    public static boolean b(int i10, int[] iArr) {
        for (int i11 : iArr) {
            if (i11 == i10) {
                return true;
            }
        }
        return false;
    }

    public static ColorStateList e(Context context, int i10) {
        int iC = l3.c(context, d.a.colorControlHighlight);
        return new ColorStateList(new int[][]{l3.f29761b, l3.f29763d, l3.f29762c, l3.f29765f}, new int[]{l3.b(context, d.a.colorButtonNormal), j0.c.c(iC, i10), j0.c.c(iC, i10), i10});
    }

    public static LayerDrawable f(o2 o2Var, Context context, int i10) {
        BitmapDrawable bitmapDrawable;
        BitmapDrawable bitmapDrawable2;
        BitmapDrawable bitmapDrawable3;
        int dimensionPixelSize = context.getResources().getDimensionPixelSize(i10);
        Drawable drawableE = o2Var.e(context, d.e.abc_star_black_48dp);
        Drawable drawableE2 = o2Var.e(context, d.e.abc_star_half_black_48dp);
        if ((drawableE instanceof BitmapDrawable) && drawableE.getIntrinsicWidth() == dimensionPixelSize && drawableE.getIntrinsicHeight() == dimensionPixelSize) {
            bitmapDrawable = (BitmapDrawable) drawableE;
            bitmapDrawable2 = new BitmapDrawable(bitmapDrawable.getBitmap());
        } else {
            Bitmap bitmapCreateBitmap = Bitmap.createBitmap(dimensionPixelSize, dimensionPixelSize, Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmapCreateBitmap);
            drawableE.setBounds(0, 0, dimensionPixelSize, dimensionPixelSize);
            drawableE.draw(canvas);
            bitmapDrawable = new BitmapDrawable(bitmapCreateBitmap);
            bitmapDrawable2 = new BitmapDrawable(bitmapCreateBitmap);
        }
        bitmapDrawable2.setTileModeX(Shader.TileMode.REPEAT);
        if ((drawableE2 instanceof BitmapDrawable) && drawableE2.getIntrinsicWidth() == dimensionPixelSize && drawableE2.getIntrinsicHeight() == dimensionPixelSize) {
            bitmapDrawable3 = (BitmapDrawable) drawableE2;
        } else {
            Bitmap bitmapCreateBitmap2 = Bitmap.createBitmap(dimensionPixelSize, dimensionPixelSize, Bitmap.Config.ARGB_8888);
            Canvas canvas2 = new Canvas(bitmapCreateBitmap2);
            drawableE2.setBounds(0, 0, dimensionPixelSize, dimensionPixelSize);
            drawableE2.draw(canvas2);
            bitmapDrawable3 = new BitmapDrawable(bitmapCreateBitmap2);
        }
        LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{bitmapDrawable, bitmapDrawable3, bitmapDrawable2});
        layerDrawable.setId(0, R.id.background);
        layerDrawable.setId(1, R.id.secondaryProgress);
        layerDrawable.setId(2, R.id.progress);
        return layerDrawable;
    }

    public static void k(Drawable drawable, int i10, PorterDuff.Mode mode) {
        Drawable drawableMutate = drawable.mutate();
        if (mode == null) {
            mode = c0.f29655b;
        }
        drawableMutate.setColorFilter(c0.c(i10, mode));
    }

    public final void a(String str, String str2) {
        Map map = (Map) this.f29644f;
        if (map == null) {
            throw new IllegalStateException("Property \"autoMetadata\" has not been set");
        }
        map.put(str, str2);
    }

    public final ea.m c() {
        if (((Integer) this.f29639a) == null) {
            throw new GeneralSecurityException("AES key size is not set");
        }
        if (((Integer) this.f29640b) == null) {
            throw new GeneralSecurityException("HMAC key size is not set");
        }
        if (((Integer) this.f29641c) == null) {
            throw new GeneralSecurityException("iv size is not set");
        }
        Integer num = (Integer) this.f29642d;
        if (num == null) {
            throw new GeneralSecurityException("tag size is not set");
        }
        if (((ea.k) this.f29643e) == null) {
            throw new GeneralSecurityException("hash type is not set");
        }
        if (((ea.l) this.f29644f) == null) {
            throw new GeneralSecurityException("variant is not set");
        }
        int iIntValue = num.intValue();
        ea.k kVar = (ea.k) this.f29643e;
        if (kVar == ea.k.f25677b) {
            if (iIntValue > 20) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 20 bytes for SHA1", Integer.valueOf(iIntValue)));
            }
        } else if (kVar == ea.k.f25678c) {
            if (iIntValue > 28) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 28 bytes for SHA224", Integer.valueOf(iIntValue)));
            }
        } else if (kVar == ea.k.f25679d) {
            if (iIntValue > 32) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 32 bytes for SHA256", Integer.valueOf(iIntValue)));
            }
        } else if (kVar == ea.k.f25680e) {
            if (iIntValue > 48) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 48 bytes for SHA384", Integer.valueOf(iIntValue)));
            }
        } else {
            if (kVar != ea.k.f25681f) {
                throw new GeneralSecurityException("unknown hash type; must be SHA1, SHA224, SHA256, SHA384 or SHA512");
            }
            if (iIntValue > 64) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 64 bytes for SHA512", Integer.valueOf(iIntValue)));
            }
        }
        return new ea.m(((Integer) this.f29639a).intValue(), ((Integer) this.f29640b).intValue(), ((Integer) this.f29641c).intValue(), ((Integer) this.f29642d).intValue(), (ea.l) this.f29644f, (ea.k) this.f29643e);
    }

    @Override // l.n2
    public final Drawable createDrawableFor(o2 o2Var, Context context, int i10) {
        if (i10 == d.e.abc_cab_background_top_material) {
            return new LayerDrawable(new Drawable[]{o2Var.e(context, d.e.abc_cab_background_internal_bg), o2Var.e(context, d.e.abc_cab_background_top_mtrl_alpha)});
        }
        if (i10 == d.e.abc_ratingbar_material) {
            return f(o2Var, context, d.d.abc_star_big);
        }
        if (i10 == d.e.abc_ratingbar_indicator_material) {
            return f(o2Var, context, d.d.abc_star_medium);
        }
        if (i10 == d.e.abc_ratingbar_small_material) {
            return f(o2Var, context, d.d.abc_star_small);
        }
        return null;
    }

    public final v6.i d() {
        String strJ = ((String) this.f29639a) == null ? " transportName" : "";
        if (((v6.p) this.f29641c) == null) {
            strJ = strJ.concat(" encodedPayload");
        }
        if (((Long) this.f29642d) == null) {
            strJ = com.google.android.gms.measurement.internal.u1.j(strJ, " eventMillis");
        }
        if (((Long) this.f29643e) == null) {
            strJ = com.google.android.gms.measurement.internal.u1.j(strJ, " uptimeMillis");
        }
        if (((Map) this.f29644f) == null) {
            strJ = com.google.android.gms.measurement.internal.u1.j(strJ, " autoMetadata");
        }
        if (strJ.isEmpty()) {
            return new v6.i((String) this.f29639a, (Integer) this.f29640b, (v6.p) this.f29641c, ((Long) this.f29642d).longValue(), ((Long) this.f29643e).longValue(), (Map) this.f29644f, 0);
        }
        throw new IllegalStateException("Missing required properties:".concat(strJ));
    }

    public final void g(int i10) {
        if (i10 != 16 && i10 != 24 && i10 != 32) {
            throw new InvalidAlgorithmParameterException(String.format("Invalid key size %d; only 16-byte, 24-byte and 32-byte AES keys are supported", Integer.valueOf(i10)));
        }
        this.f29639a = Integer.valueOf(i10);
    }

    @Override // l.n2
    public final ColorStateList getTintListForDrawableRes(Context context, int i10) {
        if (i10 == d.e.abc_edit_text_material) {
            return g0.d.getColorStateList(context, d.c.abc_tint_edittext);
        }
        if (i10 == d.e.abc_switch_track_mtrl_alpha) {
            return g0.d.getColorStateList(context, d.c.abc_tint_switch_track);
        }
        if (i10 != d.e.abc_switch_thumb_material) {
            if (i10 == d.e.abc_btn_default_mtrl_shape) {
                return e(context, l3.c(context, d.a.colorButtonNormal));
            }
            if (i10 == d.e.abc_btn_borderless_material) {
                return e(context, 0);
            }
            if (i10 == d.e.abc_btn_colored_material) {
                return e(context, l3.c(context, d.a.colorAccent));
            }
            if (i10 == d.e.abc_spinner_mtrl_am_alpha || i10 == d.e.abc_spinner_textfield_background_material) {
                return g0.d.getColorStateList(context, d.c.abc_tint_spinner);
            }
            if (b(i10, (int[]) this.f29640b)) {
                return l3.getThemeAttrColorStateList(context, d.a.colorControlNormal);
            }
            if (b(i10, (int[]) this.f29643e)) {
                return g0.d.getColorStateList(context, d.c.abc_tint_default);
            }
            if (b(i10, (int[]) this.f29644f)) {
                return g0.d.getColorStateList(context, d.c.abc_tint_btn_checkable);
            }
            if (i10 == d.e.abc_seekbar_thumb_material) {
                return g0.d.getColorStateList(context, d.c.abc_tint_seek_thumb);
            }
            return null;
        }
        int[][] iArr = new int[3][];
        int[] iArr2 = new int[3];
        int i11 = d.a.colorSwitchThumbNormal;
        ColorStateList themeAttrColorStateList = l3.getThemeAttrColorStateList(context, i11);
        if (themeAttrColorStateList == null || !themeAttrColorStateList.isStateful()) {
            iArr[0] = l3.f29761b;
            iArr2[0] = l3.b(context, i11);
            iArr[1] = l3.f29764e;
            iArr2[1] = l3.c(context, d.a.colorControlActivated);
            iArr[2] = l3.f29765f;
            iArr2[2] = l3.c(context, i11);
        } else {
            int[] iArr3 = l3.f29761b;
            iArr[0] = iArr3;
            iArr2[0] = themeAttrColorStateList.getColorForState(iArr3, 0);
            iArr[1] = l3.f29764e;
            iArr2[1] = l3.c(context, d.a.colorControlActivated);
            iArr[2] = l3.f29765f;
            iArr2[2] = themeAttrColorStateList.getDefaultColor();
        }
        return new ColorStateList(iArr, iArr2);
    }

    @Override // l.n2
    public final PorterDuff.Mode getTintModeForDrawableRes(int i10) {
        if (i10 == d.e.abc_switch_thumb_material) {
            return PorterDuff.Mode.MULTIPLY;
        }
        return null;
    }

    public final void h(v6.p pVar) {
        if (pVar == null) {
            throw new NullPointerException("Null encodedPayload");
        }
        this.f29641c = pVar;
    }

    public final void i(int i10) {
        if (i10 < 16) {
            throw new InvalidAlgorithmParameterException(String.format("Invalid key size in bytes %d; HMAC key must be at least 16 bytes", Integer.valueOf(i10)));
        }
        this.f29640b = Integer.valueOf(i10);
    }

    public final void j(int i10) {
        if (i10 < 12 || i10 > 16) {
            throw new GeneralSecurityException(String.format("Invalid IV size in bytes %d; IV size must be between 12 and 16 bytes", Integer.valueOf(i10)));
        }
        this.f29641c = Integer.valueOf(i10);
    }

    public final void l(int i10) {
        if (i10 < 10) {
            throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; must be at least 10 bytes", Integer.valueOf(i10)));
        }
        this.f29642d = Integer.valueOf(i10);
    }

    public final void m(int i10) throws InvalidAlgorithmParameterException {
        if (i10 != 16 && i10 != 24 && i10 != 32) {
            throw new InvalidAlgorithmParameterException(String.format("Invalid key size %d; only 16-byte, 24-byte and 32-byte AES keys are supported", Integer.valueOf(i10)));
        }
        this.f29639a = Integer.valueOf(i10);
    }

    public final void n(int i10) throws InvalidAlgorithmParameterException {
        if (i10 < 16) {
            throw new InvalidAlgorithmParameterException(String.format("Invalid key size in bytes %d; HMAC key must be at least 16 bytes", Integer.valueOf(i10)));
        }
        this.f29640b = Integer.valueOf(i10);
    }

    public final void o(int i10) throws GeneralSecurityException {
        if (i10 < 12 || i10 > 16) {
            throw new GeneralSecurityException(String.format("Invalid IV size in bytes %d; IV size must be between 12 and 16 bytes", Integer.valueOf(i10)));
        }
        this.f29641c = Integer.valueOf(i10);
    }

    @Override // xyz.stream.view.OnItemListener
    public final void onItemClick(View view, int i10) {
        super.onItemClick(view, i10);
        if (((List) this.f29639a).contains(Integer.valueOf(((SeriesEntity) ((List) this.f29640b).get(i10)).getVideoId()))) {
            ((List) this.f29639a).remove(Integer.valueOf(((SeriesEntity) ((List) this.f29640b).get(i10)).getVideoId()));
            ((List) this.f29641c).remove(((List) this.f29640b).get(i10));
        } else {
            ((List) this.f29639a).add(Integer.valueOf(((SeriesEntity) ((List) this.f29640b).get(i10)).getVideoId()));
            ((List) this.f29641c).add((SeriesEntity) ((List) this.f29640b).get(i10));
        }
        pf.e eVar = (pf.e) this.f29642d;
        eVar.f31966b = (List) this.f29639a;
        eVar.notifyDataSetChanged();
        ((ie.a4) this.f29643e).f26640c.setText(((Activity) this.f29644f).getString(org.drive_hunter.R.string.download_selected) + "(" + ((List) this.f29639a).size() + ")");
        ((ie.a4) this.f29643e).f26640c.setBackgroundResource(((List) this.f29639a).isEmpty() ? org.drive_hunter.R.drawable.shape_radius_black6 : org.drive_hunter.R.drawable.shape_radius_red_select_12);
        ((ie.a4) this.f29643e).f26640c.setTextColor(((Activity) this.f29644f).getResources().getColor(((List) this.f29639a).isEmpty() ? org.drive_hunter.R.color.black_9 : org.drive_hunter.R.color.main_text));
    }

    public final void p(int i10) throws GeneralSecurityException {
        if (i10 < 10) {
            throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; must be at least 10 bytes", Integer.valueOf(i10)));
        }
        this.f29642d = Integer.valueOf(i10);
    }

    public final uw1 q() throws GeneralSecurityException {
        if (((Integer) this.f29639a) == null) {
            throw new GeneralSecurityException("AES key size is not set");
        }
        if (((Integer) this.f29640b) == null) {
            throw new GeneralSecurityException("HMAC key size is not set");
        }
        if (((Integer) this.f29641c) == null) {
            throw new GeneralSecurityException("iv size is not set");
        }
        Integer num = (Integer) this.f29642d;
        if (num == null) {
            throw new GeneralSecurityException("tag size is not set");
        }
        if (((sw1) this.f29643e) == null) {
            throw new GeneralSecurityException("hash type is not set");
        }
        if (((tw1) this.f29644f) == null) {
            throw new GeneralSecurityException("variant is not set");
        }
        int iIntValue = num.intValue();
        sw1 sw1Var = (sw1) this.f29643e;
        if (sw1Var == sw1.f16604b) {
            if (iIntValue > 20) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 20 bytes for SHA1", Integer.valueOf(iIntValue)));
            }
        } else if (sw1Var == sw1.f16605c) {
            if (iIntValue > 28) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 28 bytes for SHA224", Integer.valueOf(iIntValue)));
            }
        } else if (sw1Var == sw1.f16606d) {
            if (iIntValue > 32) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 32 bytes for SHA256", Integer.valueOf(iIntValue)));
            }
        } else if (sw1Var == sw1.f16607e) {
            if (iIntValue > 48) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 48 bytes for SHA384", Integer.valueOf(iIntValue)));
            }
        } else {
            if (sw1Var != sw1.f16608f) {
                throw new GeneralSecurityException("unknown hash type; must be SHA1, SHA224, SHA256, SHA384 or SHA512");
            }
            if (iIntValue > 64) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 64 bytes for SHA512", Integer.valueOf(iIntValue)));
            }
        }
        return new uw1(((Integer) this.f29639a).intValue(), ((Integer) this.f29640b).intValue(), ((Integer) this.f29641c).intValue(), ((Integer) this.f29642d).intValue(), (tw1) this.f29644f, (sw1) this.f29643e);
    }

    @Override // m7.f
    public final synchronized void zza(View view) {
        if (((AtomicBoolean) this.f29644f).compareAndSet(false, true)) {
            ((na0) this.f29643e).h();
            ((bk0) this.f29642d).I0(view);
        }
    }

    @Override // m7.f
    public final void zzb() {
        if (((AtomicBoolean) this.f29644f).get()) {
            ((te0) this.f29639a).onAdClicked();
        }
    }

    @Override // m7.f
    public final void zzc() {
        if (((AtomicBoolean) this.f29644f).get()) {
            ((gf0) this.f29640b).zza();
            hk0 hk0Var = (hk0) this.f29641c;
            synchronized (hk0Var) {
                hk0Var.H0(gk0.f11771a);
            }
        }
    }

    public b0(int i10) {
        if (i10 != 2) {
            if (i10 != 6) {
                this.f29639a = new int[]{d.e.abc_textfield_search_default_mtrl_alpha, d.e.abc_textfield_default_mtrl_alpha, d.e.abc_ab_share_pack_mtrl_alpha};
                this.f29640b = new int[]{d.e.abc_ic_commit_search_api_mtrl_alpha, d.e.abc_seekbar_tick_mark_material, d.e.abc_ic_menu_share_mtrl_alpha, d.e.abc_ic_menu_copy_mtrl_am_alpha, d.e.abc_ic_menu_cut_mtrl_alpha, d.e.abc_ic_menu_selectall_mtrl_alpha, d.e.abc_ic_menu_paste_mtrl_am_alpha};
                this.f29641c = new int[]{d.e.abc_textfield_activated_mtrl_alpha, d.e.abc_textfield_search_activated_mtrl_alpha, d.e.abc_cab_background_top_mtrl_alpha, d.e.abc_text_cursor_material, d.e.abc_text_select_handle_left_mtrl, d.e.abc_text_select_handle_middle_mtrl, d.e.abc_text_select_handle_right_mtrl};
                this.f29642d = new int[]{d.e.abc_popup_background_mtrl_mult, d.e.abc_cab_background_internal_bg, d.e.abc_menu_hardkey_panel_mtrl_mult};
                this.f29643e = new int[]{d.e.abc_tab_indicator_material, d.e.abc_textfield_search_material};
                this.f29644f = new int[]{d.e.abc_btn_check_material, d.e.abc_btn_radio_material, d.e.abc_btn_check_material_anim, d.e.abc_btn_radio_material_anim};
                return;
            }
            this.f29639a = null;
            this.f29640b = null;
            this.f29641c = null;
            this.f29642d = null;
            this.f29643e = null;
            this.f29644f = ea.l.f25688d;
        }
    }
}
