package androidx.media3.extractor.metadata.id3;

import F3.O;
import I3.c;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import com.google.firebase.sessions.settings.RemoteSettings;
import java.util.ArrayList;
import java.util.List;
import q.AbstractC2761L;

/* JADX INFO: loaded from: classes.dex */
@UnstableApi
public final class TextInformationFrame extends Id3Frame {
    public static final Parcelable.Creator<TextInformationFrame> CREATOR = new Parcelable.Creator<TextInformationFrame>() { // from class: androidx.media3.extractor.metadata.id3.TextInformationFrame.1
        /* JADX WARN: Can't rename method to resolve collision */
        @Override // android.os.Parcelable.Creator
        public TextInformationFrame createFromParcel(Parcel parcel) {
            return new TextInformationFrame(parcel);
        }

        /* JADX WARN: Can't rename method to resolve collision */
        @Override // android.os.Parcelable.Creator
        public TextInformationFrame[] newArray(int i6) {
            return new TextInformationFrame[i6];
        }
    };
    public final String description;

    @Deprecated
    public final String value;
    public final O values;

    private static List<Integer> parseId3v2point4TimestampFrameForDate(String str) {
        ArrayList arrayList = new ArrayList();
        try {
            if (str.length() >= 10) {
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(0, 4))));
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(5, 7))));
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(8, 10))));
                return arrayList;
            }
            if (str.length() >= 7) {
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(0, 4))));
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(5, 7))));
                return arrayList;
            }
            if (str.length() >= 4) {
                arrayList.add(Integer.valueOf(Integer.parseInt(str.substring(0, 4))));
            }
            return arrayList;
        } catch (NumberFormatException unused) {
            return new ArrayList();
        }
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && TextInformationFrame.class == obj.getClass()) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) obj;
            if (Util.areEqual(this.id, textInformationFrame.id) && Util.areEqual(this.description, textInformationFrame.description) && this.values.equals(textInformationFrame.values)) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        int iB = AbstractC2761L.b(527, 31, this.id);
        String str = this.description;
        return this.values.hashCode() + ((iB + (str != null ? str.hashCode() : 0)) * 31);
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:119:0x01c1  */
    @Override // androidx.media3.common.Metadata.Entry
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void populateMediaMetadata(MediaMetadata.Builder builder) {
        byte b5;
        byte b6;
        Long lValueOf;
        byte b7;
        byte b8 = 10;
        String str = this.id;
        str.getClass();
        switch (str.hashCode()) {
            case 82815:
                b5 = !str.equals("TAL") ? (byte) -1 : (byte) 0;
                break;
            case 82878:
                b5 = !str.equals("TCM") ? (byte) -1 : (byte) 1;
                break;
            case 82897:
                b5 = !str.equals("TDA") ? (byte) -1 : (byte) 2;
                break;
            case 83253:
                b5 = !str.equals("TP1") ? (byte) -1 : (byte) 3;
                break;
            case 83254:
                b5 = !str.equals("TP2") ? (byte) -1 : (byte) 4;
                break;
            case 83255:
                b5 = !str.equals("TP3") ? (byte) -1 : (byte) 5;
                break;
            case 83341:
                b5 = !str.equals("TRK") ? (byte) -1 : (byte) 6;
                break;
            case 83378:
                b5 = !str.equals("TT2") ? (byte) -1 : (byte) 7;
                break;
            case 83536:
                b5 = !str.equals("TXT") ? (byte) -1 : (byte) 8;
                break;
            case 83552:
                b5 = !str.equals("TYE") ? (byte) -1 : (byte) 9;
                break;
            case 2567331:
                b5 = !str.equals("TALB") ? (byte) -1 : (byte) 10;
                break;
            case 2569357:
                b5 = !str.equals("TCOM") ? (byte) -1 : (byte) 11;
                break;
            case 2569358:
                b5 = !str.equals("TCON") ? (byte) -1 : (byte) 12;
                break;
            case 2569891:
                b5 = !str.equals("TDAT") ? (byte) -1 : (byte) 13;
                break;
            case 2570401:
                b5 = !str.equals("TDRC") ? (byte) -1 : (byte) 14;
                break;
            case 2570410:
                b5 = !str.equals("TDRL") ? (byte) -1 : (byte) 15;
                break;
            case 2571565:
                b5 = !str.equals("TEXT") ? (byte) -1 : (byte) 16;
                break;
            case 2575251:
                b5 = !str.equals("TIT2") ? (byte) -1 : (byte) 17;
                break;
            case 2581512:
                b5 = !str.equals("TPE1") ? (byte) -1 : (byte) 18;
                break;
            case 2581513:
                b5 = !str.equals("TPE2") ? (byte) -1 : (byte) 19;
                break;
            case 2581514:
                b5 = !str.equals("TPE3") ? (byte) -1 : (byte) 20;
                break;
            case 2583398:
                b5 = !str.equals("TRCK") ? (byte) -1 : (byte) 21;
                break;
            case 2590194:
                b5 = !str.equals("TYER") ? (byte) -1 : (byte) 22;
                break;
            default:
                b5 = -1;
                break;
        }
        try {
            switch (b5) {
                case 0:
                case 10:
                    builder.setAlbumTitle((CharSequence) this.values.get(0));
                    break;
                case 1:
                case 11:
                    builder.setComposer((CharSequence) this.values.get(0));
                    break;
                case 2:
                case 13:
                    String str2 = (String) this.values.get(0);
                    builder.setRecordingMonth(Integer.valueOf(Integer.parseInt(str2.substring(2, 4)))).setRecordingDay(Integer.valueOf(Integer.parseInt(str2.substring(0, 2))));
                    break;
                case 3:
                case 18:
                    builder.setArtist((CharSequence) this.values.get(0));
                    break;
                case 4:
                case 19:
                    builder.setAlbumArtist((CharSequence) this.values.get(0));
                    break;
                case 5:
                case 20:
                    builder.setConductor((CharSequence) this.values.get(0));
                    break;
                case 6:
                case 21:
                    String[] strArrSplit = Util.split((String) this.values.get(0), RemoteSettings.FORWARD_SLASH_STRING);
                    builder.setTrackNumber(Integer.valueOf(Integer.parseInt(strArrSplit[0]))).setTotalTrackCount(strArrSplit.length > 1 ? Integer.valueOf(Integer.parseInt(strArrSplit[1])) : null);
                    break;
                case 7:
                case 17:
                    builder.setTitle((CharSequence) this.values.get(0));
                    break;
                case 8:
                case 16:
                    builder.setWriter((CharSequence) this.values.get(0));
                    break;
                case 9:
                case 22:
                    builder.setRecordingYear(Integer.valueOf(Integer.parseInt((String) this.values.get(0))));
                    break;
                case 12:
                    String str3 = (String) this.values.get(0);
                    str3.getClass();
                    if (!str3.isEmpty()) {
                        int i6 = str3.charAt(0) == '-' ? 1 : 0;
                        if (i6 == str3.length()) {
                            lValueOf = null;
                        } else {
                            int i7 = i6 + 1;
                            char cCharAt = str3.charAt(i6);
                            if (cCharAt < 128) {
                                b6 = c.f2685a[cCharAt];
                            } else {
                                byte[] bArr = c.f2685a;
                                b6 = -1;
                            }
                            if (b6 >= 0 && b6 < 10) {
                                long j4 = -b6;
                                long j6 = 10;
                                long j7 = Long.MIN_VALUE / j6;
                                while (true) {
                                    if (i7 < str3.length()) {
                                        int i8 = i7 + 1;
                                        char cCharAt2 = str3.charAt(i7);
                                        if (cCharAt2 < 128) {
                                            b7 = c.f2685a[cCharAt2];
                                        } else {
                                            byte[] bArr2 = c.f2685a;
                                            b7 = -1;
                                        }
                                        if (b7 >= 0 && b7 < b8 && j4 >= j7) {
                                            long j8 = j4 * j6;
                                            String str4 = str3;
                                            long j9 = b7;
                                            if (j8 >= j9 - Long.MIN_VALUE) {
                                                j4 = j8 - j9;
                                                i7 = i8;
                                                str3 = str4;
                                                b8 = 10;
                                            }
                                        }
                                    } else if (i6 != 0) {
                                        lValueOf = Long.valueOf(j4);
                                    } else if (j4 != Long.MIN_VALUE) {
                                        lValueOf = Long.valueOf(-j4);
                                    }
                                }
                                lValueOf = null;
                            }
                        }
                    }
                    if (lValueOf != null && lValueOf.longValue() == lValueOf.intValue()) {
                        numValueOf = Integer.valueOf(lValueOf.intValue());
                    }
                    if (numValueOf != null) {
                        String strResolveV1Genre = Id3Util.resolveV1Genre(numValueOf.intValue());
                        if (strResolveV1Genre != null) {
                            builder.setGenre(strResolveV1Genre);
                        }
                    } else {
                        builder.setGenre((CharSequence) this.values.get(0));
                    }
                    break;
                case 14:
                    List<Integer> id3v2point4TimestampFrameForDate = parseId3v2point4TimestampFrameForDate((String) this.values.get(0));
                    int size = id3v2point4TimestampFrameForDate.size();
                    if (size != 1) {
                        if (size != 2) {
                            if (size == 3) {
                                builder.setRecordingDay(id3v2point4TimestampFrameForDate.get(2));
                            }
                        }
                        builder.setRecordingMonth(id3v2point4TimestampFrameForDate.get(1));
                    }
                    builder.setRecordingYear(id3v2point4TimestampFrameForDate.get(0));
                    break;
                case 15:
                    List<Integer> id3v2point4TimestampFrameForDate2 = parseId3v2point4TimestampFrameForDate((String) this.values.get(0));
                    int size2 = id3v2point4TimestampFrameForDate2.size();
                    if (size2 != 1) {
                        if (size2 != 2) {
                            if (size2 == 3) {
                                builder.setReleaseDay(id3v2point4TimestampFrameForDate2.get(2));
                            }
                        }
                        builder.setReleaseMonth(id3v2point4TimestampFrameForDate2.get(1));
                    }
                    builder.setReleaseYear(id3v2point4TimestampFrameForDate2.get(0));
                    break;
            }
        } catch (NumberFormatException | StringIndexOutOfBoundsException unused) {
        }
    }

    @Override // androidx.media3.extractor.metadata.id3.Id3Frame
    public String toString() {
        return this.id + ": description=" + this.description + ": values=" + this.values;
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i6) {
        parcel.writeString(this.id);
        parcel.writeString(this.description);
        parcel.writeStringArray((String[]) this.values.toArray(new String[0]));
    }

    public TextInformationFrame(String str, String str2, List<String> list) {
        super(str);
        Assertions.checkArgument(!list.isEmpty());
        this.description = str2;
        O oP = O.p(list);
        this.values = oP;
        this.value = (String) oP.get(0);
    }

    @Deprecated
    public TextInformationFrame(String str, String str2, String str3) {
        this(str, str2, O.u(str3));
    }

    private TextInformationFrame(Parcel parcel) {
        this((String) Assertions.checkNotNull(parcel.readString()), parcel.readString(), O.q((String[]) Assertions.checkNotNull(parcel.createStringArray())));
    }
}
