<%# locals: (script:, show_author_details: false) %>

<li data-script-id="<%= script.id %>" data-script-name="<%= script.name(request_locale) %>" data-script-authors="<%= script.users.map { |u| [u.id, u.name] }.to_h.to_json %>" data-script-daily-installs="<%= script.daily_installs %>" data-script-total-installs="<%= script.total_installs %>" data-script-rating-score="<%= script.fan_score %>" data-script-created-date="<%= script.created_at.strftime('%Y-%m-%d') %>" data-script-updated-date="<%= script.code_updated_at.strftime('%Y-%m-%d') %>" data-script-type="<%= script.script_type %>" data-script-version="<%= script.version %>" data-sensitive="<%= script.sensitive %>" data-script-language="<%= script.language %>" data-css-available-as-js="<%= script.css_convertible_to_js %>" data-code-url="<%= script.code_url %>">
  <article>
    <h2>
      <%= render_script(script) %>
      <%= render_script_badge(script.language) %>
      <% if show_author_details && script.users.include?(current_user) && script.sensitive %>
        <span class="script-type"><%= t('scripts.adult_marker') %></span>
      <% end %>
      <% case script.script_type
        when 'unlisted' %>
          <span class="script-type"><%= t('scripts.unlisted_marker') %></span>
        <% when 'library' %>
          <span class="script-type"><%= t('scripts.library_marker') %></span>
      <% end %>
      <% if script.deleted? %>
        <span class="script-type"><%= t('scripts.deleted_marker') %></span>
      <% end %>
      <% if script.locked %>
        <span class="script-type"><%= t('scripts.locked_marker') %></span>
      <% end %>
      <span class="name-description-separator">
        -
      </span>
      <span class="script-description description">
        <%= script.description(request_locale) %>
      </span>
    </h2>
    <div class="script-meta-block">
      <dl class="inline-script-stats">
        <dt class="script-list-author"><span><%= t('scripts.author_name') %></span></dt>
        <dd class="script-list-author"><span><%= script.users.map { |u| link_to(u.name, u) }.to_sentence.html_safe %></span></dd>
        <% if !script.library? %>
          <dt class="script-list-daily-installs"><span><%= t('scripts.daily_installs') %></span></dt>
          <dd class="script-list-daily-installs"><span><%= number_with_delimiter(script.daily_installs) %></span></dd>
          <dt class="script-list-total-installs"><span><%= t('scripts.total_installs') %></span></dt>
          <dd class="script-list-total-installs"><span><%= number_with_delimiter(script.total_installs) %></span></dd>
          <dt class="script-list-ratings"><span><%= t('scripts.ratings') %></span></dt>
          <dd class="script-list-ratings" data-rating-score="<%= script.fan_score %>"><span><%= render partial: 'scripts/ratings', locals: {script: script} %></span></dd>
        <% end %>
        <dt class="script-list-created-date"><span><%= t('scripts.created_date') %></span></dt>
        <dd class="script-list-created-date"><span><%= markup_date(script.created_at) %></span></dd>
        <dt class="script-list-updated-date"><span><%= t('scripts.updated_date') %></span></dt>
        <dd class="script-list-updated-date"><span><%= markup_date(script.code_updated_at) %></span></dd>
      </dl>
    </div>
  </article>
</li>
