package xyz.stream.utils;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.view.Choreographer;
import android.view.View;
import androidx.core.view.f3;
import androidx.core.view.l0;
import androidx.core.view.r2;
import androidx.core.view.s1;
import androidx.core.view.v2;
import androidx.room.RoomDatabase;
import androidx.room.s0;
import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.load.EncodeStrategy;
import com.google.android.gms.internal.atv_ads_framework.d1;
import com.google.android.gms.internal.atv_ads_framework.r1;
import com.google.android.gms.measurement.internal.u1;
import com.google.android.tv.ads.controls.FallbackImageActivity;
import com.google.zxing.NotFoundException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import tv.danmaku.ijk.media.player.ui.IjkPlayerRuntime;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.view.listener.OnDialogSelectListener;

/* JADX INFO: loaded from: classes3.dex */
public final class f implements a3.o, l0, n4.t, a5.e, a5.n, com.google.android.gms.ads.mediation.customevent.b, w8.d, f9.h, wa.a, pc.f, ed.f, OnDialogSelectListener, y {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static volatile f f36130d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f36131a;

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

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

    public /* synthetic */ f(Object obj, Object obj2, int i10) {
        this.f36131a = i10;
        this.f36133c = obj;
        this.f36132b = obj2;
    }

    public static f p() {
        if (f36130d == null) {
            synchronized (f.class) {
                try {
                    if (f36130d == null) {
                        f36130d = new f(0);
                    }
                } finally {
                }
            }
        }
        return f36130d;
    }

    public final float A(int i10, int i11, int i12, int i13) {
        float f10;
        float f11;
        float fZ = z(i10, i11, i12, i13);
        int i14 = i10 - (i12 - i10);
        int i15 = 0;
        if (i14 < 0) {
            f10 = i10 / (i10 - i14);
            i14 = 0;
        } else {
            Object obj = this.f36132b;
            if (i14 >= ((tb.b) obj).f33005a) {
                float f12 = ((((tb.b) obj).f33005a - 1) - i10) / (i14 - i10);
                int i16 = ((tb.b) obj).f33005a - 1;
                f10 = f12;
                i14 = i16;
            } else {
                f10 = 1.0f;
            }
        }
        float f13 = i11;
        int i17 = (int) (f13 - ((i13 - i11) * f10));
        if (i17 < 0) {
            f11 = f13 / (i11 - i17);
        } else {
            Object obj2 = this.f36132b;
            if (i17 >= ((tb.b) obj2).f33006b) {
                f11 = ((((tb.b) obj2).f33006b - 1) - i11) / (i17 - i11);
                i15 = ((tb.b) obj2).f33006b - 1;
            } else {
                i15 = i17;
                f11 = 1.0f;
            }
        }
        return (z(i10, i11, (int) (((i14 - i10) * f11) + i10), i15) + fZ) - 1.0f;
    }

    /* JADX WARN: Removed duplicated region for block: B:45:0x00ca A[Catch: all -> 0x000e, IOException -> 0x00c6, TRY_LEAVE, TryCatch #2 {IOException -> 0x00c6, blocks: (B:41:0x00c2, B:45:0x00ca), top: B:61:0x00c2 }] */
    /* JADX WARN: Removed duplicated region for block: B:61:0x00c2 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:69:0x00a3 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void B(String str, String str2) {
        FileWriter fileWriter;
        File fileQ;
        BufferedWriter bufferedWriter;
        synchronized (f.class) {
            BufferedWriter bufferedWriter2 = null;
            try {
                try {
                    fileQ = q();
                } catch (Throwable th) {
                    th = th;
                }
            } catch (Exception e10) {
                e = e10;
                fileWriter = null;
            } catch (Throwable th2) {
                th = th2;
                fileWriter = null;
            }
            if (fileQ == null) {
                return;
            }
            fileWriter = new FileWriter(fileQ.getAbsolutePath(), true);
            try {
                bufferedWriter = new BufferedWriter(fileWriter);
            } catch (Exception e11) {
                e = e11;
            }
            try {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
                simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                String str3 = simpleDateFormat.format(Long.valueOf(System.currentTimeMillis()));
                if (str != null) {
                    bufferedWriter.write(str3 + "    " + String.format("%-12s", str) + " : " + str2 + "\n");
                } else {
                    bufferedWriter.write(str2 + "\n");
                }
                try {
                    bufferedWriter.close();
                    fileWriter.close();
                } catch (IOException e12) {
                    e = e12;
                    e.printStackTrace();
                }
            } catch (Exception e13) {
                e = e13;
                bufferedWriter2 = bufferedWriter;
                e.printStackTrace();
                if (bufferedWriter2 != null) {
                }
                if (bufferedWriter2 != null) {
                }
                if (fileWriter != null) {
                }
            } catch (Throwable th3) {
                th = th3;
                bufferedWriter2 = bufferedWriter;
                if (bufferedWriter2 != null) {
                    try {
                        bufferedWriter2.close();
                    } catch (IOException e14) {
                        e14.printStackTrace();
                        throw th;
                    }
                }
                if (fileWriter != null) {
                    fileWriter.close();
                }
                throw th;
            }
            e.printStackTrace();
            if (bufferedWriter2 != null) {
                try {
                    bufferedWriter2.write("Exception: " + e.getMessage() + "\n");
                } catch (IOException e15) {
                    e15.printStackTrace();
                }
            }
            if (bufferedWriter2 != null) {
                try {
                    bufferedWriter2.close();
                } catch (IOException e16) {
                    e = e16;
                    e.printStackTrace();
                }
            }
            if (fileWriter != null) {
                fileWriter.close();
            }
        }
    }

    public final void C() {
        ((Context) this.f36132b).startActivity(new Intent().setClassName(((Context) this.f36132b).getPackageName(), FallbackImageActivity.class.getName()).setFlags(268435456).putExtra("render_error_message", true));
    }

    @Override // a5.e
    public final int d(a5.c cVar) throws Throwable {
        com.bumptech.glide.load.resource.bitmap.a aVar;
        com.bumptech.glide.load.resource.bitmap.a aVar2 = null;
        try {
            aVar = new com.bumptech.glide.load.resource.bitmap.a(new FileInputStream(((com.bumptech.glide.load.data.n) this.f36132b).a().getFileDescriptor()), (c5.b) this.f36133c);
        } catch (Throwable th) {
            th = th;
        }
        try {
            int iD = cVar.d(aVar, (c5.b) this.f36133c);
            try {
                aVar.close();
            } catch (IOException unused) {
            }
            ((com.bumptech.glide.load.data.n) this.f36132b).a();
            return iD;
        } catch (Throwable th2) {
            th = th2;
            aVar2 = aVar;
            if (aVar2 != null) {
                try {
                    aVar2.close();
                } catch (IOException unused2) {
                }
            }
            ((com.bumptech.glide.load.data.n) this.f36132b).a();
            throw th;
        }
    }

    @Override // pc.f
    public final void f(String str, HashMap map) {
        ((ed.t) this.f36132b).error("sqlite_error", str, map);
    }

    public final void h(String str, int[] iArr) {
        ((List) this.f36132b).add(iArr);
        ((List) this.f36133c).add(str);
    }

    @Override // androidx.core.view.l0
    public final f3 i(View view, f3 f3Var) {
        f3 f3VarF = s1.f(view, f3Var);
        if (f3VarF.f1747a.m()) {
            return f3VarF;
        }
        Rect rect = (Rect) this.f36132b;
        rect.left = f3VarF.b();
        rect.top = f3VarF.d();
        rect.right = f3VarF.c();
        rect.bottom = f3VarF.a();
        int childCount = ((ViewPager) this.f36133c).getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            f3 f3VarB = s1.b(((ViewPager) this.f36133c).getChildAt(i10), f3VarF);
            rect.left = Math.min(f3VarB.b(), rect.left);
            rect.top = Math.min(f3VarB.d(), rect.top);
            rect.right = Math.min(f3VarB.c(), rect.right);
            rect.bottom = Math.min(f3VarB.a(), rect.bottom);
        }
        int i11 = rect.left;
        int i12 = rect.top;
        int i13 = rect.right;
        int i14 = rect.bottom;
        r2 r2Var = new r2(f3VarF);
        j0.d dVarB = j0.d.b(i11, i12, i13, i14);
        v2 v2Var = r2Var.f1814a;
        v2Var.f(dVarB);
        return v2Var.b();
    }

    public final float j(jc.c cVar, jc.c cVar2) {
        int i10 = (int) cVar.f31472a;
        int i11 = (int) cVar.f31473b;
        int i12 = (int) cVar2.f31472a;
        int i13 = (int) cVar2.f31473b;
        float fA = A(i10, i11, i12, i13);
        float fA2 = A((int) cVar2.f31472a, i13, (int) cVar.f31472a, i11);
        return Float.isNaN(fA) ? fA2 / 7.0f : Float.isNaN(fA2) ? fA / 7.0f : (fA + fA2) / 14.0f;
    }

    @Override // a5.n
    public final EncodeStrategy k(a5.l lVar) {
        return ((a5.n) this.f36133c).k(lVar);
    }

    public final jc.a l(float f10, int i10, float f11, int i11) throws NotFoundException {
        tb.b bVar;
        jc.a aVarB;
        jc.a aVarB2;
        int i12 = (int) (f11 * f10);
        int iMax = Math.max(0, i10 - i12);
        int iMin = Math.min(((tb.b) this.f36132b).f33005a - 1, i10 + i12) - iMax;
        float f12 = 3.0f * f10;
        if (iMin < f12) {
            throw NotFoundException.a();
        }
        int iMax2 = Math.max(0, i11 - i12);
        int iMin2 = Math.min(((tb.b) this.f36132b).f33006b - 1, i11 + i12) - iMax2;
        if (iMin2 < f12) {
            throw NotFoundException.a();
        }
        jc.b bVar2 = new jc.b((tb.b) this.f36132b, iMax, iMax2, iMin, iMin2, f10, (ob.h) this.f36133c);
        int i13 = bVar2.f28773e;
        int i14 = bVar2.f28771c;
        int i15 = i13 + i14;
        int i16 = bVar2.f28774f;
        int i17 = (i16 / 2) + bVar2.f28772d;
        int[] iArr = new int[3];
        for (int i18 = 0; i18 < i16; i18++) {
            int i19 = ((i18 & 1) == 0 ? (i18 + 1) / 2 : -((i18 + 1) / 2)) + i17;
            iArr[0] = 0;
            iArr[1] = 0;
            iArr[2] = 0;
            int i20 = i14;
            while (true) {
                bVar = bVar2.f28769a;
                if (i20 >= i15 || bVar.b(i20, i19)) {
                    break;
                }
                i20++;
            }
            int i21 = 0;
            while (i20 < i15) {
                if (!bVar.b(i20, i19)) {
                    if (i21 == 1) {
                        i21++;
                    }
                    iArr[i21] = iArr[i21] + 1;
                } else if (i21 == 1) {
                    iArr[1] = iArr[1] + 1;
                } else if (i21 != 2) {
                    i21++;
                    iArr[i21] = iArr[i21] + 1;
                } else {
                    if (bVar2.a(iArr) && (aVarB2 = bVar2.b(i19, i20, iArr)) != null) {
                        return aVarB2;
                    }
                    iArr[0] = iArr[2];
                    iArr[1] = 1;
                    iArr[2] = 0;
                    i21 = 1;
                }
                i20++;
            }
            if (bVar2.a(iArr) && (aVarB = bVar2.b(i19, i15, iArr)) != null) {
                return aVarB;
            }
        }
        ArrayList arrayList = bVar2.f28770b;
        if (arrayList.isEmpty()) {
            throw NotFoundException.a();
        }
        return (jc.a) arrayList.get(0);
    }

    @Override // a5.a
    public final boolean m(Object obj, File file, a5.l lVar) {
        return ((a5.n) this.f36133c).m(new j5.d(((BitmapDrawable) ((com.bumptech.glide.load.engine.e0) obj).get()).getBitmap(), (c5.e) this.f36132b), file, lVar);
    }

    @Override // xyz.stream.utils.y
    public final void n(String str) {
        try {
            ((xyz.stream.api.e) this.f36132b).onSuccess((BaseEntity) m.f36162a.fromJson(str, BaseEntity.class));
        } catch (Exception e10) {
            ((xyz.stream.api.e) this.f36132b).a(e10.getMessage());
        }
    }

    public final tb.b o() {
        if (((tb.b) this.f36133c) == null) {
            this.f36133c = ((o0.i) this.f36132b).i();
        }
        return (tb.b) this.f36133c;
    }

    @Override // xyz.stream.view.listener.OnDialogSelectListener
    public final void onCancelClick() {
        switch (this.f36131a) {
            case 22:
                super.onCancelClick();
                ((me.c) this.f36133c).d();
                break;
            default:
                super.onCancelClick();
                ((ve.v) this.f36133c).p();
                break;
        }
    }

    @Override // w8.d
    public final void onComplete(w8.h hVar) {
        ((com.google.android.gms.common.api.internal.w) this.f36133c).f8298b.remove((w8.i) this.f36132b);
    }

    @Override // xyz.stream.view.listener.OnDialogSelectListener
    public final void onItemSelected(int i10) {
        switch (this.f36131a) {
            case 22:
                int iIntValue = ((Integer[]) ((Map) this.f36132b).keySet().toArray(new Integer[0]))[i10].intValue();
                f0.o().v(iIntValue, IjkPlayerRuntime.SP_VOD_VIDEO_RATIO);
                ((me.c) this.f36133c).f30661d.setResizeMode(iIntValue);
                break;
            default:
                int iIntValue2 = ((Integer[]) ((Map) this.f36132b).keySet().toArray(new Integer[0]))[i10].intValue();
                f0.o().v(iIntValue2, "sp_live_video_ratio");
                ((ve.v) this.f36133c).f33925e.setResizeMode(iIntValue2);
                ((ve.v) this.f36133c).f33922b.getRatioText().setText((CharSequence) ((Map) this.f36132b).get(Integer.valueOf(iIntValue2)));
                ((ve.v) this.f36133c).p();
                break;
        }
    }

    @Override // ed.f
    public final void onMessage(ByteBuffer byteBuffer, ed.g gVar) {
        try {
            ((ed.s) this.f36132b).onMethodCall(((ed.u) this.f36133c).f25848c.b(byteBuffer), new dd.a0(this, gVar, 1));
        } catch (RuntimeException e10) {
            Object obj = this.f36133c;
            String str = ((ed.u) obj).f25847b;
            gVar.reply(((ed.u) obj).f25848c.encodeErrorEnvelopeWithStacktrace(IjkMediaPlayer.OnNativeInvokeListener.ARG_ERROR, e10.getMessage(), null, wc.c.getStackTraceString(e10)));
        }
    }

    public final File q() throws IOException {
        if (((Context) this.f36132b) == null) {
            return null;
        }
        String str = ((Context) this.f36132b).getCacheDir().getAbsolutePath() + "/logs";
        File file = new File(str);
        if (!file.exists()) {
            file.mkdirs();
        }
        File file2 = new File(defpackage.e.o(u.a.c(str), File.separator, "video.log"));
        if (file2.exists() && file2.length() > 4194304) {
            file2.delete();
        }
        if (!file2.exists()) {
            file2.createNewFile();
        }
        return file2;
    }

    @Override // xyz.stream.utils.y
    public final void r(Exception exc) {
    }

    public final synchronized List s(String str) {
        List arrayList;
        try {
            if (!((List) this.f36132b).contains(str)) {
                ((List) this.f36132b).add(str);
            }
            arrayList = (List) ((Map) this.f36133c).get(str);
            if (arrayList == null) {
                arrayList = new ArrayList();
                ((Map) this.f36133c).put(str, arrayList);
            }
        } catch (Throwable th) {
            throw th;
        }
        return arrayList;
    }

    @Override // pc.f
    public final void success(Object obj) {
        ((ed.t) this.f36132b).success(obj);
    }

    public final synchronized ArrayList t(Class cls, Class cls2) {
        ArrayList arrayList;
        arrayList = new ArrayList();
        Iterator it = ((List) this.f36132b).iterator();
        while (it.hasNext()) {
            List<p5.e> list = (List) ((Map) this.f36133c).get((String) it.next());
            if (list != null) {
                for (p5.e eVar : list) {
                    if (eVar.f31634a.isAssignableFrom(cls) && cls2.isAssignableFrom(eVar.f31635b) && !arrayList.contains(eVar.f31635b)) {
                        arrayList.add(eVar.f31635b);
                    }
                }
            }
        }
        return arrayList;
    }

    public final String toString() {
        switch (this.f36131a) {
            case 17:
                try {
                    return o().toString();
                } catch (NotFoundException unused) {
                    return "";
                }
            default:
                return super.toString();
        }
    }

    public final ArrayList u(String str) {
        s0 s0VarK = s0.k(1, "SELECT DISTINCT tag FROM worktag WHERE work_spec_id=?");
        if (str == null) {
            s0VarK.d(1);
        } else {
            s0VarK.l(1, str);
        }
        ((RoomDatabase) this.f36132b).assertNotSuspendingTransaction();
        Cursor cursorC = androidx.room.util.b.c((RoomDatabase) this.f36132b, s0VarK);
        try {
            ArrayList arrayList = new ArrayList(cursorC.getCount());
            while (cursorC.moveToNext()) {
                arrayList.add(cursorC.getString(0));
            }
            return arrayList;
        } finally {
            cursorC.close();
            s0VarK.m();
        }
    }

    public final void v(aa.k kVar) {
        String staticResourceUri;
        String queryParameter;
        List list = kVar.f411a;
        Iterator it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                staticResourceUri = null;
                break;
            }
            aa.d dVar = (aa.d) it.next();
            String staticResourceUri2 = dVar.getStaticResourceUri();
            if (staticResourceUri2 != null && (queryParameter = Uri.parse(staticResourceUri2).getQueryParameter("atvatc")) != null && queryParameter.equals("1")) {
                staticResourceUri = dVar.getStaticResourceUri();
                break;
            }
        }
        if (staticResourceUri == null) {
            if (!list.isEmpty()) {
                u1.x(this.f36133c);
                ((Context) this.f36132b).startActivity(new Intent().setClassName(((Context) this.f36132b).getPackageName(), FallbackImageActivity.class.getName()).setFlags(268435456).putExtra("icon_click_fallback_images", kVar));
                return;
            }
            d1 d1VarS = d1.s((Context) this.f36132b);
            r1 r1VarM = com.google.android.gms.internal.atv_ads_framework.s1.m();
            r1VarM.d();
            r1VarM.f(2);
            r1VarM.e(6);
            d1VarS.t((com.google.android.gms.internal.atv_ads_framework.s1) r1VarM.a());
            C();
            return;
        }
        try {
            Intent intentPutExtra = new Intent().setAction("com.google.android.tv.ads.intent.action.LAUNCH_ATC_MENU").setFlags(268435456).putExtra("extra_atc_uri", staticResourceUri).putExtra("extra_publisher_package", ((Context) this.f36132b).getPackageName());
            int iOrdinal = com.bumptech.glide.g.w((Context) this.f36132b).ordinal();
            if (iOrdinal != 0) {
                if (iOrdinal == 1) {
                    d1 d1VarS2 = d1.s((Context) this.f36132b);
                    r1 r1VarM2 = com.google.android.gms.internal.atv_ads_framework.s1.m();
                    r1VarM2.d();
                    r1VarM2.f(3);
                    d1VarS2.t((com.google.android.gms.internal.atv_ads_framework.s1) r1VarM2.a());
                    ((Context) this.f36132b).startActivity(intentPutExtra.setPackage("com.google.android.apps.tv.launcherx"));
                    return;
                }
                if (iOrdinal != 2) {
                    if (iOrdinal == 3 || iOrdinal == 4 || iOrdinal == 5) {
                        d1 d1VarS3 = d1.s((Context) this.f36132b);
                        r1 r1VarM3 = com.google.android.gms.internal.atv_ads_framework.s1.m();
                        r1VarM3.d();
                        r1VarM3.f(3);
                        r1VarM3.e(3);
                        d1VarS3.t((com.google.android.gms.internal.atv_ads_framework.s1) r1VarM3.a());
                        C();
                        return;
                    }
                    return;
                }
            }
            d1 d1VarS4 = d1.s((Context) this.f36132b);
            r1 r1VarM4 = com.google.android.gms.internal.atv_ads_framework.s1.m();
            r1VarM4.d();
            r1VarM4.f(3);
            d1VarS4.t((com.google.android.gms.internal.atv_ads_framework.s1) r1VarM4.a());
            ((Context) this.f36132b).startActivity(intentPutExtra.setPackage("com.google.android.tvrecommendations"));
        } catch (ActivityNotFoundException unused) {
            d1 d1VarS5 = d1.s((Context) this.f36132b);
            r1 r1VarM5 = com.google.android.gms.internal.atv_ads_framework.s1.m();
            r1VarM5.d();
            r1VarM5.f(3);
            r1VarM5.e(2);
            d1VarS5.t((com.google.android.gms.internal.atv_ads_framework.s1) r1VarM5.a());
            C();
        }
    }

    public final void w(String str) {
        d5.d dVar;
        synchronized (this) {
            try {
                dVar = (d5.d) t5.n.checkNotNull(((Map) this.f36132b).get(str));
                int i10 = dVar.f24986b;
                if (i10 < 1) {
                    throw new IllegalStateException("Cannot release a lock that is not held, safeKey: " + str + ", interestedThreads: " + dVar.f24986b);
                }
                int i11 = i10 - 1;
                dVar.f24986b = i11;
                if (i11 == 0) {
                    d5.d dVar2 = (d5.d) ((Map) this.f36132b).remove(str);
                    if (!dVar2.equals(dVar)) {
                        throw new IllegalStateException("Removed the wrong lock, expected to remove: " + dVar + ", but actually removed: " + dVar2 + ", safeKey: " + str);
                    }
                    a0 a0Var = (a0) this.f36133c;
                    synchronized (((Queue) a0Var.f36098a)) {
                        try {
                            if (((Queue) a0Var.f36098a).size() < 10) {
                                ((Queue) a0Var.f36098a).offer(dVar2);
                            }
                        } finally {
                        }
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        dVar.f24985a.unlock();
    }

    public final void x(String str) {
        y("XyzStream", str);
    }

    public final void y(String str, String str2) {
        ((ExecutorService) this.f36133c).execute(new androidx.emoji2.text.v(this, str, str2, 25));
    }

    /* JADX WARN: Code restructure failed: missing block: B:40:0x0088, code lost:
    
        if (r15 != r0) goto L43;
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x0090, code lost:
    
        return nb.g.s(r19, r6, r1, r4);
     */
    /* JADX WARN: Code restructure failed: missing block: B:43:0x0091, code lost:
    
        return Float.NaN;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final float z(int i10, int i11, int i12, int i13) {
        int i14;
        int i15;
        int i16;
        int i17;
        int i18;
        int i19;
        f fVar;
        boolean z10;
        int i20;
        int i21 = 1;
        boolean z11 = Math.abs(i13 - i11) > Math.abs(i12 - i10);
        if (z11) {
            i15 = i10;
            i14 = i11;
            i17 = i12;
            i16 = i13;
        } else {
            i14 = i10;
            i15 = i11;
            i16 = i12;
            i17 = i13;
        }
        int iAbs = Math.abs(i16 - i14);
        int iAbs2 = Math.abs(i17 - i15);
        int i22 = 2;
        int i23 = (-iAbs) / 2;
        int i24 = i14 < i16 ? 1 : -1;
        int i25 = i15 < i17 ? 1 : -1;
        int i26 = i16 + i24;
        int i27 = i14;
        int i28 = i15;
        int i29 = 0;
        while (true) {
            if (i27 == i26) {
                i18 = i26;
                i19 = i22;
                break;
            }
            int i30 = z11 ? i28 : i27;
            int i31 = z11 ? i27 : i28;
            if (i29 == i21) {
                z10 = z11;
                i20 = i21;
                i18 = i26;
                fVar = this;
            } else {
                fVar = this;
                z10 = z11;
                i18 = i26;
                i20 = 0;
            }
            if (i20 == ((tb.b) fVar.f36132b).b(i30, i31)) {
                if (i29 == 2) {
                    return nb.g.s(i27, i28, i14, i15);
                }
                i29++;
            }
            i23 += iAbs2;
            if (i23 > 0) {
                if (i28 == i17) {
                    i19 = 2;
                    break;
                }
                i28 += i25;
                i23 -= iAbs;
            }
            i27 += i24;
            i26 = i18;
            z11 = z10;
            i21 = 1;
            i22 = 2;
        }
    }

    public /* synthetic */ f(Object obj, Object obj2, int i10, int i11) {
        this.f36131a = i10;
        this.f36132b = obj;
        this.f36133c = obj2;
    }

    public f(Context context) {
        this.f36131a = 14;
        context.getClass();
        this.f36132b = context;
    }

    public f(RoomDatabase roomDatabase) {
        this.f36131a = 5;
        this.f36132b = roomDatabase;
        this.f36133c = new n4.c(this, roomDatabase, 6);
    }

    public f(int i10) {
        this.f36131a = i10;
        if (i10 == 1) {
            this.f36132b = Choreographer.getInstance();
            this.f36133c = Looper.myLooper();
            return;
        }
        if (i10 != 2) {
            int i11 = 9;
            if (i10 == 7) {
                this.f36132b = new HashMap();
                this.f36133c = new a0(i11);
                return;
            }
            if (i10 == 18) {
                this.f36132b = new ArrayList();
                this.f36133c = new ArrayList();
            } else if (i10 == 9) {
                this.f36132b = new ArrayList();
                this.f36133c = new HashMap();
            } else if (i10 != 10) {
                this.f36133c = Executors.newFixedThreadPool(5);
                this.f36132b = e.d().f36112a;
            } else {
                this.f36133c = new HashMap();
            }
        }
    }

    public f(o0.i iVar) {
        this.f36131a = 17;
        if (iVar == null) {
            throw new IllegalArgumentException("Binarizer must be non-null.");
        }
        this.f36132b = iVar;
    }

    public f(tb.b bVar) {
        this.f36131a = 19;
        this.f36132b = bVar;
    }

    public f(Context context, String str, String str2) {
        this.f36131a = 15;
        if (str != null) {
            this.f36133c = str;
            Context applicationContext = context.getApplicationContext();
            if (str2 == null) {
                this.f36132b = PreferenceManager.getDefaultSharedPreferences(applicationContext).edit();
                return;
            } else {
                this.f36132b = applicationContext.getSharedPreferences(str2, 0).edit();
                return;
            }
        }
        throw new IllegalArgumentException("keysetName cannot be null");
    }

    public f(ViewPager viewPager) {
        this.f36131a = 4;
        this.f36133c = viewPager;
        this.f36132b = new Rect();
    }
}
