package kotlinx.coroutines.flow;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.SystemClock;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.exoplayer.upstream.CmcdData;
import ie.l3;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.NetworkInterface;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Objects;
import java.util.TimeZone;
import java.util.concurrent.CancellationException;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Ref$ObjectRef;
import kotlinx.coroutines.flow.internal.AbortFlowException;
import org.drive_hunter.R;
import xyz.stream.utils.f0;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes.dex */
public abstract class h {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static long f29371a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static long f29372b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final la.e f29373c = new la.e("NO_VALUE");

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final la.e f29374d = new la.e("NONE");

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final la.e f29375e = new la.e("PENDING");

    public static String A() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US).format(Long.valueOf(System.currentTimeMillis()));
    }

    public static String B(long j10) {
        long j11 = j10 / 3600000;
        long j12 = (j10 % 3600000) / 60000;
        double d10 = (j10 % 60000) / 1000.0d;
        return j11 == 0 ? j12 == 0 ? String.format(Locale.US, "%.2fs", Double.valueOf(d10)) : String.format(Locale.US, "%02dm%.2fs", Long.valueOf(j12), Double.valueOf(d10)) : String.format(Locale.US, "%02dh%02dm%.2fs", Long.valueOf(j11), Long.valueOf(j12), Double.valueOf(d10));
    }

    public static String C() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US).format(Long.valueOf(SystemClock.uptimeMillis()));
    }

    public static String D() {
        int offset = TimeZone.getDefault().getOffset(System.currentTimeMillis());
        return String.format(Locale.getDefault(), "%s%02d:%02d", offset >= 0 ? "+" : "-", Integer.valueOf(Math.abs(offset / 3600000)), Integer.valueOf(Math.abs(Math.abs((offset / 60000) % 60))));
    }

    public static boolean E(String str, String str2) {
        if (str == null || str.isEmpty() || str2 == null || str2.isEmpty()) {
            return false;
        }
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
            Date date = simpleDateFormat.parse(str);
            Date date2 = simpleDateFormat.parse(str2);
            if (date == null || date2 == null) {
                return false;
            }
            return date.after(date2);
        } catch (Exception e10) {
            u.a.g(e10, new StringBuilder("isAfter error: "));
            return false;
        }
    }

    public static boolean F(long j10) {
        if (j10 <= 0) {
            return false;
        }
        Calendar calendar = Calendar.getInstance();
        Calendar calendar2 = Calendar.getInstance();
        calendar2.setTimeInMillis(j10);
        return calendar.get(1) == calendar2.get(1) && calendar.get(2) == calendar2.get(2) && calendar.get(5) == calendar2.get(5);
    }

    public static boolean G(String str) {
        if (str != null && !str.isEmpty()) {
            try {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
                simpleDateFormat.setTimeZone(TimeZone.getDefault());
                Date date = simpleDateFormat.parse(str);
                if (date == null) {
                    return false;
                }
                long time = date.getTime();
                Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
                Calendar calendar2 = Calendar.getInstance(TimeZone.getDefault());
                calendar2.setTimeInMillis(time);
                if (calendar.get(1) == calendar2.get(1) && calendar.get(2) == calendar2.get(2)) {
                    return calendar.get(5) == calendar2.get(5);
                }
                return false;
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("isToday parse error: "));
            }
        }
        return false;
    }

    public static void H(Activity activity) {
        try {
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://t.me/Netfly_Community"));
            intent.addFlags(268435456);
            activity.startActivity(intent);
        } catch (Exception e10) {
            xyz.stream.utils.h.c(e10.getMessage());
        }
    }

    public static String I(String str) {
        try {
            byte[] bArrDigest = MessageDigest.getInstance("MD5").digest(str.getBytes());
            StringBuilder sb = new StringBuilder();
            for (byte b10 : bArrDigest) {
                sb.append(String.format("%02x", Integer.valueOf(b10 & 255)));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e10) {
            e10.printStackTrace();
            return null;
        }
    }

    public static final Object J(Object obj, Object obj2) {
        if (obj == null) {
            return obj2;
        }
        if (obj instanceof ArrayList) {
            ((ArrayList) obj).add(obj2);
            return obj;
        }
        ArrayList arrayList = new ArrayList(4);
        arrayList.add(obj);
        arrayList.add(obj2);
        return arrayList;
    }

    public static String K(File file) {
        BufferedReader bufferedReader;
        StringBuilder sb;
        boolean z10;
        if (file != null && file.exists()) {
            try {
                bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
                try {
                    sb = new StringBuilder((int) Math.min(file.length(), 2147483647L));
                    z10 = true;
                } finally {
                }
            } catch (IOException e10) {
                xyz.stream.utils.h.c("readFile error: " + e10.getMessage());
            }
            while (true) {
                String line = bufferedReader.readLine();
                if (line == null) {
                    String string = sb.toString();
                    bufferedReader.close();
                    return string;
                }
                if (!z10) {
                    sb.append('\n');
                }
                sb.append(line);
                z10 = false;
                xyz.stream.utils.h.c("readFile error: " + e10.getMessage());
            }
        }
        return "";
    }

    public static void L(String str, LinkedHashSet linkedHashSet) {
        StringBuilder sb = new StringBuilder();
        Iterator it = linkedHashSet.iterator();
        while (it.hasNext()) {
            String str2 = (String) it.next();
            if (sb.length() > 0) {
                sb.append(',');
            }
            sb.append(str2);
        }
        f0.o().w(str, sb.toString());
    }

    public static void M(AppCompatActivity appCompatActivity, le.a aVar) {
        if (appCompatActivity.isFinishing() || appCompatActivity.isDestroyed()) {
            return;
        }
        l3 l3VarInflate = l3.inflate(LayoutInflater.from(appCompatActivity), null, false);
        e.l lVar = new e.l(appCompatActivity, R.style.CustomDialogDownload);
        lVar.setView(l3VarInflate.f27176a);
        int i10 = 1;
        lVar.f25255a.f25211k = true;
        e.m mVarCreate = lVar.create();
        mVarCreate.show();
        if (mVarCreate.getWindow() == null) {
            return;
        }
        mVarCreate.getWindow().getDecorView().setPadding(0, 0, 0, 0);
        l3VarInflate.f27179d.setText(appCompatActivity.getString(R.string.open_download_tip));
        Window window = mVarCreate.getWindow();
        Objects.requireNonNull(window);
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.width = ((int) UiUtils.getScreenWidth(appCompatActivity)) - UiUtils.dp2px(280.0f);
        attributes.height = -2;
        mVarCreate.getWindow().setAttributes(attributes);
        mVarCreate.getWindow().getDecorView().setSystemUiVisibility(6);
        mVarCreate.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        l3VarInflate.f27177b.setOnClickListener(new xyz.netfly.mobile.view.o(mVarCreate, i10));
        l3VarInflate.f27178c.setOnClickListener(new xyz.netfly.ads.i(mVarCreate, aVar, 2));
    }

    public static void N(Function2 function2, kotlinx.coroutines.a aVar, Continuation continuation) {
        try {
            kotlinx.coroutines.internal.a.d(nb.g.F(nb.g.q(aVar, continuation, function2)), kd.e.f29109a, null);
        } catch (Throwable th) {
            continuation.resumeWith(kotlin.a.b(th));
            throw th;
        }
    }

    public static final long O(String str, long j10, long j11, long j12) {
        String property;
        boolean z10;
        String str2;
        Long lValueOf;
        int i10 = kotlinx.coroutines.internal.u.f29489a;
        try {
            property = System.getProperty(str);
        } catch (SecurityException unused) {
            property = null;
        }
        if (property == null) {
            return j10;
        }
        ua.b.e(10);
        int length = property.length();
        if (length == 0) {
            str2 = property;
            lValueOf = null;
            break;
        }
        int i11 = 0;
        char cCharAt = property.charAt(0);
        long j13 = -9223372036854775807L;
        if (nb.g.j(cCharAt, 48) < 0) {
            z10 = true;
            if (length != 1) {
                if (cCharAt == '-') {
                    j13 = Long.MIN_VALUE;
                    i11 = 1;
                } else if (cCharAt == '+') {
                    z10 = false;
                    i11 = 1;
                }
            }
            str2 = property;
            lValueOf = null;
            break;
        }
        z10 = false;
        long j14 = 0;
        long j15 = -256204778801521550L;
        while (i11 < length) {
            int iDigit = Character.digit((int) property.charAt(i11), 10);
            if (iDigit >= 0) {
                if (j14 >= j15) {
                    str2 = property;
                } else if (j15 == -256204778801521550L) {
                    str2 = property;
                    j15 = j13 / ((long) 10);
                    if (j14 < j15) {
                    }
                    lValueOf = null;
                    break;
                }
                long j16 = j14 * ((long) 10);
                long j17 = iDigit;
                if (j16 < j13 + j17) {
                    lValueOf = null;
                    break;
                }
                j14 = j16 - j17;
                i11++;
                property = str2;
            }
            str2 = property;
            lValueOf = null;
            break;
        }
        str2 = property;
        lValueOf = z10 ? Long.valueOf(j14) : Long.valueOf(-j14);
        if (lValueOf == null) {
            throw new IllegalStateException(("System property '" + str + "' has unrecognized value '" + str2 + '\'').toString());
        }
        long jLongValue = lValueOf.longValue();
        if (j11 <= jLongValue && jLongValue <= j12) {
            return jLongValue;
        }
        StringBuilder sb = new StringBuilder("System property '");
        sb.append(str);
        sb.append("' should be in range ");
        sb.append(j11);
        defpackage.e.B(sb, "..", j12, ", but is '");
        sb.append(jLongValue);
        sb.append('\'');
        throw new IllegalStateException(sb.toString().toString());
    }

    public static int P(String str, int i10, int i11, int i12, int i13) {
        if ((i13 & 4) != 0) {
            i11 = 1;
        }
        if ((i13 & 8) != 0) {
            i12 = Integer.MAX_VALUE;
        }
        return (int) O(str, i10, i11, i12);
    }

    public static LinkedHashSet Q(LinkedHashSet linkedHashSet) {
        LinkedHashSet linkedHashSet2 = new LinkedHashSet();
        Iterator it = linkedHashSet.iterator();
        while (it.hasNext()) {
            try {
                linkedHashSet2.add(Integer.valueOf(Integer.parseInt((String) it.next())));
            } catch (NumberFormatException unused) {
            }
        }
        return linkedHashSet2;
    }

    public static void R(File file, String str) {
        try {
            if (!file.exists() && !file.createNewFile()) {
                xyz.stream.utils.h.c("Failed to create file: " + file.getAbsolutePath());
            } else {
                FileWriter fileWriter = new FileWriter(file);
                fileWriter.write(str);
                fileWriter.flush();
                fileWriter.close();
            }
        } catch (IOException e10) {
            e10.printStackTrace();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object a(x xVar, sd.p pVar, Throwable th, Continuation continuation) {
        FlowKt__EmittersKt$invokeSafely$1 flowKt__EmittersKt$invokeSafely$1;
        if (continuation instanceof FlowKt__EmittersKt$invokeSafely$1) {
            flowKt__EmittersKt$invokeSafely$1 = (FlowKt__EmittersKt$invokeSafely$1) continuation;
            int i10 = flowKt__EmittersKt$invokeSafely$1.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                flowKt__EmittersKt$invokeSafely$1.label = i10 - Integer.MIN_VALUE;
            } else {
                flowKt__EmittersKt$invokeSafely$1 = new FlowKt__EmittersKt$invokeSafely$1(continuation);
            }
        }
        Object obj = flowKt__EmittersKt$invokeSafely$1.result;
        Object obj2 = CoroutineSingletons.f29226a;
        int i11 = flowKt__EmittersKt$invokeSafely$1.label;
        try {
            if (i11 == 0) {
                kotlin.a.d(obj);
                flowKt__EmittersKt$invokeSafely$1.L$0 = th;
                flowKt__EmittersKt$invokeSafely$1.label = 1;
                if (pVar.a(xVar, th, flowKt__EmittersKt$invokeSafely$1) == obj2) {
                    return obj2;
                }
            } else {
                if (i11 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                th = (Throwable) flowKt__EmittersKt$invokeSafely$1.L$0;
                kotlin.a.d(obj);
            }
            return kd.e.f29109a;
        } catch (Throwable th2) {
            if (th != null && th != th2) {
                kotlin.a.a(th2, th);
            }
            throw th2;
        }
    }

    public static final void b(Object[] objArr, long j10, Object obj) {
        objArr[((int) j10) & (objArr.length - 1)] = obj;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x0039 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void c(Context context, String str, String str2) {
        FileOutputStream fileOutputStream;
        byte[] bArr;
        try {
            InputStream inputStreamOpen = context.getAssets().open(str);
            try {
                fileOutputStream = new FileOutputStream(str2);
                try {
                    bArr = new byte[1024];
                } finally {
                }
            } finally {
            }
            while (true) {
                int i10 = inputStreamOpen.read(bArr);
                if (i10 <= 0) {
                    new File(str2);
                    fileOutputStream.close();
                    inputStreamOpen.close();
                    return;
                }
                fileOutputStream.write(bArr, 0, i10);
            }
        } catch (IOException e10) {
            xyz.stream.utils.h.b("assetsToFile error: " + e10.getMessage());
        }
    }

    public static void d(View view) {
        if (view == null) {
            return;
        }
        view.setHapticFeedbackEnabled(true);
        view.performHapticFeedback(1);
    }

    public static void e(File file) {
        File[] fileArrListFiles;
        if (file.isDirectory() && (fileArrListFiles = file.listFiles()) != null) {
            for (File file2 : fileArrListFiles) {
                e(file2);
            }
        }
        file.delete();
    }

    /* JADX WARN: Removed duplicated region for block: B:27:0x0075 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0076  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0082 A[Catch: all -> 0x003b, TryCatch #0 {all -> 0x003b, blocks: (B:13:0x0035, B:25:0x0065, B:29:0x007a, B:31:0x0082, B:33:0x0088, B:35:0x008e, B:38:0x009f, B:39:0x00a7, B:40:0x00a8, B:41:0x00b3, B:20:0x0054, B:24:0x005f), top: B:58:0x0021 }] */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00b4  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:36:0x009c -> B:14:0x0038). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object f(g gVar, kotlinx.coroutines.channels.k kVar, boolean z10, Continuation continuation) throws Throwable {
        FlowKt__ChannelsKt$emitAllImpl$1 flowKt__ChannelsKt$emitAllImpl$1;
        kotlinx.coroutines.channels.a it;
        kotlinx.coroutines.channels.m mVar;
        kotlinx.coroutines.channels.a aVar;
        g gVar2;
        kotlinx.coroutines.channels.m mVar2;
        Object objB;
        if (continuation instanceof FlowKt__ChannelsKt$emitAllImpl$1) {
            flowKt__ChannelsKt$emitAllImpl$1 = (FlowKt__ChannelsKt$emitAllImpl$1) continuation;
            int i10 = flowKt__ChannelsKt$emitAllImpl$1.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                flowKt__ChannelsKt$emitAllImpl$1.label = i10 - Integer.MIN_VALUE;
            } else {
                flowKt__ChannelsKt$emitAllImpl$1 = new FlowKt__ChannelsKt$emitAllImpl$1(continuation);
            }
        }
        Object obj = flowKt__ChannelsKt$emitAllImpl$1.result;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        int i11 = flowKt__ChannelsKt$emitAllImpl$1.label;
        try {
            if (i11 == 0) {
                kotlin.a.d(obj);
                if (gVar instanceof x) {
                    throw ((x) gVar).f29431a;
                }
                it = kVar.f29342d.iterator();
                mVar2 = kVar;
                flowKt__ChannelsKt$emitAllImpl$1.L$0 = gVar;
                flowKt__ChannelsKt$emitAllImpl$1.L$1 = mVar2;
                flowKt__ChannelsKt$emitAllImpl$1.L$2 = it;
                flowKt__ChannelsKt$emitAllImpl$1.Z$0 = z10;
                flowKt__ChannelsKt$emitAllImpl$1.label = 1;
                objB = it.b(flowKt__ChannelsKt$emitAllImpl$1);
                if (objB == coroutineSingletons) {
                }
            } else if (i11 == 1) {
                z10 = flowKt__ChannelsKt$emitAllImpl$1.Z$0;
                aVar = (kotlinx.coroutines.channels.a) flowKt__ChannelsKt$emitAllImpl$1.L$2;
                kotlinx.coroutines.channels.m mVar3 = (kotlinx.coroutines.channels.m) flowKt__ChannelsKt$emitAllImpl$1.L$1;
                gVar2 = (g) flowKt__ChannelsKt$emitAllImpl$1.L$0;
                kotlin.a.d(obj);
                mVar = mVar3;
                if (!((Boolean) obj).booleanValue()) {
                }
            } else {
                if (i11 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                z10 = flowKt__ChannelsKt$emitAllImpl$1.Z$0;
                aVar = (kotlinx.coroutines.channels.a) flowKt__ChannelsKt$emitAllImpl$1.L$2;
                kotlinx.coroutines.channels.m mVar4 = (kotlinx.coroutines.channels.m) flowKt__ChannelsKt$emitAllImpl$1.L$1;
                gVar2 = (g) flowKt__ChannelsKt$emitAllImpl$1.L$0;
                kotlin.a.d(obj);
                kotlinx.coroutines.channels.m mVar5 = mVar4;
                it = aVar;
                gVar = gVar2;
                mVar2 = mVar5;
                flowKt__ChannelsKt$emitAllImpl$1.L$0 = gVar;
                flowKt__ChannelsKt$emitAllImpl$1.L$1 = mVar2;
                flowKt__ChannelsKt$emitAllImpl$1.L$2 = it;
                flowKt__ChannelsKt$emitAllImpl$1.Z$0 = z10;
                flowKt__ChannelsKt$emitAllImpl$1.label = 1;
                objB = it.b(flowKt__ChannelsKt$emitAllImpl$1);
                if (objB == coroutineSingletons) {
                    return coroutineSingletons;
                }
                gVar2 = gVar;
                aVar = it;
                obj = objB;
                mVar = mVar2;
                if (!((Boolean) obj).booleanValue()) {
                    if (z10) {
                        mVar.e(null);
                    }
                    return kd.e.f29109a;
                }
                Object obj2 = aVar.f29302a;
                la.e eVar = kotlinx.coroutines.channels.c.f29331p;
                if (obj2 == eVar) {
                    throw new IllegalStateException("`hasNext()` has not been invoked".toString());
                }
                aVar.f29302a = eVar;
                if (obj2 == kotlinx.coroutines.channels.c.f29327l) {
                    Throwable thQ = aVar.f29304c.q();
                    int i12 = kotlinx.coroutines.internal.t.f29488a;
                    throw thQ;
                }
                flowKt__ChannelsKt$emitAllImpl$1.L$0 = gVar2;
                flowKt__ChannelsKt$emitAllImpl$1.L$1 = mVar;
                flowKt__ChannelsKt$emitAllImpl$1.L$2 = aVar;
                flowKt__ChannelsKt$emitAllImpl$1.Z$0 = z10;
                flowKt__ChannelsKt$emitAllImpl$1.label = 2;
                mVar5 = mVar;
                if (gVar2.c(obj2, flowKt__ChannelsKt$emitAllImpl$1) == coroutineSingletons) {
                    return coroutineSingletons;
                }
                it = aVar;
                gVar = gVar2;
                mVar2 = mVar5;
                flowKt__ChannelsKt$emitAllImpl$1.L$0 = gVar;
                flowKt__ChannelsKt$emitAllImpl$1.L$1 = mVar2;
                flowKt__ChannelsKt$emitAllImpl$1.L$2 = it;
                flowKt__ChannelsKt$emitAllImpl$1.Z$0 = z10;
                flowKt__ChannelsKt$emitAllImpl$1.label = 1;
                objB = it.b(flowKt__ChannelsKt$emitAllImpl$1);
                if (objB == coroutineSingletons) {
                }
            }
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                if (z10) {
                    CancellationException cancellationException = th instanceof CancellationException ? th : null;
                    if (cancellationException == null) {
                        cancellationException = new CancellationException("Channel was consumed, consumer had failed");
                        cancellationException.initCause(th);
                    }
                    kVar.e(cancellationException);
                }
                throw th2;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object g(f fVar, Continuation continuation) {
        FlowKt__ReduceKt$firstOrNull$1 flowKt__ReduceKt$firstOrNull$1;
        Ref$ObjectRef ref$ObjectRef;
        AbortFlowException e10;
        g gVar;
        if (continuation instanceof FlowKt__ReduceKt$firstOrNull$1) {
            flowKt__ReduceKt$firstOrNull$1 = (FlowKt__ReduceKt$firstOrNull$1) continuation;
            int i10 = flowKt__ReduceKt$firstOrNull$1.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                flowKt__ReduceKt$firstOrNull$1.label = i10 - Integer.MIN_VALUE;
            } else {
                flowKt__ReduceKt$firstOrNull$1 = new FlowKt__ReduceKt$firstOrNull$1(continuation);
            }
        }
        Object obj = flowKt__ReduceKt$firstOrNull$1.result;
        Object obj2 = CoroutineSingletons.f29226a;
        int i11 = flowKt__ReduceKt$firstOrNull$1.label;
        if (i11 == 0) {
            kotlin.a.d(obj);
            Ref$ObjectRef ref$ObjectRef2 = new Ref$ObjectRef();
            g oVar = new o(ref$ObjectRef2);
            try {
                flowKt__ReduceKt$firstOrNull$1.L$0 = ref$ObjectRef2;
                flowKt__ReduceKt$firstOrNull$1.L$1 = oVar;
                flowKt__ReduceKt$firstOrNull$1.label = 1;
                if (fVar.a(oVar, flowKt__ReduceKt$firstOrNull$1) == obj2) {
                    return obj2;
                }
                ref$ObjectRef = ref$ObjectRef2;
            } catch (AbortFlowException e11) {
                ref$ObjectRef = ref$ObjectRef2;
                e10 = e11;
                gVar = oVar;
                if (e10.f29378a != gVar) {
                }
            }
        } else {
            if (i11 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            gVar = (o) flowKt__ReduceKt$firstOrNull$1.L$1;
            ref$ObjectRef = (Ref$ObjectRef) flowKt__ReduceKt$firstOrNull$1.L$0;
            try {
                kotlin.a.d(obj);
            } catch (AbortFlowException e12) {
                e10 = e12;
                if (e10.f29378a != gVar) {
                    throw e10;
                }
            }
        }
        return ref$ObjectRef.element;
    }

    public static String h(String str, Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, Locale.US);
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return simpleDateFormat.format(date);
    }

    public static String i(String str, String str2) {
        try {
            Locale locale = Locale.US;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", locale);
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            Date date = simpleDateFormat.parse(str);
            if (date == null) {
                return "";
            }
            SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(str2, locale);
            simpleDateFormat2.setTimeZone(TimeZone.getDefault());
            return simpleDateFormat2.format(date);
        } catch (Exception e10) {
            e10.printStackTrace();
            return "";
        }
    }

    public static String j(long j10) {
        if (j10 <= 0) {
            return SessionDescription.SUPPORTED_SDP_VERSION;
        }
        String[] strArr = {"B", "KB", "MB", "GB", "TB"};
        double d10 = j10;
        int iLog10 = (int) (Math.log10(d10) / Math.log10(1024.0d));
        if (iLog10 <= 0) {
            return SessionDescription.SUPPORTED_SDP_VERSION;
        }
        return new DecimalFormat("#,##0.#").format(d10 / Math.pow(1024.0d, iLog10)) + " " + strArr[iLog10];
    }

    public static String k(String str, String str2, String str3) {
        try {
            Locale locale = Locale.US;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str2, locale);
            simpleDateFormat.setTimeZone(TimeZone.getDefault());
            Date date = simpleDateFormat.parse(str);
            if (date == null) {
                return "";
            }
            SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(str3, locale);
            simpleDateFormat2.setTimeZone(TimeZone.getDefault());
            return simpleDateFormat2.format(date);
        } catch (Exception e10) {
            e10.printStackTrace();
            return "";
        }
    }

    public static String l(String str) {
        int i10;
        String str2;
        if (str != null) {
            try {
                if (str.isEmpty() || (i10 = Integer.parseInt(str)) == 0) {
                    return SessionDescription.SUPPORTED_SDP_VERSION;
                }
                int i11 = i10 / 60;
                int i12 = i10 % 60;
                String str3 = "";
                if (i11 == 0) {
                    str2 = "";
                } else {
                    str2 = i11 + CmcdData.STREAMING_FORMAT_HLS;
                }
                if (i12 != 0) {
                    str3 = i12 + CmcdData.OBJECT_TYPE_MANIFEST;
                }
                return str2 + str3;
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("formatRuntime: "));
            }
        }
        return SessionDescription.SUPPORTED_SDP_VERSION;
    }

    public static String m(String str) {
        int i10;
        if (str != null) {
            try {
                if (str.isEmpty() || (i10 = Integer.parseInt(str)) == 0) {
                    return SessionDescription.SUPPORTED_SDP_VERSION;
                }
                int i11 = i10 / 60;
                int i12 = i10 % 60;
                StringBuilder sb = new StringBuilder();
                sb.append(i11 == 0 ? "00" : Integer.valueOf(i11));
                sb.append(":");
                String string = sb.toString();
                StringBuilder sb2 = new StringBuilder();
                sb2.append(i12 == 0 ? "00" : Integer.valueOf(i12));
                sb2.append(":");
                return string + sb2.toString() + "00";
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("formatRuntime2: "));
            }
        }
        return SessionDescription.SUPPORTED_SDP_VERSION;
    }

    public static String n(String str) {
        try {
            return (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class).invoke(null, str, "");
        } catch (Exception unused) {
            xyz.stream.utils.f.p().y("XyzStream", "read SystemProperties error");
            return null;
        }
    }

    public static Calendar o(String str) {
        try {
            Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault()).parse(str);
            if (date == null) {
                return null;
            }
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            return calendar;
        } catch (Exception e10) {
            u.a.g(e10, new StringBuilder("getCalendarFromString error: "));
            return null;
        }
    }

    public static String p(int i10) {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
            Date date = new Date();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(6, i10);
            return simpleDateFormat.format(calendar.getTime());
        } catch (Exception e10) {
            u.a.g(e10, new StringBuilder("getDateLocalStrOffset error: "));
            return "";
        }
    }

    public static long q(File file) {
        File[] fileArrListFiles;
        long jQ;
        long j10 = 0;
        if (file != null && file.exists() && file.isDirectory() && (fileArrListFiles = file.listFiles()) != null) {
            for (File file2 : fileArrListFiles) {
                if (file2.isFile()) {
                    jQ = file2.length();
                } else if (file2.isDirectory()) {
                    jQ = q(file2);
                }
                j10 = jQ + j10;
            }
        }
        return j10;
    }

    public static String r(String str, String str2) {
        if (str != null && !str.isEmpty() && str2 != null && !str2.isEmpty()) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
            try {
                Date date = simpleDateFormat.parse(str);
                Objects.requireNonNull(date);
                long time = date.getTime();
                Date date2 = simpleDateFormat.parse(str2);
                Objects.requireNonNull(date2);
                return B(date2.getTime() - time);
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("getDuration: "));
            }
        }
        return "";
    }

    public static long s(String str, String str2) {
        if (str != null && !str.isEmpty() && str2 != null && !str2.isEmpty()) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
            try {
                Date date = simpleDateFormat.parse(str);
                Objects.requireNonNull(date);
                long time = date.getTime();
                Date date2 = simpleDateFormat.parse(str2);
                Objects.requireNonNull(date2);
                return date2.getTime() - time;
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("getDurationForTime: "));
            }
        }
        return 0L;
    }

    public static String t(Context context, Uri uri) {
        String name = "temp";
        try {
            b1.a aVarFromSingleUri = b1.a.fromSingleUri(context, uri);
            InputStream inputStreamOpenInputStream = context.getContentResolver().openInputStream(uri);
            if (inputStreamOpenInputStream == null) {
                return null;
            }
            File file = new File(context.getCacheDir(), "temp");
            if (!file.exists()) {
                file.mkdir();
            }
            if (aVarFromSingleUri != null) {
                name = aVarFromSingleUri.getName();
                Objects.requireNonNull(name);
            }
            File file2 = new File(file, name);
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            byte[] bArr = new byte[1024];
            while (true) {
                int i10 = inputStreamOpenInputStream.read(bArr);
                if (i10 == -1) {
                    inputStreamOpenInputStream.close();
                    fileOutputStream.close();
                    return file2.getAbsolutePath();
                }
                fileOutputStream.write(bArr, 0, i10);
            }
        } catch (Exception unused) {
            return null;
        }
    }

    public static LinkedHashSet u(String str) {
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        String strQ = f0.o().q(str, "");
        if (strQ != null && !strQ.trim().isEmpty()) {
            for (String str2 : strQ.split(",")) {
                if (str2 != null && !str2.trim().isEmpty()) {
                    linkedHashSet.add(str2.trim());
                }
            }
        }
        return linkedHashSet;
    }

    public static String v() {
        try {
            for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
                if (networkInterface.getName().equalsIgnoreCase("wlan0")) {
                    byte[] hardwareAddress = networkInterface.getHardwareAddress();
                    if (hardwareAddress == null) {
                        return "";
                    }
                    StringBuilder sb = new StringBuilder();
                    for (byte b10 : hardwareAddress) {
                        sb.append(String.format("%02X:", Byte.valueOf(b10)));
                    }
                    if (sb.length() > 0) {
                        sb.deleteCharAt(sb.length() - 1);
                    }
                    return sb.toString().toLowerCase();
                }
            }
            return "";
        } catch (Exception unused) {
            return "";
        }
    }

    public static long w(String str, String str2) {
        try {
            Date date = new SimpleDateFormat(str2, Locale.US).parse(str);
            if (date != null) {
                return date.getTime();
            }
            return 0L;
        } catch (Exception e10) {
            e10.printStackTrace();
            return 0L;
        }
    }

    public static String x() {
        ApplicationInfo applicationInfo;
        try {
            applicationInfo = xyz.stream.utils.e.d().f36112a.getPackageManager().getApplicationInfo(xyz.stream.utils.e.d().f36112a.getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e10) {
            e10.printStackTrace();
            applicationInfo = null;
        }
        long totalRxBytes = (applicationInfo == null || TrafficStats.getUidRxBytes(applicationInfo.uid) != -1) ? TrafficStats.getTotalRxBytes() : 0L;
        long jCurrentTimeMillis = System.currentTimeMillis();
        long j10 = f29371a;
        String str = "";
        if (j10 > 0) {
            long j11 = f29372b;
            if (j11 > 0) {
                long j12 = totalRxBytes - j10;
                long j13 = jCurrentTimeMillis - j11;
                if (j13 <= 0) {
                    return "";
                }
                str = j((j12 * 1000) / j13) + "/s";
            }
        }
        f29371a = totalRxBytes;
        f29372b = jCurrentTimeMillis;
        return str;
    }

    public static String y(String str) {
        return new SimpleDateFormat(str, Locale.US).format(new Date());
    }

    public static int z(String str, String str2) {
        if (str != null && !str.isEmpty() && str2 != null && !str2.isEmpty()) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT);
            try {
                Date date = simpleDateFormat.parse(str);
                Objects.requireNonNull(date);
                long time = date.getTime();
                Date date2 = simpleDateFormat.parse(str2);
                Objects.requireNonNull(date2);
                long time2 = date2.getTime() - time;
                if (time2 > 0) {
                    return (int) (time2 / 1000);
                }
                return 0;
            } catch (Exception e10) {
                u.a.g(e10, new StringBuilder("getSecond: "));
            }
        }
        return 0;
    }
}
