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

import X.C6037FGf;
import X.C6043FGl;
import X.C6051FGt;
import X.C6061FHd;
import X.FGW;
import X.FHC;
import X.Lnj;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.innerpush.api.IInnerPushService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class InnerPushServiceImpl implements IInnerPushService {
    static {
        Covode.recordClassIndex(88584);
    }

    public final void LIZ() {
        FHC.LIZJ.LIZ();
    }

    public static IInnerPushService LIZIZ() {
        MethodCollector.i(2886);
        IInnerPushService iInnerPushService = (IInnerPushService) Lnj.LIZ(IInnerPushService.class, false);
        if (iInnerPushService != null) {
            MethodCollector.o(2886);
            return iInnerPushService;
        }
        Object LIZIZ = Lnj.LIZIZ(IInnerPushService.class, false);
        if (LIZIZ != null) {
            IInnerPushService iInnerPushService2 = (IInnerPushService) LIZIZ;
            MethodCollector.o(2886);
            return iInnerPushService2;
        }
        if (Lnj.LLLLIILLL == null) {
            synchronized (IInnerPushService.class) {
                try {
                    if (Lnj.LLLLIILLL == null) {
                        Lnj.LLLLIILLL = new InnerPushServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(2886);
                    throw th;
                }
            }
        }
        InnerPushServiceImpl innerPushServiceImpl = (InnerPushServiceImpl) Lnj.LLLLIILLL;
        MethodCollector.o(2886);
        return innerPushServiceImpl;
    }

    public final boolean LIZ(JSONObject jSONObject) {
        return C6043FGl.LIZIZ.LIZ(jSONObject);
    }

    public final boolean LIZ(boolean z) {
        return C6037FGf.LIZIZ.LIZ(z);
    }

    public final void LIZ(C6061FHd fHd) {
        M12.LIZ(fHd);
        C6051FGt fGt = C6051FGt.LIZIZ;
        M12.LIZ(fHd);
        if (!C6051FGt.LIZ.isEmpty()) {
            C6051FGt.LIZ.remove(fHd);
        }
        if (!fGt.LIZ().isEmpty()) {
            for (Map.Entry<Integer, List<C6061FHd>> value : fGt.LIZ().entrySet()) {
                ((List) value.getValue()).remove(fHd);
            }
        }
    }

    public final void LIZ(boolean z, boolean z2) {
        FGW.LIZ = z;
        if (z) {
            C6051FGt.LIZIZ.LIZ(22);
        } else {
            C6051FGt.LIZIZ.LIZIZ(22);
        }
    }

    public final void LIZIZ(boolean z, boolean z2) {
        FGW.LIZIZ = z;
        if (z) {
            C6051FGt.LIZIZ.LIZ(23);
        } else {
            C6051FGt.LIZIZ.LIZIZ(23);
        }
    }

    public final void LIZJ(boolean z, boolean z2) {
        FGW.LIZJ = z;
        if (z) {
            C6051FGt.LIZIZ.LIZ(21);
        } else {
            C6051FGt.LIZIZ.LIZIZ(21);
        }
    }

    public final void LIZ(C6061FHd fHd, int[] iArr) {
        M12.LIZ(fHd);
        M12.LIZ(fHd);
        if (iArr == null || iArr.length == 0) {
            List<C6061FHd> list = C6051FGt.LIZ;
            if (!(list instanceof Collection) || !list.isEmpty()) {
                Iterator<T> it = list.iterator();
                while (it.hasNext()) {
                    if (n.LIZ(it.next(), fHd)) {
                        return;
                    }
                }
            }
            C6051FGt.LIZ.add(fHd);
            return;
        }
        for (int i : iArr) {
            List list2 = C6051FGt.LIZIZ.LIZ().get(Integer.valueOf(i));
            if (list2 == null || list2.isEmpty()) {
                list2 = new ArrayList();
                list2.add(fHd);
            } else {
                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                    Iterator it2 = list2.iterator();
                    while (true) {
                        if (it2.hasNext()) {
                            if (n.LIZ(it2.next(), fHd)) {
                                break;
                            }
                        } else {
                            break;
                        }
                    }
                }
                list2.add(fHd);
            }
            C6051FGt.LIZIZ.LIZ().put(Integer.valueOf(i), list2);
        }
    }
}
