package com.ss.android.ugc.aweme.textsticker;

import X.2HN;
import X.2Pr;
import X.C32556Of;
import X.Lea;
import X.LsC;
import X.M12;
import android.os.Parcel;
import android.os.Parcelable;
import com.bytedance.covode.number.Covode;
import com.google.gson.a.c;
import com.ss.android.ugc.aweme.shortvideo.AVChallenge;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import kotlin.h.b.n;

public final class TextStickerChallenges implements Parcelable, Serializable {
    public static final Parcelable.Creator<TextStickerChallenges> CREATOR = new C32556Of();
    @c(LIZ = "readTextChallenges")
    public final List<AVChallenge> readTextChallenges;

    static {
        Covode.recordClassIndex(118833);
    }

    public TextStickerChallenges() {
        this((List) null, 1, (2HN) null);
    }

    private Object[] LIZ() {
        return new Object[]{this.readTextChallenges};
    }

    public static /* synthetic */ TextStickerChallenges copy$default(TextStickerChallenges textStickerChallenges, List<AVChallenge> list, int i, Object obj) {
        if ((i & 1) != 0) {
            list = textStickerChallenges.readTextChallenges;
        }
        return textStickerChallenges.copy(list);
    }

    public final TextStickerChallenges copy(List<AVChallenge> list) {
        M12.LIZ(list);
        return new TextStickerChallenges(list);
    }

    public final int describeContents() {
        return 0;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof TextStickerChallenges)) {
            return false;
        }
        return M12.LIZ(((TextStickerChallenges) obj).LIZ(), LIZ());
    }

    public final int hashCode() {
        return Objects.hash(LIZ());
    }

    public final String toString() {
        return M12.LIZ("TextStickerChallenges:%s", LIZ());
    }

    public final void writeToParcel(Parcel parcel, int i) {
        M12.LIZ(parcel);
        List<AVChallenge> list = this.readTextChallenges;
        parcel.writeInt(list.size());
        for (AVChallenge writeParcelable : list) {
            parcel.writeParcelable(writeParcelable, i);
        }
    }

    public final List<String> getReadTextChallengeIds() {
        ArrayList arrayList = new ArrayList();
        List<AVChallenge> list = this.readTextChallenges;
        ListIterator<AVChallenge> listIterator = list.listIterator(list.size());
        while (listIterator.hasPrevious()) {
            AVChallenge previous = listIterator.previous();
            if (!arrayList.contains(previous.cid)) {
                String str = previous.cid;
                n.LIZIZ(str, "");
                arrayList.add(str);
            }
        }
        return arrayList;
    }

    public final List<AVChallenge> getReadTextChallenges() {
        ArrayList arrayList = new ArrayList();
        List<AVChallenge> list = this.readTextChallenges;
        ListIterator<AVChallenge> listIterator = list.listIterator(list.size());
        while (listIterator.hasPrevious()) {
            AVChallenge previous = listIterator.previous();
            if (!arrayList.contains(previous)) {
                arrayList.add(previous);
            }
        }
        return Lea.LJIIIIZZ(Lea.LJIIJJI(arrayList));
    }

    public TextStickerChallenges(List<AVChallenge> list) {
        M12.LIZ(list);
        this.readTextChallenges = list;
    }

    public final void addReadTextChallenge(AVChallenge aVChallenge) {
        M12.LIZ(aVChallenge);
        this.readTextChallenges.add(aVChallenge);
    }

    public final void removeReadTextChallenge(String str, LsC<? super AVChallenge, 2Pr> lsC) {
        M12.LIZ(str, lsC);
        for (T next : this.readTextChallenges) {
            if (n.LIZ(((AVChallenge) next).cid, str)) {
                if (next != null) {
                    this.readTextChallenges.remove(next);
                    lsC.invoke(next);
                    return;
                }
                return;
            }
        }
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public /* synthetic */ TextStickerChallenges(List list, int i, 2HN r4) {
        this((i & 1) != 0 ? new LinkedList() : list);
    }
}
