package com.bytedance.android.live;

import X.AnonymousClass053;
import X.AnonymousClass0AA;
import X.C09320Zu;
import X.C10000b0;
import X.C11100cm;
import X.C11110cn;
import X.HEP;
import X.M12;
import android.content.Context;
import com.bytedance.android.live.base.model.emoji.EmoteModel;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.livesdk.api.revenue.subscription.ISubscribeService;
import com.bytedance.android.livesdk.chatroom.event.ISendCommentEvent;
import com.bytedance.android.livesdk.chatroom.viewmodule.CommentWidget;
import com.bytedance.android.livesdk.chatroom.viewmodule.QuickCommentWidget;
import com.bytedance.android.livesdk.livesetting.other.subscribe.SubscribeShortPaySetting;
import com.bytedance.android.livesdk.livesetting.watchlive.LiveSubscribeLynxUrl;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannelGlobal;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import emotes.ui.EmotePreviewDialog;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import kotlin.h.b.n;

public class CommentService implements ICommentService {
    public final AnonymousClass053<C09320Zu> commentConsumers = new AnonymousClass053<>();
    public final List<C11110cn> commentEventListeners = new ArrayList();

    static {
        Covode.recordClassIndex(4687);
    }

    public void onInit() {
    }

    public Class<? extends LiveRecyclableWidget> getCommentWidget() {
        return CommentWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getQuickCommentWidget() {
        return QuickCommentWidget.class;
    }

    public final void notifyOnCommentSending() {
        for (C11110cn LIZ : this.commentEventListeners) {
            LIZ.LIZ();
        }
    }

    public final void unregisterCommentConsumer(long j) {
        this.commentConsumers.LIZIZ(j);
    }

    public void addCommentEventListener(C11110cn r2) {
        M12.LIZ(r2);
        this.commentEventListeners.add(r2);
    }

    public void removeCommentEventListener(C11110cn r2) {
        M12.LIZ(r2);
        this.commentEventListeners.remove(r2);
    }

    public final void registerCommentConsumer(long j, C09320Zu r4) {
        M12.LIZ(r4);
        this.commentConsumers.LIZIZ(j, r4);
    }

    public void sendComment(long j, String str, ISendCommentEvent.Sender sender) {
        String str2 = str;
        ISendCommentEvent.Sender sender2 = sender;
        M12.LIZ(str2, sender2);
        sendComment(j, str2, 0, sender2);
    }

    public void showEmoteDetailDialog(EmoteModel emoteModel, AnonymousClass0AA r11, boolean z) {
        M12.LIZ(emoteModel, r11);
        Room room = (Room) DataChannelGlobal.LIZLLL.LIZIZ(HEP.class);
        if (room != null && room.getOwner() != null) {
            User owner = room.getOwner();
            n.LIZIZ(owner, "");
            if (owner.isAnchorHasSubQualification()) {
                if (SubscribeShortPaySetting.INSTANCE.getValue()) {
                    User owner2 = room.getOwner();
                    n.LIZIZ(owner2, "");
                    if (!owner2.isSubscribed() && !z) {
                        String anchor_user_badge_or_emotes_subscribe = LiveSubscribeLynxUrl.INSTANCE.getValue().getAnchor_user_badge_or_emotes_subscribe();
                        LinkedHashMap linkedHashMap = new LinkedHashMap();
                        linkedHashMap.put("page_type", "emotes");
                        Context LJ = C10000b0.LJ();
                        n.LIZIZ(LJ, "");
                        C11100cm.LIZ(ISubscribeService.class).openLiveRoomSubscribeLynx(LJ, room, anchor_user_badge_or_emotes_subscribe, "emote_preview", linkedHashMap);
                        return;
                    }
                }
                EmotePreviewDialog emotePreviewDialog = new EmotePreviewDialog();
                if (emoteModel != null) {
                    emotePreviewDialog.LIZLLL = emoteModel;
                }
                String simpleName = EmotePreviewDialog.class.getSimpleName();
                n.LIZIZ(simpleName, "");
                emotePreviewDialog.show(r11, simpleName);
            }
        }
    }

    public void sendComment(long j, String str, int i, ISendCommentEvent.Sender sender) {
        M12.LIZ(str, sender);
        C09320Zu LIZ = this.commentConsumers.LIZ(j, null);
        if (LIZ != null) {
            LIZ.LIZ(str, i, sender);
        }
    }

    public void sendComment(long j, List<? extends EmoteModel> list, int i, ISendCommentEvent.Sender sender) {
        M12.LIZ(list, sender);
        C09320Zu LIZ = this.commentConsumers.LIZ(j, null);
        if (LIZ != null) {
            LIZ.LIZ(list, sender);
        }
    }
}
