package com.ss.android.ugc.aweme.commercialize.egg.impl.service;

import X.9n5;
import X.C3463LMg;
import X.C3466LMj;
import X.C3547LPm;
import X.C3548LPn;
import X.C3549LPo;
import X.C3552LPr;
import X.C3557LPw;
import X.C4672Lnj;
import X.LLR;
import X.LQ1;
import X.M12;
import android.text.TextUtils;
import android.view.ViewStub;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.commercialize.egg.service.ICommerceEggService;
import com.ss.android.ugc.aweme.feed.model.EditHint;
import com.ss.android.ugc.aweme.feed.model.ItemCommentEggGroup;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class CommerceEggServiceImpl implements ICommerceEggService {
    static {
        Covode.recordClassIndex(58571);
    }

    public final C3466LMj LIZIZ() {
        return C3463LMg.LIZ;
    }

    public final void LIZ() {
        C3549LPo.LIZLLL = null;
        C3549LPo.LIZJ = null;
    }

    public static ICommerceEggService LIZJ() {
        MethodCollector.i(5615);
        ICommerceEggService iCommerceEggService = (ICommerceEggService) C4672Lnj.LIZ(ICommerceEggService.class, false);
        if (iCommerceEggService != null) {
            MethodCollector.o(5615);
            return iCommerceEggService;
        }
        Object LIZIZ = C4672Lnj.LIZIZ(ICommerceEggService.class, false);
        if (LIZIZ != null) {
            ICommerceEggService iCommerceEggService2 = (ICommerceEggService) LIZIZ;
            MethodCollector.o(5615);
            return iCommerceEggService2;
        }
        if (C4672Lnj.LJLJLLL == null) {
            synchronized (ICommerceEggService.class) {
                try {
                    if (C4672Lnj.LJLJLLL == null) {
                        C4672Lnj.LJLJLLL = new CommerceEggServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(5615);
                    throw th;
                }
            }
        }
        CommerceEggServiceImpl commerceEggServiceImpl = (CommerceEggServiceImpl) C4672Lnj.LJLJLLL;
        MethodCollector.o(5615);
        return commerceEggServiceImpl;
    }

    public final 9n5 LIZ(ViewStub viewStub) {
        M12.LIZ((Object) viewStub);
        return new C3552LPr(viewStub);
    }

    public final void LIZ(LQ1 lq1) {
        M12.LIZ((Object) lq1);
        C3557LPw.LIZ.LIZ(lq1);
    }

    public final String LIZ(String str) {
        boolean z;
        List<? extends EditHint> list;
        if (str == null || str.length() == 0) {
            z = true;
        } else {
            z = false;
        }
        if (z || (list = C3549LPo.LIZLLL) == null) {
            return null;
        }
        for (EditHint next : list) {
            if (TextUtils.equals(str, next.getLanguage())) {
                return next.getHint();
            }
        }
        return null;
    }

    public final void LIZ(C3547LPm lPm, String str) {
        M12.LIZ((Object) str);
        if (lPm != null && !TextUtils.isEmpty(lPm.LIZIZ) && !TextUtils.isEmpty(lPm.LIZ)) {
            int hashCode = str.hashCode();
            if (hashCode != -906336856) {
                if (hashCode == 3321751 && str.equals("like")) {
                    if (lPm == null) {
                        lPm = null;
                    } else if (lPm.LJI) {
                        C3548LPn.LIZ.LIZ(lPm);
                    }
                    C3549LPo.LIZ = lPm;
                }
            } else if (str.equals("search")) {
                if (lPm == null) {
                    lPm = null;
                } else if (lPm.LJI) {
                    C3548LPn.LIZ.LIZ(lPm);
                }
                C3549LPo.LIZIZ = lPm;
            }
        }
    }

    public final void LIZ(String str, String str2, ItemCommentEggGroup itemCommentEggGroup) {
        List<? extends EditHint> list;
        if (itemCommentEggGroup != null) {
            List<T> commentEggData = itemCommentEggGroup.getCommentEggData();
            if (commentEggData != null) {
                ArrayList arrayList = new ArrayList();
                for (T t : commentEggData) {
                    if (C3549LPo.LJ.LIZ(t)) {
                        LLR llr = new LLR();
                        n.LIZIZ(t, "");
                        llr.LIZ = t;
                        llr.LIZIZ = true;
                        llr.LIZ(str);
                        llr.LIZIZ(str2);
                        C3547LPm LIZ = llr.LIZ();
                        arrayList.add(LIZ);
                        C3548LPn.LIZ.LIZ(LIZ);
                    }
                }
                C3549LPo.LIZJ = arrayList;
            }
            list = itemCommentEggGroup.getEditintist();
        } else {
            list = null;
        }
        C3549LPo.LIZLLL = list;
    }
}
