package com.google.android.gms.internal.ads;

import android.content.Context;
import android.media.DeniedByServerException;
import android.media.MediaCodec;
import android.media.MediaDrm;
import android.media.MediaDrmResetException;
import android.media.NotProvisionedException;
import android.media.metrics.MediaMetricsManager;
import android.media.metrics.PlaybackMetrics;
import android.media.metrics.PlaybackSession;
import android.media.metrics.TrackChangeEvent;
import android.net.Uri;
import android.os.SystemClock;
import android.system.ErrnoException;
import android.system.OsConstants;
import android.util.Pair;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import androidx.media3.common.MediaLibraryInfo;
import androidx.media3.common.PlaybackException;
import androidx.media3.exoplayer.analytics.AnalyticsListener;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;

/* JADX INFO: loaded from: classes2.dex */
public final class ik2 implements oj2, jk2 {
    public boolean Q;
    public int R;
    public int S;
    public int T;
    public boolean U;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f12548a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final gk2 f12550c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final PlaybackSession f12551d;

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

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f12560m;

    @Nullable
    private String zzj;

    @Nullable
    private PlaybackMetrics.Builder zzk;

    @Nullable
    private zzau zzo;

    @Nullable
    private hk2 zzp;

    @Nullable
    private hk2 zzq;

    @Nullable
    private hk2 zzr;

    @Nullable
    private zn2 zzs;

    @Nullable
    private zn2 zzt;

    @Nullable
    private zn2 zzu;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Executor f12549b = zi0.a();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final tj f12553f = new tj();

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final gj f12554g = new gj();

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final HashMap f12556i = new HashMap();

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final HashMap f12555h = new HashMap();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final long f12552e = SystemClock.elapsedRealtime();

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

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

    public ik2(Context context, PlaybackSession playbackSession) {
        this.f12548a = context.getApplicationContext();
        this.f12551d = playbackSession;
        gk2 gk2Var = new gk2();
        this.f12550c = gk2Var;
        gk2Var.f11777d = this;
    }

    private final void zzA(int i10, long j10, @Nullable zn2 zn2Var, int i11) {
        TrackChangeEvent.Builder timeSinceCreatedMillis = androidx.media3.exoplayer.analytics.a0.n(i10).setTimeSinceCreatedMillis(j10 - this.f12552e);
        if (zn2Var != null) {
            timeSinceCreatedMillis.setTrackState(1);
            timeSinceCreatedMillis.setTrackChangeReason(i11 != 1 ? 1 : 2);
            String str = zn2Var.zzn;
            if (str != null) {
                timeSinceCreatedMillis.setContainerMimeType(str);
            }
            String str2 = zn2Var.zzo;
            if (str2 != null) {
                timeSinceCreatedMillis.setSampleMimeType(str2);
            }
            String str3 = zn2Var.zzk;
            if (str3 != null) {
                timeSinceCreatedMillis.setCodecName(str3);
            }
            int i12 = zn2Var.f19333f;
            if (i12 != -1) {
                timeSinceCreatedMillis.setBitrate(i12);
            }
            int i13 = zn2Var.f19339l;
            if (i13 != -1) {
                timeSinceCreatedMillis.setWidth(i13);
            }
            int i14 = zn2Var.f19340m;
            if (i14 != -1) {
                timeSinceCreatedMillis.setHeight(i14);
            }
            int i15 = zn2Var.f19348u;
            if (i15 != -1) {
                timeSinceCreatedMillis.setChannelCount(i15);
            }
            int i16 = zn2Var.f19349v;
            if (i16 != -1) {
                timeSinceCreatedMillis.setAudioSampleRate(i16);
            }
            String str4 = zn2Var.zzd;
            if (str4 != null) {
                String str5 = bb1.f9474a;
                String[] strArrSplit = str4.split("-", -1);
                Pair pairCreate = Pair.create(strArrSplit[0], strArrSplit.length >= 2 ? strArrSplit[1] : null);
                timeSinceCreatedMillis.setLanguage((String) pairCreate.first);
                Object obj = pairCreate.second;
                if (obj != null) {
                    timeSinceCreatedMillis.setLanguageRegion((String) obj);
                }
            }
            float f10 = zn2Var.f19343p;
            if (f10 != -1.0f) {
                timeSinceCreatedMillis.setVideoFrameRate(f10);
            }
        } else {
            timeSinceCreatedMillis.setTrackState(0);
        }
        this.U = true;
        this.f12549b.execute(new nw0(this, timeSinceCreatedMillis.build(), 24));
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x004e  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00a7  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00d3  */
    @RequiresNonNull({"metricsBuilder"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final void zzB(mk mkVar, @Nullable cp2 cp2Var) {
        int i10;
        PlaybackMetrics.Builder builder = this.zzk;
        if (cp2Var == null) {
            return;
        }
        int iE = mkVar.e(cp2Var.f10025a);
        if (iE != -1) {
            gj gjVar = this.f12554g;
            int i11 = 0;
            mkVar.d(iE, gjVar, false);
            int i12 = gjVar.f11762a;
            tj tjVar = this.f12553f;
            mkVar.b(i12, tjVar, 0L);
            m3 m3Var = tjVar.f16911b.zzb;
            if (m3Var != null) {
                String str = bb1.f9474a;
                Uri uri = m3Var.f13937a;
                String scheme = uri.getScheme();
                if (scheme == null || !(ih1.N0("rtsp", scheme) || ih1.N0("rtspt", scheme))) {
                    String lastPathSegment = uri.getLastPathSegment();
                    if (lastPathSegment != null) {
                        int iLastIndexOf = lastPathSegment.lastIndexOf(46);
                        if (iLastIndexOf >= 0) {
                            String strR = ih1.r(lastPathSegment.substring(iLastIndexOf + 1));
                            strR.getClass();
                            switch (strR) {
                                case "ism":
                                case "isml":
                                    i10 = 1;
                                    break;
                                case "mpd":
                                    i10 = 0;
                                    break;
                                case "m3u8":
                                    i10 = 2;
                                    break;
                                default:
                                    i10 = 4;
                                    break;
                            }
                            if (i10 == 4) {
                                String path = uri.getPath();
                                path.getClass();
                                Matcher matcher = bb1.f9476c.matcher(path);
                                if (matcher.matches()) {
                                    String strGroup = matcher.group(2);
                                    if (strGroup == null) {
                                        i11 = 1;
                                    } else if (!strGroup.contains("format=mpd-time-csf")) {
                                        if (strGroup.contains("format=m3u8-aapl")) {
                                            i11 = 2;
                                        }
                                    }
                                } else {
                                    i11 = 4;
                                }
                            } else {
                                i11 = i10;
                            }
                        }
                    }
                } else {
                    i11 = 3;
                }
                i11 = i11 != 0 ? i11 != 1 ? i11 != 2 ? 1 : 4 : 5 : 3;
            }
            builder.setStreamType(i11);
            long j10 = tjVar.f16918i;
            if (j10 != -9223372036854775807L && !tjVar.f16917h && !tjVar.f16916g && !tjVar.a()) {
                builder.setMediaDurationMillis(bb1.o(j10));
            }
            builder.setPlaybackType(true != tjVar.a() ? 1 : 2);
            this.U = true;
        }
    }

    @Nullable
    public static ik2 zza(Context context) {
        MediaMetricsManager mediaMetricsManagerA = androidx.media3.exoplayer.analytics.z.a(context.getSystemService("media_metrics"));
        if (mediaMetricsManagerA == null) {
            return null;
        }
        return new ik2(context, mediaMetricsManagerA.createPlaybackSession());
    }

    @EnsuresNonNullIf(expression = {"#1"}, result = true)
    private final boolean zzw(@Nullable hk2 hk2Var) {
        return hk2Var != null && hk2Var.f12188b.equals(this.f12550c.zzf());
    }

    private final void zzx(long j10, @Nullable zn2 zn2Var, int i10) {
        if (Objects.equals(this.zzs, zn2Var)) {
            return;
        }
        int i11 = this.zzs == null ? 1 : 0;
        this.zzs = zn2Var;
        zzA(1, j10, zn2Var, i11);
    }

    private final void zzy(long j10, @Nullable zn2 zn2Var, int i10) {
        if (Objects.equals(this.zzt, zn2Var)) {
            return;
        }
        int i11 = this.zzt == null ? 1 : 0;
        this.zzt = zn2Var;
        zzA(0, j10, zn2Var, i11);
    }

    private final void zzz(long j10, @Nullable zn2 zn2Var, int i10) {
        if (Objects.equals(this.zzu, zn2Var)) {
            return;
        }
        int i11 = this.zzu == null ? 1 : 0;
        this.zzu = zn2Var;
        zzA(2, j10, zn2Var, i11);
    }

    public final void a() {
        PlaybackMetrics.Builder builder = this.zzk;
        if (builder != null && this.U) {
            builder.setAudioUnderrunCount(this.T);
            this.zzk.setVideoFramesDropped(this.R);
            this.zzk.setVideoFramesPlayed(this.S);
            Long l10 = (Long) this.f12555h.get(this.zzj);
            this.zzk.setNetworkTransferDurationMillis(l10 == null ? 0L : l10.longValue());
            Long l11 = (Long) this.f12556i.get(this.zzj);
            this.zzk.setNetworkBytesRead(l11 == null ? 0L : l11.longValue());
            this.zzk.setStreamSource((l11 == null || l11.longValue() <= 0) ? 0 : 1);
            this.f12549b.execute(new nw0(this, this.zzk.build(), 25));
        }
        this.zzk = null;
        this.zzj = null;
        this.T = 0;
        this.R = 0;
        this.S = 0;
        this.zzs = null;
        this.zzt = null;
        this.zzu = null;
        this.U = false;
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void c(int i10) {
        if (i10 == 1) {
            this.f12560m = true;
            i10 = 1;
        }
        this.f12557j = i10;
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void e(ug2 ug2Var) {
        this.R += ug2Var.f17246g;
        this.S += ug2Var.f17244e;
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void f(nj2 nj2Var, yo2 yo2Var) {
        cp2 cp2Var = nj2Var.zzd;
        if (cp2Var == null) {
            return;
        }
        zn2 zn2Var = yo2Var.zzb;
        zn2Var.getClass();
        hk2 hk2Var = new hk2(zn2Var, this.f12550c.a(nj2Var.f14652b, cp2Var));
        int i10 = yo2Var.f18920a;
        if (i10 != 0) {
            if (i10 == 1) {
                this.zzq = hk2Var;
                return;
            } else if (i10 != 2) {
                if (i10 != 3) {
                    return;
                }
                this.zzr = hk2Var;
                return;
            }
        }
        this.zzp = hk2Var;
    }

    public final void g(nj2 nj2Var, String str) {
        cp2 cp2Var = nj2Var.zzd;
        if (cp2Var == null || !cp2Var.b()) {
            a();
            this.zzj = str;
            this.zzk = androidx.media3.exoplayer.analytics.a0.l().setPlayerName(MediaLibraryInfo.TAG).setPlayerVersion("1.9.0-beta01");
            zzB(nj2Var.f14652b, cp2Var);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:105:0x01a9  */
    /* JADX WARN: Removed duplicated region for block: B:116:0x01da A[PHI: r10
      0x01da: PHI (r10v5 int) = (r10v4 int), (r10v4 int), (r10v7 int), (r10v7 int) binds: [B:134:0x0214, B:135:0x0216, B:112:0x01cc, B:114:0x01d4] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:186:0x02ee  */
    /* JADX WARN: Removed duplicated region for block: B:258:0x03d9  */
    /* JADX WARN: Removed duplicated region for block: B:261:0x0403  */
    /* JADX WARN: Removed duplicated region for block: B:276:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:89:0x0179 A[PHI: r15
      0x0179: PHI (r15v12 int) = (r15v4 int), (r15v13 int) binds: [B:161:0x026b, B:88:0x0176] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:90:0x017d A[PHI: r15
      0x017d: PHI (r15v11 int) = (r15v4 int), (r15v13 int) binds: [B:161:0x026b, B:88:0x0176] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:91:0x0181 A[PHI: r15
      0x0181: PHI (r15v10 int) = (r15v4 int), (r15v13 int) binds: [B:161:0x026b, B:88:0x0176] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:92:0x0185 A[PHI: r15
      0x0185: PHI (r15v9 int) = (r15v4 int), (r15v13 int) binds: [B:161:0x026b, B:88:0x0176] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:93:0x0189 A[PHI: r15
      0x0189: PHI (r15v8 int) = (r15v4 int), (r15v13 int) binds: [B:161:0x026b, B:88:0x0176] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // com.google.android.gms.internal.ads.oj2
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void h(yh yhVar, uz0 uz0Var) {
        gk2 gk2Var;
        long j10;
        hk2 hk2Var;
        int i10;
        int i11;
        boolean z10;
        boolean z11;
        int i12;
        zn2 zn2Var;
        int i13;
        int errorCode;
        int i14;
        uk2 uk2Var;
        int i15;
        int i16;
        if (((wl2) uz0Var.f17461c).f18116a.size() == 0) {
            return;
        }
        int i17 = 0;
        while (true) {
            int size = ((wl2) uz0Var.f17461c).f18116a.size();
            gk2Var = this.f12550c;
            if (i17 >= size) {
                break;
            }
            int iA = ((wl2) uz0Var.f17461c).a(i17);
            nj2 nj2Var = (nj2) ((SparseArray) uz0Var.f17460b).get(iA);
            nj2Var.getClass();
            if (iA == 0) {
                gk2Var.c(nj2Var);
            } else if (iA == 11) {
                gk2Var.d(nj2Var, this.f12557j);
            } else {
                gk2Var.b(nj2Var);
            }
            i17++;
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        if (uz0Var.h(0)) {
            nj2 nj2Var2 = (nj2) ((SparseArray) uz0Var.f17460b).get(0);
            nj2Var2.getClass();
            if (this.zzk != null) {
                zzB(nj2Var2.f14652b, nj2Var2.zzd);
            }
        }
        int i18 = 2;
        if (uz0Var.h(2) && this.zzk != null) {
            zzguf zzgufVar = yhVar.zzp().f13849a;
            int size2 = zzgufVar.size();
            int i19 = 0;
            loop1: while (true) {
                if (i19 >= size2) {
                    uk2Var = null;
                    break;
                }
                sr srVar = (sr) zzgufVar.get(i19);
                int i20 = 0;
                while (true) {
                    i16 = i19 + 1;
                    if (i20 < srVar.f16554a) {
                        if (srVar.f16558e[i20] && (uk2Var = srVar.f16555b.f11276d[i20].zzs) != null) {
                            break loop1;
                        } else {
                            i20++;
                        }
                    }
                }
                i19 = i16;
            }
            if (uk2Var != null) {
                PlaybackMetrics.Builder builder = this.zzk;
                String str = bb1.f9474a;
                PlaybackMetrics.Builder builderH = androidx.media3.exoplayer.analytics.z.h(builder);
                int i21 = 0;
                while (true) {
                    if (i21 >= uk2Var.f17299c) {
                        i15 = 1;
                        break;
                    }
                    UUID uuid = uk2Var.f17297a[i21].f9563b;
                    if (uuid.equals(jj1.f12907d)) {
                        i15 = 3;
                        break;
                    } else if (uuid.equals(jj1.f12908e)) {
                        i15 = 2;
                        break;
                    } else {
                        if (uuid.equals(jj1.f12906c)) {
                            i15 = 6;
                            break;
                        }
                        i21++;
                    }
                }
                builderH.setDrmType(i15);
            }
        }
        if (uz0Var.h(1011)) {
            this.T++;
        }
        zzau zzauVar = this.zzo;
        Context context = this.f12548a;
        Executor executor = this.f12549b;
        long j11 = this.f12552e;
        if (zzauVar != null) {
            int i22 = zzauVar.zza;
            if (i22 == 1001) {
                i13 = 20;
            } else {
                zziw zziwVar = (zziw) zzauVar;
                boolean z12 = zziwVar.zzc == 1;
                int i23 = zziwVar.zzg;
                Throwable cause = zzauVar.getCause();
                cause.getClass();
                if (!(cause instanceof IOException)) {
                    if (z12) {
                        i14 = 35;
                        if (i23 == 0 || i23 == 1) {
                        }
                    }
                    if (z12 && i23 == 3) {
                        i13 = 15;
                    } else if (!z12 || i23 != 2) {
                        if (cause instanceof zzuq) {
                            errorCode = bb1.zzQ(((zzuq) cause).zzd);
                            i13 = 13;
                        } else if (cause instanceof zzum) {
                            errorCode = ((zzum) cause).zza;
                            i13 = 14;
                        } else if (cause instanceof OutOfMemoryError) {
                            i13 = 14;
                        } else if (cause instanceof zzrf) {
                            i13 = 17;
                        } else if (cause instanceof zzri) {
                            errorCode = ((zzri) cause).zza;
                            i13 = 18;
                        } else if (cause instanceof MediaCodec.CryptoException) {
                            errorCode = ((MediaCodec.CryptoException) cause).getErrorCode();
                            switch (bb1.e(errorCode)) {
                            }
                        } else {
                            i13 = 22;
                        }
                        executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.j().setTimeSinceCreatedMillis(jElapsedRealtime - j11).setErrorCode(i13).setSubErrorCode(errorCode).setException(zzauVar).build(), 26));
                        this.U = true;
                        this.zzo = null;
                    }
                } else if (cause instanceof zzhs) {
                    errorCode = ((zzhs) cause).zzc;
                    i13 = 5;
                    executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.j().setTimeSinceCreatedMillis(jElapsedRealtime - j11).setErrorCode(i13).setSubErrorCode(errorCode).setException(zzauVar).build(), 26));
                    this.U = true;
                    this.zzo = null;
                } else if (cause instanceof zzat) {
                    i13 = 11;
                } else {
                    boolean z13 = cause instanceof zzhq;
                    if (z13 || (cause instanceof zzia)) {
                        if (jz0.a(context).b() == 1) {
                            i13 = 3;
                        } else {
                            Throwable cause2 = cause.getCause();
                            i13 = cause2 instanceof UnknownHostException ? 6 : cause2 instanceof SocketTimeoutException ? 7 : (z13 && ((zzhq) cause).zzb == 1) ? 4 : 8;
                        }
                    } else if (i22 == 1002) {
                        i13 = 21;
                    } else if (cause instanceof zztg) {
                        Throwable cause3 = cause.getCause();
                        cause3.getClass();
                        if (cause3 instanceof MediaDrm.MediaDrmStateException) {
                            errorCode = bb1.zzQ(((MediaDrm.MediaDrmStateException) cause3).getDiagnosticInfo());
                            switch (bb1.e(errorCode)) {
                                case PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED /* 6002 */:
                                    i13 = 24;
                                    break;
                                case PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR /* 6003 */:
                                    i13 = 28;
                                    break;
                                case PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED /* 6004 */:
                                    i13 = 25;
                                    break;
                                case PlaybackException.ERROR_CODE_DRM_DISALLOWED_OPERATION /* 6005 */:
                                    i13 = 26;
                                    break;
                                default:
                                    i13 = 27;
                                    break;
                            }
                            executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.j().setTimeSinceCreatedMillis(jElapsedRealtime - j11).setErrorCode(i13).setSubErrorCode(errorCode).setException(zzauVar).build(), 26));
                            this.U = true;
                            this.zzo = null;
                        } else {
                            i13 = cause3 instanceof MediaDrmResetException ? 27 : cause3 instanceof NotProvisionedException ? 24 : cause3 instanceof DeniedByServerException ? 29 : cause3 instanceof zztq ? 23 : 30;
                        }
                    } else if ((cause instanceof zzhn) && (cause.getCause() instanceof FileNotFoundException)) {
                        Throwable cause4 = cause.getCause();
                        cause4.getClass();
                        Throwable cause5 = cause4.getCause();
                        i14 = 31;
                        i13 = ((cause5 instanceof ErrnoException) && ((ErrnoException) cause5).errno == OsConstants.EACCES) ? 32 : i14;
                    } else {
                        i13 = 9;
                    }
                }
            }
            errorCode = 0;
            executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.j().setTimeSinceCreatedMillis(jElapsedRealtime - j11).setErrorCode(i13).setSubErrorCode(errorCode).setException(zzauVar).build(), 26));
            this.U = true;
            this.zzo = null;
        }
        if (uz0Var.h(2)) {
            ls lsVarZzp = yhVar.zzp();
            boolean zA = lsVarZzp.a(2);
            boolean zA2 = lsVarZzp.a(1);
            boolean zA3 = lsVarZzp.a(3);
            if (!zA && !zA2) {
                if (zA3) {
                    zA3 = true;
                }
                j10 = jElapsedRealtime;
            }
            j10 = jElapsedRealtime;
            if (zA) {
                i12 = 0;
                zn2Var = null;
            } else {
                i12 = 0;
                zn2Var = null;
                zzx(j10, null, 0);
            }
            if (!zA2) {
                zzy(j10, zn2Var, i12);
            }
            if (!zA3) {
                zzz(j10, zn2Var, i12);
            }
        } else {
            j10 = jElapsedRealtime;
        }
        if (zzw(this.zzp)) {
            zn2 zn2Var2 = this.zzp.f12187a;
            if (zn2Var2.f19340m != -1) {
                i10 = 0;
                zzx(j10, zn2Var2, 0);
                hk2Var = null;
                this.zzp = null;
            } else {
                hk2Var = null;
                i10 = 0;
            }
        }
        if (zzw(this.zzq)) {
            zzy(j10, this.zzq.f12187a, i10);
            this.zzq = hk2Var;
        }
        if (zzw(this.zzr)) {
            zzz(j10, this.zzr.f12187a, i10);
            this.zzr = hk2Var;
        }
        switch (jz0.a(context).b()) {
            case 0:
                i11 = 0;
                break;
            case 1:
                i11 = 9;
                break;
            case 2:
                i11 = 2;
                break;
            case 3:
                i11 = 4;
                break;
            case 4:
                i11 = 5;
                break;
            case 5:
                i11 = 6;
                break;
            case 6:
            case 8:
            default:
                i11 = 1;
                break;
            case 7:
                i11 = 3;
                break;
            case 9:
                i11 = 8;
                break;
            case 10:
                i11 = 7;
                break;
        }
        if (i11 != this.f12559l) {
            this.f12559l = i11;
            executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.i().setNetworkType(i11).setTimeSinceCreatedMillis(j10 - j11).build(), 22));
        }
        if (yhVar.zzh() != 2) {
            z10 = false;
            this.f12560m = false;
        } else {
            z10 = false;
        }
        if (((kj2) yhVar).zzI() == null) {
            this.Q = z10;
        } else if (uz0Var.h(10)) {
            this.Q = true;
        }
        int iZzh = yhVar.zzh();
        if (!this.f12560m) {
            if (this.Q) {
                z11 = true;
                i18 = 13;
            } else if (iZzh == 4) {
                z11 = true;
                i18 = 11;
            } else if (iZzh == 2) {
                int i24 = this.f12558k;
                if (i24 != 0 && i24 != 2 && i24 != 12) {
                    if (!yhVar.zzk()) {
                        i18 = 7;
                    } else if (yhVar.zzi() != 0) {
                        i18 = 10;
                    } else {
                        z11 = true;
                        i18 = 6;
                    }
                }
            } else {
                i18 = 3;
                if (iZzh != 3) {
                    z11 = true;
                    i18 = (iZzh != 1 || this.f12558k == 0) ? this.f12558k : 12;
                } else if (!yhVar.zzk()) {
                    i18 = 4;
                } else if (yhVar.zzi() != 0) {
                    i18 = 9;
                }
            }
            if (this.f12558k != i18) {
                this.f12558k = i18;
                this.U = z11;
                executor.execute(new nw0(this, androidx.media3.exoplayer.analytics.a0.m().setState(this.f12558k).setTimeSinceCreatedMillis(j10 - j11).build(), 23));
            }
            if (uz0Var.h(AnalyticsListener.EVENT_PLAYER_RELEASED)) {
                return;
            }
            nj2 nj2Var3 = (nj2) ((SparseArray) uz0Var.f17460b).get(AnalyticsListener.EVENT_PLAYER_RELEASED);
            nj2Var3.getClass();
            gk2Var.e(nj2Var3);
            return;
        }
        i18 = 5;
        z11 = true;
        if (this.f12558k != i18) {
        }
        if (uz0Var.h(AnalyticsListener.EVENT_PLAYER_RELEASED)) {
        }
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void i(rw rwVar) {
        hk2 hk2Var = this.zzp;
        if (hk2Var != null) {
            zn2 zn2Var = hk2Var.f12187a;
            if (zn2Var.f19340m == -1) {
                sm2 sm2Var = new sm2(zn2Var);
                sm2Var.f16487j = rwVar.f16235a;
                sm2Var.f16488k = rwVar.f16236b;
                this.zzp = new hk2(new zn2(sm2Var), hk2Var.f12188b);
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void j(zzau zzauVar) {
        this.zzo = zzauVar;
    }

    public final void k(nj2 nj2Var, String str) {
        cp2 cp2Var = nj2Var.zzd;
        if ((cp2Var == null || !cp2Var.b()) && str.equals(this.zzj)) {
            a();
        }
        this.f12555h.remove(str);
        this.f12556i.remove(str);
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void l(nj2 nj2Var, int i10, long j10) {
        cp2 cp2Var = nj2Var.zzd;
        if (cp2Var != null) {
            String strA = this.f12550c.a(nj2Var.f14652b, cp2Var);
            HashMap map = this.f12556i;
            Long l10 = (Long) map.get(strA);
            HashMap map2 = this.f12555h;
            Long l11 = (Long) map2.get(strA);
            map.put(strA, Long.valueOf((l10 == null ? 0L : l10.longValue()) + j10));
            map2.put(strA, Long.valueOf((l11 != null ? l11.longValue() : 0L) + ((long) i10)));
        }
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public final void m(IOException iOException) {
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public /* bridge */ /* synthetic */ void zzk(nj2 nj2Var, zn2 zn2Var, @Nullable vg2 vg2Var) {
        super.zzk(nj2Var, zn2Var, vg2Var);
    }

    @Override // com.google.android.gms.internal.ads.oj2
    public /* bridge */ /* synthetic */ void zzl(nj2 nj2Var, zn2 zn2Var, @Nullable vg2 vg2Var) {
        super.zzl(nj2Var, zn2Var, vg2Var);
    }
}
