package xyz.netfly.player;

import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Looper;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import clientgosdk.Clientgosdk;
import com.google.android.gms.measurement.internal.u1;
import ie.c4;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.drive_hunter.R;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.SubtitleView;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.FormatASS;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.FormatSCC;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.FormatSRT;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.FormatSTL;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.FormatTTML;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.TimedTextFileFormat;
import tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.TimedTextObject;
import xyz.stream.api.entity.InnerSubtitleEntity;
import xyz.stream.api.entity.SubtitleEntity;
import xyz.stream.api.entity.SubtitlePlayEntity;
import xyz.stream.api.u;
import xyz.stream.utils.f0;
import xyz.stream.utils.z;
import xyz.stream.view.MaskOverLay;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public final class n {

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final String[][] f35213y = {new String[]{"english", "English(AI)"}, new String[]{"español", "Español(AI)"}, new String[]{"português", "Português(AI)"}, new String[]{"français", "Français(AI)"}, new String[]{"العربية", "بالعربية(AI)"}, new String[]{"türkçe", "Türkçe(AI)"}};

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static volatile n f35214z;

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public String f35221g;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public WeakReference f35223i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public TimedTextObject f35224j;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public ScheduledExecutorService f35226l;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public String f35229o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public String f35230p;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public Activity f35233s;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public g f35238x;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList f35217c = new ArrayList();

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f35222h = 0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final Handler f35225k = new Handler(Looper.getMainLooper());

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final ArrayList f35227m = new ArrayList();

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f35228n = true;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f35231q = false;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f35232r = false;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final ArrayList f35234t = new ArrayList();

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final ArrayList f35235u = new ArrayList();

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f35236v = false;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public boolean f35237w = false;

    public static void a(n nVar, String str, String str2) {
        ArrayList arrayList = nVar.f35217c;
        Object obj = t4.f.x(arrayList).e(new com.google.firebase.messaging.m(str2, 8)).g().f32947a;
        if (obj == null) {
            obj = null;
        }
        SubtitlePlayEntity subtitlePlayEntity = (SubtitlePlayEntity) obj;
        if (subtitlePlayEntity != null) {
            int iIndexOf = arrayList.indexOf(subtitlePlayEntity);
            ((SubtitlePlayEntity) arrayList.get(iIndexOf)).setInnerSubtitleEntity(new InnerSubtitleEntity(str2, str, "srt"));
            nVar.s(iIndexOf, true);
        }
        ArrayList arrayList2 = nVar.f35227m;
        if (!arrayList2.isEmpty()) {
            arrayList2.remove(0);
        }
        nVar.t();
        if (arrayList2.isEmpty()) {
            nVar.f35228n = true;
        } else {
            nVar.y((SubtitlePlayEntity) arrayList2.get(0), false);
        }
    }

    public static void b(ArrayList arrayList, SubtitlePlayEntity subtitlePlayEntity) {
        if (subtitlePlayEntity == null || subtitlePlayEntity.getTitle() == null) {
            return;
        }
        t4.f fVarX = t4.f.x(arrayList);
        while (true) {
            Iterator it = fVarX.f32951a;
            if (!it.hasNext()) {
                break;
            }
            boolean zEquals = subtitlePlayEntity.getTitle().equals(((SubtitlePlayEntity) it.next()).getTitle());
            if (zEquals) {
                if (zEquals) {
                    return;
                }
            }
        }
        arrayList.add(subtitlePlayEntity);
    }

    public static String d(String str, String str2) {
        return (str == null || str.isEmpty() || str2.endsWith(".".concat(str))) ? str2 : defpackage.e.j(str2, ".", str);
    }

    public static n h() {
        if (f35214z == null) {
            synchronized (n.class) {
                try {
                    if (f35214z == null) {
                        f35214z = new n();
                    }
                } finally {
                }
            }
        }
        return f35214z;
    }

    public static TimedTextFileFormat l(String str) {
        return str.endsWith(".srt") ? new FormatSRT() : str.endsWith(".ass") ? new FormatASS() : str.endsWith(".scc") ? new FormatSCC() : str.endsWith(".stl") ? new FormatSTL() : str.endsWith(".xml") ? new FormatTTML() : new FormatSRT();
    }

    public static boolean p(String str) {
        return str != null && str.contains("(AI)");
    }

    public static boolean q(SubtitlePlayEntity subtitlePlayEntity, String str, boolean z10, boolean z11) {
        if (subtitlePlayEntity == null || subtitlePlayEntity.getTitle() == null || p(subtitlePlayEntity.getTitle())) {
            return false;
        }
        if (z10 && subtitlePlayEntity.getInnerSubtitleEntity() == null) {
            return false;
        }
        String title = subtitlePlayEntity.getTitle();
        Locale locale = Locale.ROOT;
        String lowerCase = title.toLowerCase(locale);
        String lowerCase2 = subtitlePlayEntity.getTitle().split("\\(")[0].toLowerCase(locale);
        if (!z11) {
            return lowerCase.equals(str) || lowerCase.contains(str) || str.contains(lowerCase) || lowerCase2.contains(str) || str.contains(lowerCase2);
        }
        if (!lowerCase.equals(str) || subtitlePlayEntity.getTitle().contains("(CC)")) {
            return lowerCase2.equals(str);
        }
        return true;
    }

    public final void c(int i10) {
        SubtitleView subtitleViewK;
        ArrayList arrayList = this.f35217c;
        if (arrayList.isEmpty() || this.f35222h <= 0) {
            return;
        }
        int size = arrayList.size();
        int i11 = this.f35222h;
        if (size <= i11 || ((SubtitlePlayEntity) arrayList.get(i11)).getInnerSubtitleEntity() == null || (subtitleViewK = k()) == null) {
            return;
        }
        subtitleViewK.seekTo(i10);
    }

    public final void e() {
        u uVarA = u.a();
        int i10 = this.f35216b;
        ArrayList arrayList = uVarA.f35938a;
        if (!arrayList.isEmpty()) {
            Iterator it = arrayList.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                Integer num = (Integer) it.next();
                if (num.intValue() == i10) {
                    arrayList.remove(num);
                    break;
                }
            }
        }
        SubtitleView subtitleViewK = k();
        if (this.f35215a != null && subtitleViewK != null) {
            subtitleViewK.setStop();
            this.f35215a.clear();
            this.f35215a = null;
        }
        if (this.f35229o != null) {
            xyz.stream.api.q.g().a(this.f35229o);
            this.f35229o = null;
        }
        WeakReference weakReference = this.f35223i;
        if (weakReference != null) {
            weakReference.clear();
            this.f35223i = null;
        }
        WeakReference weakReference2 = this.f35218d;
        if (weakReference2 != null) {
            weakReference2.clear();
            this.f35218d = null;
        }
        g gVar = this.f35238x;
        if (gVar != null) {
            e.m mVar = (e.m) gVar.f35197a;
            if (mVar.isShowing()) {
                mVar.dismiss();
            }
            this.f35238x = null;
        }
        this.f35227m.clear();
        this.f35234t.clear();
        this.f35235u.clear();
        this.f35217c.clear();
        this.f35216b = 0;
        this.f35233s = null;
        this.f35224j = null;
        t();
        f35214z = null;
    }

    public final void f(int i10, String str, String str2, String str3) {
        String strD = d(str2, str3);
        String string = UUID.randomUUID().toString();
        if (str.startsWith("http")) {
            this.f35229o = str;
        } else {
            xyz.stream.api.q.g().getClass();
            this.f35229o = Clientgosdk.getDownloadUrl(string, str);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(this.f35221g);
        z.d(this.f35229o, strD, this.f35221g, new f(this, new File(defpackage.e.o(sb, File.separator, strD)), strD, i10, str, str2, str3));
    }

    public final t4.e g(String str, final boolean z10) {
        if (str == null || str.isEmpty()) {
            return t4.e.f32948c;
        }
        final String lowerCase = str.toLowerCase(Locale.ROOT);
        ArrayList arrayList = this.f35217c;
        final int i10 = 0;
        t4.e eVarG = t4.c.k(arrayList.size()).e(new u4.b(this) { // from class: xyz.netfly.player.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ n f35187b;

            {
                this.f35187b = this;
            }

            @Override // u4.b
            public final boolean c(int i11) {
                int i12 = i10;
                boolean z11 = z10;
                String str2 = lowerCase;
                n nVar = this.f35187b;
                switch (i12) {
                    case 0:
                        return n.q((SubtitlePlayEntity) nVar.f35217c.get(i11), str2, z11, true);
                    default:
                        return n.q((SubtitlePlayEntity) nVar.f35217c.get(i11), str2, z11, false);
                }
            }
        }).g();
        if (eVarG.f32949a) {
            return eVarG;
        }
        final int i11 = 1;
        return t4.c.k(arrayList.size()).e(new u4.b(this) { // from class: xyz.netfly.player.e

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ n f35187b;

            {
                this.f35187b = this;
            }

            @Override // u4.b
            public final boolean c(int i112) {
                int i12 = i11;
                boolean z11 = z10;
                String str2 = lowerCase;
                n nVar = this.f35187b;
                switch (i12) {
                    case 0:
                        return n.q((SubtitlePlayEntity) nVar.f35217c.get(i112), str2, z11, true);
                    default:
                        return n.q((SubtitlePlayEntity) nVar.f35217c.get(i112), str2, z11, false);
                }
            }
        }).g();
    }

    public final TextView i() {
        WeakReference weakReference = this.f35218d;
        if (weakReference == null) {
            return null;
        }
        return (TextView) weakReference.get();
    }

    public final ArrayList j() {
        ArrayList arrayList = new ArrayList();
        Iterator it = this.f35217c.iterator();
        while (it.hasNext()) {
            arrayList.add(((SubtitlePlayEntity) it.next()).getTitle());
        }
        return arrayList;
    }

    public final SubtitleView k() {
        WeakReference weakReference = this.f35215a;
        if (weakReference == null) {
            return null;
        }
        return (SubtitleView) weakReference.get();
    }

    public final void m(final SubtitlePlayEntity subtitlePlayEntity) {
        ScheduledExecutorService scheduledExecutorService;
        ArrayList arrayList = this.f35227m;
        if (arrayList != null && !arrayList.isEmpty() && (scheduledExecutorService = this.f35226l) != null && !scheduledExecutorService.isShutdown()) {
            Object obj = t4.f.x(arrayList).e(new u4.c() { // from class: xyz.netfly.player.a
                @Override // u4.c
                public final boolean test(Object obj2) {
                    return ((SubtitlePlayEntity) obj2).getTitle().equals(subtitlePlayEntity.getTitle());
                }
            }).g().f32947a;
            if (obj == null) {
                obj = null;
            }
            if (((SubtitlePlayEntity) obj) != null) {
                if (this.f35238x == null) {
                    x();
                    return;
                }
                return;
            }
        }
        WeakReference weakReference = this.f35223i;
        if (weakReference != null && weakReference.get() != null) {
            ((wf.a) this.f35223i.get()).b();
        }
        d dVar = new d(this, subtitlePlayEntity, 1);
        if (o()) {
            this.f35233s.runOnUiThread(dVar);
        }
    }

    public final void n(Activity activity, boolean z10, int i10, boolean z11, String str) {
        File[] fileArrListFiles;
        this.f35233s = (Activity) new WeakReference(activity).get();
        this.f35216b = i10;
        this.f35231q = z11;
        this.f35230p = str;
        this.f35232r = z10;
        this.f35219e = activity.getString(R.string.subtitle_loading);
        this.f35220f = activity.getString(R.string.subtitle_failed);
        t();
        g gVar = this.f35238x;
        if (gVar != null) {
            e.m mVar = (e.m) gVar.f35197a;
            if (mVar.isShowing()) {
                mVar.dismiss();
            }
            this.f35238x = null;
        }
        ArrayList arrayList = this.f35217c;
        arrayList.clear();
        this.f35235u.clear();
        this.f35234t.clear();
        this.f35227m.clear();
        this.f35222h = 0;
        this.f35224j = null;
        this.f35236v = false;
        this.f35237w = false;
        this.f35228n = true;
        this.f35229o = null;
        arrayList.clear();
        StringBuilder sb = new StringBuilder();
        sb.append(activity.getCacheDir().getAbsolutePath());
        this.f35221g = defpackage.e.o(sb, File.separator, "captions");
        new File(this.f35221g).mkdirs();
        if (!z10) {
            if (this.f35216b == 0) {
                w(new ArrayList());
                return;
            } else {
                u.a().b(this.f35216b, new b(this, 0));
                return;
            }
        }
        File file = new File(str);
        ArrayList arrayList2 = new ArrayList();
        if (file.isDirectory() && (fileArrListFiles = file.listFiles()) != null) {
            for (File file2 : fileArrListFiles) {
                if (file2.isFile() && file2.getName().endsWith(".srt")) {
                    arrayList2.add(file2);
                }
            }
        }
        ArrayList arrayList3 = new ArrayList();
        Iterator it = arrayList2.iterator();
        while (it.hasNext()) {
            arrayList3.add(new SubtitleEntity(((File) it.next()).getName(), "srt"));
        }
        w(arrayList3);
    }

    public final boolean o() {
        Activity activity = this.f35233s;
        return (activity == null || activity.isDestroyed() || this.f35233s.isFinishing()) ? false : true;
    }

    public final void r() {
        wf.a aVar;
        if (this.f35236v && this.f35237w) {
            ArrayList arrayList = this.f35217c;
            arrayList.clear();
            Iterator it = this.f35234t.iterator();
            while (it.hasNext()) {
                b(arrayList, (SubtitlePlayEntity) it.next());
            }
            ArrayList arrayList2 = this.f35235u;
            Iterator it2 = arrayList2.iterator();
            while (it2.hasNext()) {
                b(arrayList, (SubtitlePlayEntity) it2.next());
            }
            int i10 = 1;
            if (arrayList.isEmpty()) {
                WeakReference weakReference = this.f35223i;
                if (weakReference != null && (aVar = (wf.a) weakReference.get()) != null) {
                    aVar.c();
                }
                c cVar = new c(this, i10);
                if (o()) {
                    this.f35233s.runOnUiThread(cVar);
                    return;
                }
                return;
            }
            int i11 = 0;
            if (!this.f35232r && !arrayList2.isEmpty()) {
                for (int i12 = 0; i12 < 6; i12++) {
                    String[] strArr = f35213y[i12];
                    String str = strArr[0];
                    String str2 = strArr[1];
                    if (!t4.c.k(arrayList.size()).e(new androidx.media3.exoplayer.analytics.g(this, str, 24)).g().f32949a) {
                        arrayList.add(new SubtitlePlayEntity(str2, i12 + 1, null));
                    }
                }
            }
            xyz.stream.utils.o.g(arrayList);
            Object obj = t4.f.x(arrayList).e(new fa.h(25)).g().f32947a;
            if (obj == null) {
                obj = null;
            }
            SubtitlePlayEntity subtitlePlayEntity = (SubtitlePlayEntity) obj;
            if (subtitlePlayEntity != null) {
                arrayList.remove(subtitlePlayEntity);
            }
            arrayList.add(0, new SubtitlePlayEntity("Off", -1, null));
            this.f35222h = 0;
            c cVar2 = new c(this, i11);
            if (o()) {
                this.f35233s.runOnUiThread(cVar2);
            }
        }
    }

    public final void s(int i10, boolean z10) {
        wf.a aVar;
        if (i10 < 0) {
            return;
        }
        ArrayList arrayList = this.f35217c;
        if (i10 >= arrayList.size()) {
            return;
        }
        WeakReference weakReference = this.f35223i;
        if (weakReference != null && (aVar = (wf.a) weakReference.get()) != null) {
            aVar.c();
        }
        SubtitlePlayEntity subtitlePlayEntity = (SubtitlePlayEntity) arrayList.get(i10);
        Handler handler = this.f35225k;
        if (subtitlePlayEntity == null) {
            this.f35222h = i10;
            handler.post(new c(this, 3));
            return;
        }
        if (subtitlePlayEntity.getInnerSubtitleEntity() != null) {
            if (this.f35222h != i10) {
                handler.post(new c(this, 2));
            }
            String name = subtitlePlayEntity.getInnerSubtitleEntity().getName();
            if (!this.f35232r) {
                name = this.f35216b + "_" + subtitlePlayEntity.getInnerSubtitleEntity().getName();
            }
            new Thread(new androidx.media3.exoplayer.audio.j(this, subtitlePlayEntity.getInnerSubtitleEntity().getType(), name, subtitlePlayEntity.getInnerSubtitleEntity().getUrl(), 5)).start();
            this.f35222h = i10;
        } else if (p(subtitlePlayEntity.getTitle())) {
            m(subtitlePlayEntity);
        } else {
            this.f35222h = i10;
            d dVar = new d(this, subtitlePlayEntity, 0);
            if (o()) {
                this.f35233s.runOnUiThread(dVar);
            }
        }
        if (z10) {
            return;
        }
        f0 f0VarO = f0.o();
        String title = ((SubtitlePlayEntity) arrayList.get(i10)).getTitle();
        Matcher matcher = Pattern.compile("^(.*?)(\\(.*\\))?$").matcher(title);
        if (matcher.find()) {
            title = matcher.group(1).trim();
        }
        f0VarO.w("flutter.spSubtitleLanguage", title);
    }

    public final void t() {
        ScheduledExecutorService scheduledExecutorService = this.f35226l;
        if (scheduledExecutorService != null && !scheduledExecutorService.isShutdown()) {
            this.f35226l.shutdownNow();
        }
        this.f35226l = null;
    }

    public final void u(ArrayList arrayList) {
        ArrayList arrayList2 = this.f35234t;
        arrayList2.clear();
        arrayList2.addAll(arrayList);
        this.f35236v = true;
        r();
    }

    public final void v(Activity activity, SubtitleView subtitleView, TextView textView) {
        new WeakReference(activity);
        this.f35215a = new WeakReference(subtitleView);
        WeakReference weakReference = new WeakReference(textView);
        this.f35218d = weakReference;
        if (weakReference.get() == null) {
            return;
        }
        ((TextView) this.f35218d.get()).setText("");
        ((TextView) this.f35218d.get()).setVisibility(0);
        String strQ = f0.o().q("flutter.spSubtitleLanguage", null);
        if (strQ == null || !strQ.equals("Off")) {
            textView.setText(this.f35219e);
        }
    }

    public final void w(ArrayList arrayList) {
        ArrayList arrayList2 = this.f35235u;
        arrayList2.clear();
        if (!arrayList.isEmpty()) {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                SubtitleEntity subtitleEntity = (SubtitleEntity) it.next();
                String name = subtitleEntity.getName();
                try {
                    name = xyz.stream.utils.o.c().f(subtitleEntity.getName());
                } catch (Exception e10) {
                    xyz.stream.utils.h.b("get subtitle name error: " + e10);
                }
                if (name != null && !name.isEmpty()) {
                    b(arrayList2, new SubtitlePlayEntity(name, arrayList.indexOf(subtitleEntity), new InnerSubtitleEntity(subtitleEntity.getName(), subtitleEntity.getTurboUrl(), subtitleEntity.getType())));
                }
            }
        }
        this.f35237w = true;
        r();
    }

    public final void x() {
        if (o()) {
            ArrayList arrayList = this.f35227m;
            if (arrayList.isEmpty()) {
                return;
            }
            Activity activity = this.f35233s;
            boolean z10 = this.f35231q;
            int i10 = 0;
            String title = ((SubtitlePlayEntity) arrayList.get(0)).getTitle();
            f0 f0Var = new f0(this, 25);
            g gVar = null;
            if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
                c4 c4VarInflate = c4.inflate(LayoutInflater.from(activity), null, false);
                e.l lVar = new e.l(activity, R.style.CustomDialogWhite);
                lVar.setView(c4VarInflate.f26734a);
                lVar.f25255a.f25211k = true;
                e.m mVarCreate = lVar.create();
                mVarCreate.show();
                MaskOverLay.getInstance().backgroundAlpha(activity, 0.5f);
                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                spannableStringBuilder.append((CharSequence) activity.getString(R.string.ai_sub_for));
                spannableStringBuilder.append((CharSequence) " ");
                SpannableString spannableString = new SpannableString(title.replace("(AI)", ""));
                Object obj = g0.d.f26125a;
                spannableString.setSpan(new ForegroundColorSpan(activity.getColor(R.color.main_color)), 0, spannableString.length(), 33);
                spannableStringBuilder.append((CharSequence) spannableString);
                spannableStringBuilder.append((CharSequence) " ");
                spannableStringBuilder.append((CharSequence) activity.getString(R.string.you_can_wait));
                TextView textView = c4VarInflate.f26736c;
                textView.setText(spannableStringBuilder);
                TextView textView2 = c4VarInflate.f26737d;
                if (z10) {
                    c4VarInflate.f26738e.setTextSize(48.0f);
                    textView.setTextSize(36.0f);
                    textView2.setTextSize(36.0f);
                }
                textView2.setTextColor(activity.getColor(R.color.main_color));
                mVarCreate.setOnDismissListener(new m(activity, f0Var, i10));
                mVarCreate.setOnCancelListener(new k(f0Var, 1));
                if (mVarCreate.getWindow() != null) {
                    mVarCreate.getWindow().getDecorView().setPadding(0, 0, 0, 0);
                    Window window = mVarCreate.getWindow();
                    Objects.requireNonNull(window);
                    WindowManager.LayoutParams attributes = window.getAttributes();
                    attributes.width = UiUtils.dp2px(z10 ? 800.0f : 680.0f);
                    attributes.height = UiUtils.dp2px(z10 ? 460.0f : 400.0f);
                    mVarCreate.getWindow().setAttributes(attributes);
                    mVarCreate.getWindow().getDecorView().setSystemUiVisibility(6);
                    mVarCreate.getWindow().setBackgroundDrawable(new ColorDrawable(0));
                    gVar = new g(mVarCreate, c4VarInflate);
                }
            }
            this.f35238x = gVar;
        }
    }

    public final void y(SubtitlePlayEntity subtitlePlayEntity, boolean z10) {
        SubtitlePlayEntity subtitlePlayEntity2;
        ScheduledExecutorService scheduledExecutorService = this.f35226l;
        if (scheduledExecutorService != null && !scheduledExecutorService.isShutdown()) {
            m(subtitlePlayEntity);
            return;
        }
        t4.e eVarG = g("English", true);
        ArrayList arrayList = this.f35217c;
        boolean z11 = eVarG.f32949a;
        if (!z11) {
            t4.d dVarG = t4.f.x(arrayList).e(new b(this, 2)).g();
            Object subtitlePlayEntity3 = new SubtitlePlayEntity("Off", -1, null);
            Object obj = dVarG.f32947a;
            if (obj != null) {
                subtitlePlayEntity3 = obj;
            }
            subtitlePlayEntity2 = (SubtitlePlayEntity) subtitlePlayEntity3;
            if (subtitlePlayEntity2.getTitle().equals("Off")) {
                return;
            }
        } else {
            if (!z11) {
                throw new NoSuchElementException("No value present");
            }
            subtitlePlayEntity2 = (SubtitlePlayEntity) arrayList.get(eVarG.f32950b);
        }
        if (subtitlePlayEntity2.getInnerSubtitleEntity() == null) {
            return;
        }
        if (z10) {
            UiUtils.showProgressDialog(this.f35233s);
        }
        xyz.stream.api.o oVarF = xyz.stream.api.o.f();
        String name = subtitlePlayEntity2.getInnerSubtitleEntity().getName();
        int i10 = this.f35216b;
        String url = subtitlePlayEntity2.getInnerSubtitleEntity().getUrl();
        String strE = xyz.stream.utils.o.e(subtitlePlayEntity.getTitle());
        h hVar = new h(this, subtitlePlayEntity);
        oVarF.getClass();
        HashMap mapO = u1.o("original_name", name);
        mapO.put("video_id", String.valueOf(i10));
        mapO.put("turbo_url", url);
        mapO.put("target_lang", strE);
        xyz.stream.api.o.v("translation/subtitle", oVarF.n(), xyz.stream.utils.m.a(mapO), new xyz.stream.api.j(oVarF, hVar, "translation/subtitle", mapO, 7));
    }
}
