{{#if isChatRoomLoading}}
  {{loading-spinner}}
{{/if}}

{{#if showViewerList}}
  {{chat/twitch-chat-viewers
      model=room.viewers
      toggleViewerList=(action 'toggleViewerList')
      showModOverlay=(action 'showModOverlay')}}
{{/if}}

{{#if isTagEnabledChannel}}
  {{bits/leaderboard/tag-board}}
{{/if}}

<div class="scroll chat-messages js-chat-messages {{if settings.showTimestamps 'showTimestamps' 'hideTimestamps'}} {{if settings.showModIcons 'showModIcons' 'hideModIcons'}} {{if isTagEnabledChannel 'bits-tags__offset'}} {{if settings.showTwitchBotActions 'showTwitchBotActions' 'hideTwitchBotActions'}}">
  <div class="tse-scroll-content">
    <div class="tse-content">
      {{chat/chat-display
          roomTrackingData=roomTrackingData
          messages=room.messages
          currentUserNick=tmiSession.nickname
          hideLinks=room.roomProperties.hide_chat_links
          chatDelayDuration=room.roomProperties.chat_delay_duration
          canModerate=room.isModeratorOrHigher
          isTwitchPrivilegedUser=room.isTwitchPrivilegedUser
          isFlashDisabled=isFlashDisabled
          flashTimedOut=room.flashTimedOut
          isDarkMode=settings.darkMode
          showModOverlay=(action 'showModOverlay')
          banUser=(action 'banUser')
          unbanUser=(action 'unbanUser')
          timeoutUser=(action 'timeoutUser')
          clickSubscriber=(action 'clickSubscriber')
          showMessageFlags=settings.showMessageFlags
          showModerationActions=settings.showModerationActions
          showTwitchBotActions=settings.showTwitchBotActions
      }}
    </div>
  </div>
</div>

{{#if showModerationCard}}
  {{chat/moderation-card
      cardInfo=moderationCardInfo
      closeAction=(action 'closeModerationCard')
      messageAction=(action 'messageUser')
      ignoreAction=(action 'ignoreUser')
      unignoreAction=(action 'unignoreUser')
      banAction=(action 'banUser')
      modAction=(action 'modUser')
      timeoutAction=(action 'timeoutUser')
      trackAction=(action 'moderationCardTracking')
      trackFollowButtonAction=(action 'trackChannelEvent' target=tracking)}}
{{/if}}

<div class="notification-container ontop {{if interactionsExist 'open'}} {{if newInteractionsExist 'new-interactions-exist'}}">
  <div class="top-notification game-commands-notification" {{action 'toggleInteractions'}}>
    <p>{{i18n 'Interactions available'}}</p>
  </div>
</div>

<div class="chat-commands-dropdown {{if showInteractions '' 'hidden'}}">
  <ul>
    {{#if visibleInteractions.sce_title_preset_text_1}}
      <li {{action 'interact' 'sce_title_preset_text_1'}}>
        <p>{{visibleInteractions.sce_title_preset_text_1}}</p>
      </li>
    {{/if}}

    {{#if visibleInteractions.sce_title_preset_text_2}}
      <li {{action 'interact' 'sce_title_preset_text_2'}}>
        <p>{{visibleInteractions.sce_title_preset_text_2}}</p>
      </li>
    {{/if}}

    {{#if visibleInteractions.sce_title_preset_text_3}}
      <li {{action 'interact' 'sce_title_preset_text_3'}}>
        <p>{{visibleInteractions.sce_title_preset_text_3}}</p>
      </li>
    {{/if}}

    {{#if visibleInteractions.sce_title_preset_text_4}}
      <li {{action 'interact' 'sce_title_preset_text_4'}}>
        <p>{{visibleInteractions.sce_title_preset_text_4}}</p>
      </li>
    {{/if}}

    {{#if visibleInteractions.sce_title_preset_text_5}}
      <li {{action 'interact' 'sce_title_preset_text_5'}}>
        <p>{{visibleInteractions.sce_title_preset_text_5}}</p>
      </li>
    {{/if}}
  </ul>
</div>

{{#if showResubNotification}}
  {{chat/resub-notification
      channelName=room.name
      resubNotification=resubNotification
      closeResubNotification=(action 'closeResubNotification')
      postResubMessage=(action 'postResubMessage')}}
{{/if}}

{{#if (and showHostingNotification (not applicationController.isChatApp))}}
  {{chat/host-mode-notification
    hostModeTargetName=room.channel.newChannel.hostModeTarget.name
    close=(action 'closeHostingNotification')}}
{{/if}}

{{#if showBLCNotification}}
  {{chat/blc-notification
      restrictedLanguage=room.restrictedChatLanguage
      channelName=room.id
      bilingualClick=(action 'bilingualClick')
      close=(action 'blcNotificationClose')}}
{{else if showNBNotification}}
  {{chat/native-broadcast-notification
      channelName=room.id
      close=(action 'nbNotificationClose')
  }}
{{else if showVPNotification}}
  {{chat/viewing-party-notification
      channelName=room.id
      close=(action 'vpNotificationClose')
  }}
{{else if showARNotification}}
  {{chat/alt-role-notification
      channelName=room.id
      close=(action 'arNotificationClose')
  }}
{{/if}}

{{#if showDisplayNameNotification}}
  {{chat/displayname-notification
      broadcasterLanguage=room.restrictedChatLanguage
      openInModal=(action 'openInModal')
      closeModal=(action 'closeModal')
      close=(action 'displaynameNotificationClose')}}
{{/if}}


{{#if showTwitchBotModNotification}}
  {{chat/twitchbot-mod-notification
    close=(action 'twitchBotModNotificationClose')}}
{{/if}}

{{#if showTwitchBotBroadcasterNotification}}
  {{chat/twitchbot-broadcaster-notification
    close=(action 'twitchBotBroadcasterNotificationClose')}}
{{/if}}

{{#if showPinnedCheers}}
  {{bits/pinned-cheers/anchor
    channelId=room.roomProperties._id
    roomTrackingData=roomTrackingData
    currentUserNick=tmiSession.nickname
    currentUserDisplayname=session.userData.name
    hideLinks=room.roomProperties.hide_chat_links
    chatDelayDuration=room.roomProperties.chat_delay_duration
    canModerate=room.isModeratorOrHigher
    isTwitchPrivilegedUser=room.isTwitchPrivilegedUser
    isFlashDisabled=isFlashDisabled
    flashTimedOut=room.flashTimedOut
    showModOverlay=(action 'showModOverlay')
    showResetTopCheer=(action 'showResetTopCheer')
    banUser=(action 'banUser')
    unbanUser=(action 'unbanUser')
    timeoutUser=(action 'timeoutUser')
    clickSubscriber=(action 'clickSubscriber')
    adjustContainer=(action 'accommodatePinnedMessage')}}
{{/if}}

{{#if showResetTopCheerConfirmation}}
  {{bits/pinned-cheers/reset-top-cheer-dialog
    options=resetTopCheerConfirmationInfo
    hide=(action 'hideResetTopCheer')}}
{{/if}}

<div class="chat-helpers">
  {{from-elsewhere name='chat-helpers'}}
</div>

<div class="chat-interface">
  {{#unless room.isLoading}}
    {{#if room.shouldDisplayChatRules}}
      {{chat/chat-rules
          chatRules=room.chatRules
          acceptChatRules=(action 'acceptChatRules')
      }}
    {{/if}}
  {{/unless}}

  {{#if (not stuckToBottom)}}
    <span {{action 'scrollToBottom'}}>
      <div class="more-messages-indicator visible js-chat-more-messages">
        {{i18n 'More messages below.'}}
      </div>
    </span>
  {{/if}}

  {{chat/chat-interface
      room=room
      tmiSession=tmiSession

      hideChat=(action hideChat)
      popoutChat=(action popoutChat)

      isFlashDisabled=isFlashDisabled
      isRoomModelLoading=isRoomModelLoading
      sendMessage=(action 'sendMessage')
      toggleViewerList=(action 'toggleViewerList')

      showEmoticonSelector=showEmoticonSelector

      focusChatInputWindow=(action 'focusChatInputWindow')
      toggleEmoticonSelector=(action 'toggleEmoticonSelector')

      isDarkMode=isDarkMode
  }}
</div>
