<%# locals: (import:) %>
<% dry_run = import.dry_run %>
<% resources_with_counts = dry_run.select { |_, count| count > 0 }.filter_map { |key, count| [dry_run_resource(key), count] if dry_run_resource(key) } %>
<% import_summary_empty = resources_with_counts.empty? %>

<div class="text-center space-y-2 mb-4 mx-auto max-w-md">
  <h1 class="text-3xl text-primary font-medium"><%= t(".title") %></h1>
  <p class="text-secondary text-sm"><%= t(".description") %></p>
</div>

<div class="mx-auto max-w-2xl space-y-4">
  <div class="bg-container-inset rounded-xl p-1 space-y-1">
    <div class="flex justify-between items-center text-xs font-medium text-secondary uppercase px-5 py-3">
      <p><%= t(".summary_item_label") %></p>
      <p class="justify-self-end"><%= t(".summary_count_label") %></p>
    </div>

    <div class="bg-container shadow-border-xs rounded-lg text-sm">
      <% if import_summary_empty %>
        <div class="px-5 py-8 text-center space-y-2">
          <p class="text-primary text-sm"><%= t(".empty_summary") %></p>
        </div>
      <% else %>
        <% resources_with_counts.each_with_index do |(resource, count), index| %>
          <div class="flex items-center justify-between gap-2 bg-container px-5 py-3 rounded-lg">
            <div class="flex items-center gap-3">
              <%= tag.div class: class_names(resource.bg_class, resource.text_class, "w-8 h-8 rounded-full flex justify-center items-center") do %>
                <%= icon resource.icon, color: "current" %>
              <% end %>

              <p><%= resource.label %></p>
            </div>

            <p class="justify-self-end"><%= count %></p>
          </div>

          <% unless index == resources_with_counts.length - 1 %>
            <%= render "shared/ruler" %>
          <% end %>
        <% end %>
      <% end %>
    </div>
  </div>

  <% if import_summary_empty %>
    <%= render DS::Button.new(text: t(".back_to_imports"), href: imports_path, variant: :secondary, full_width: true) %>
  <% else %>
    <%= render DS::Button.new(text: t(".publish_import"), href: publish_import_path(import), method: :post, full_width: true) %>
  <% end %>
</div>
