package com.ss.android.ugc.aweme.kids.commonfeed.report;

import X.C10902ks;
import X.C10912kt;
import X.LeS;
import X.LeY;
import X.Lea;
import X.Lnj;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.keva.Keva;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.kids.common.services.IReportAwemeManager;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import kotlin.h.b.n;

public final class ReportAwemeManager implements IReportAwemeManager {
    public static final C10902ks LIZ = new C10902ks((byte) 0);
    public static final C10912kt LIZIZ = new C10912kt();

    static {
        Covode.recordClassIndex(89501);
    }

    public static IReportAwemeManager LIZ() {
        MethodCollector.i(8992);
        IReportAwemeManager iReportAwemeManager = (IReportAwemeManager) Lnj.LIZ(IReportAwemeManager.class, false);
        if (iReportAwemeManager != null) {
            MethodCollector.o(8992);
            return iReportAwemeManager;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IReportAwemeManager.class, false);
        if (LIZIZ2 != null) {
            IReportAwemeManager iReportAwemeManager2 = (IReportAwemeManager) LIZIZ2;
            MethodCollector.o(8992);
            return iReportAwemeManager2;
        }
        if (Lnj.LLLLLL == null) {
            synchronized (IReportAwemeManager.class) {
                try {
                    if (Lnj.LLLLLL == null) {
                        Lnj.LLLLLL = new ReportAwemeManager();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(8992);
                    throw th;
                }
            }
        }
        ReportAwemeManager reportAwemeManager = (ReportAwemeManager) Lnj.LLLLLL;
        MethodCollector.o(8992);
        return reportAwemeManager;
    }

    public final List<Aweme> LIZ(List<? extends Aweme> list) {
        String[] LIZ2;
        Set LJIIL;
        M12.LIZ(list);
        List<Aweme> LJII = Lea.LJII(list);
        Iterator<Aweme> it = LJII.iterator();
        while (it.hasNext()) {
            String aid = it.next().getAid();
            n.LIZIZ(aid, "");
            C10912kt r1 = LIZIZ;
            if (r1.LIZJ != null) {
                LIZ2 = r1.LIZJ;
            } else {
                LIZ2 = r1.LIZ();
            }
            if (!(LIZ2 == null || (LJIIL = LeY.LJIIL(LIZ2)) == null || !LJIIL.contains(aid))) {
                it.remove();
            }
        }
        return LJII;
    }

    public final void LIZ(String str) {
        M12.LIZ(str);
        C10912kt r6 = LIZIZ;
        M12.LIZ(str);
        if (r6.LIZIZ.getStringArray("report_aweme_list", (String[]) null) == null) {
            List LIZJ = LeS.LIZJ(new String[]{str});
            Keva keva = r6.LIZIZ;
            Object[] array = LIZJ.toArray(new String[0]);
            Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
            keva.storeStringArray("report_aweme_list", (String[]) array);
            return;
        }
        String[] stringArray = r6.LIZIZ.getStringArray("report_aweme_list", (String[]) null);
        n.LIZIZ(stringArray, "");
        r6.LIZ = LeY.LJIIJJI(stringArray);
        List<String> list = r6.LIZ;
        if (list != null) {
            list.add(str);
            Keva keva2 = r6.LIZIZ;
            Object[] array2 = list.toArray(new String[0]);
            Objects.requireNonNull(array2, "null cannot be cast to non-null type kotlin.Array<T>");
            keva2.storeStringArray("report_aweme_list", (String[]) array2);
        }
    }
}
