<% cache "tag-sidebar-#{@tag}-#{@tag_model&.updated_at}-#{@tag_model&.taggings_count}", expires_in: 5.hours do %>
  <div id="sidebar-wrapper-left" class="sidebar-wrapper sidebar-wrapper-left">
    <div class="sidebar-bg" id="sidebar-bg-left"></div>
    <div class="side-bar">
      <% if @tag_model && @tag_model.short_summary.present? %>
        <div class="widget">
          <header>
            <h4>#<%= @tag %> 👋</h4>
          </header>
          <div class="widget-body">
            <%= @tag_model.short_summary.html_safe %>
          </div>
        </div>
      <% end %>
      <% if @tag_model && @tag_model.rules_html.present? %>
        <div class="widget">
          <header>
            <h4>submission guidelines</h4>
          </header>
          <div class="widget-body">
            <%= @tag_model.rules_html.html_safe %>
            <a class="cta cta-button" href="/new/<%= @tag %>">
              WRITE A POST
            </a>
          </div>
        </div>
      <% end %>
      <% if @tag_model && @tag_model.wiki_body_html.present? %>
        <div class="widget">
          <header>
            <h4>about #<%= @tag %></h4>
          </header>
          <div class="widget-body">
            <%= @tag_model.wiki_body_html.html_safe %>
          </div>
        </div>
      <% end %>
      <% if @tag_model.sponsorship && @tag_model.sponsorship.status == "live" && @tag_model.sponsorship.expires_at > Time.current %>
        <div class="widget">
          <header>
            <h4><%= @tag %> is sponsored by</h4>
          </header>
          <div class="widget-body">
            <%= render "articles/single_sponsor", sponsorship: @tag_model.sponsorship %>
          </div>
        </div>
      <% end %>
      <% if @moderators.present? %>
        <div class="widget">
          <header>
            <h4>tag moderators</h4>
          </header>
          <div class="widget-body">
            <% @moderators.each do |user| %>
              <div class="widget-user-pic">
                <a href="/<%= user.username %>" title="<%= user.username %>">
                  <img src="<%= ProfileImage.new(user).get(90) %>" alt="<%= user.username %> profile image">
                </a>
              </div>
            <% end %>
          </div>
        </div>
      <% end %>
      <div class="sidebar-data">
        <div>
          <%= pluralize Article.published.cached_tagged_with(@tag).size, "Post" %> Published
        </div>
        <% if user_signed_in? %>
          <span style="display:none;" id="tag-edit-button" data-tag="<%= @tag_model.name %>">
            <a class="cta mod-action-button" href="/t/<%= @tag_model.name %>/edit" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
              EDIT
            </a>
          </span>
          <span style="display:none;" id="tag-mod-button" data-tag="<%= @tag_model.name %>">
            <a class="cta mod-action-button" href="/mod?tag=<%= @tag_model.name %>" style="color:<%= @tag_model.text_color_hex %>;background-color:<%= @tag_model.bg_color_hex %>">
              MODERATE
            </a>
          </span>
        <% end %>
      </div>
    </div>
  </div>
<% end %>
