package com.ss.android.ugc.aweme.commercialize_x.service;

import X.4DQ;
import X.BS3;
import X.BS4;
import X.C02399vf;
import X.C02459vl;
import X.C02469vm;
import X.C3637BRx;
import X.C3638BRy;
import X.C3639BRz;
import X.K8W;
import X.Lnj;
import X.M12;
import android.app.Application;
import android.content.Context;
import android.util.SparseArray;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.commercialize_ad_api.service.ICommercializeAdService;

public final class CommercializeAdServiceImpl implements ICommercializeAdService {
    public final 4DQ LIZ = K8W.LIZ(C3638BRy.LIZ);
    public boolean LIZIZ;

    static {
        Covode.recordClassIndex(60223);
    }

    private final void LIZIZ() {
        MethodCollector.i(10247);
        if (!this.LIZIZ) {
            synchronized (this) {
                try {
                    if (!this.LIZIZ) {
                        C3637BRx.LIZ.LIZ();
                        this.LIZIZ = true;
                    }
                } finally {
                    MethodCollector.o(10247);
                }
            }
            return;
        }
        MethodCollector.o(10247);
    }

    public static ICommercializeAdService LIZ() {
        MethodCollector.i(10248);
        ICommercializeAdService iCommercializeAdService = (ICommercializeAdService) Lnj.LIZ(ICommercializeAdService.class, false);
        if (iCommercializeAdService != null) {
            MethodCollector.o(10248);
            return iCommercializeAdService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(ICommercializeAdService.class, false);
        if (LIZIZ2 != null) {
            ICommercializeAdService iCommercializeAdService2 = (ICommercializeAdService) LIZIZ2;
            MethodCollector.o(10248);
            return iCommercializeAdService2;
        }
        if (Lnj.LL == null) {
            synchronized (ICommercializeAdService.class) {
                try {
                    if (Lnj.LL == null) {
                        Lnj.LL = new CommercializeAdServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(10248);
                    throw th;
                }
            }
        }
        CommercializeAdServiceImpl commercializeAdServiceImpl = (CommercializeAdServiceImpl) Lnj.LL;
        MethodCollector.o(10248);
        return commercializeAdServiceImpl;
    }

    private final C02459vl LIZ(BS3 bs3) {
        LIZIZ();
        return C3637BRx.LIZ(bs3.LIZ());
    }

    public final BS4 LIZ(int i) {
        SparseArray<BS4> LIZIZ2;
        C3639BRz bRz = (C3639BRz) this.LIZ.LIZ();
        if (bRz == null || (LIZIZ2 = bRz.LIZIZ()) == null) {
            return null;
        }
        return LIZIZ2.get(i);
    }

    public final C02469vm LIZIZ(Context context, BS3 bs3) {
        M12.LIZ(bs3);
        C02459vl LIZ2 = LIZ(bs3);
        if (LIZ2 != null) {
            return LIZ2.LIZIZ(context, bs3);
        }
        return null;
    }

    public final C02399vf<?> LIZ(Context context, BS3 bs3) {
        M12.LIZ(context, bs3);
        C02459vl LIZ2 = LIZ(bs3);
        if (LIZ2 != null) {
            return LIZ2.LIZ(context, bs3);
        }
        return null;
    }

    public final void LIZ(Application application, C3639BRz bRz, boolean z) {
        M12.LIZ(application, bRz);
        this.LIZ.LIZ(bRz);
        if (z) {
            LIZIZ();
        }
    }
}
