<h3>Weight Class:<%= @weight.max %> <% if can? :manage, @tournament %><%= link_to edit_weight_path(@weight), class: "text-decoration-none" do %><span class="fas fa-edit" aria-hidden="true"></span><% end %><% end %></h3>
<br>
<br>
<%= form_tag @wrestlers_update_path do %>
  <table class="table table-hover table-condensed">
  	<thead>
  		<tr>
  			<th>Name</th>
  			<th>School</th>
  			<th>Seed</th>
  			<th>Record</th>
  			<th>Seed Criteria</th>
  			<th>Extra?</th>
  		</tr>
  	</thead>
  	<tbody>
      <% sorted_wrestlers = @wrestlers.sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]} %>
      <% if can? :manage, @tournament %>
        <% sorted_wrestlers.each do |wrestler| %>
          <% if wrestler.weight_id == @weight.id %>
            <tr>
              <td><%= link_to wrestler.name, wrestler %></td>
              <td><%= wrestler.school.name %></td>
              <td>
                <%= fields_for "wrestler[]", wrestler do |w| %>
                  <%= w.text_field :original_seed %>
                <% end %>
              </td>
              <td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
              <td><%= wrestler.criteria %> Win <%= wrestler.season_win_percentage %>%</td>
              <td><%= "Yes" if wrestler.extra? %></td>
              <td>
                <%= link_to wrestler, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{wrestler.name}? THIS WILL DELETE ALL MATCHES." }, class: "text-decoration-none" do %>
                  <span class="fas fa-trash-alt" aria-hidden="true"></span>
                <% end %>
              </td>
            </tr>
          <% end %>
        <% end %>
      <% else %>
        <% sorted_wrestlers.each do |wrestler| %>
          <% if wrestler.weight_id == @weight.id %>
            <%= render "weights/readonly_wrestler_row", wrestler: wrestler %>
          <% end %>
        <% end %>
      <% end %>
    	</tbody>
  </table>
<br><p>*All wrestlers without a seed (determined by tournament director) will be assigned a random bracket line.</p>
		<% if can? :manage, @tournament %>
		<br>
	      <%= submit_tag "Save Seeds", :class=>"btn btn-success"%>
	    <% end %>
    <% end %>
<br>
<% if @tournament.tournament_type == "Pool to bracket" %>
<div>
  <strong>Pool assignments by seed:</strong>
  <ul>
    <li>Two Pools
      <ul>
        <li>Pool 1: Seed 1 & 4</li>
        <li>Pool 2: Seed 2 & 3</li>
      </ul>
    </li>
    <li>Four Pools
      <ul>
        <li>Pool 1: Seed 1 & 8</li>
        <li>Pool 2: Seed 2 & 7</li>
        <li>Pool 3: Seed 3 & 6</li>
        <li>Pool 4: Seed 4 & 5</li>
      </ul>
    </li>
    <li>Eight Pools
      <ul>
        <li>Pool 1: Seed 1</li>
        <li>Pool 2: Seed 2</li>
        <li>Pool 3: Seed 3</li>
        <li>Pool 4: Seed 4</li>
        <li>Pool 5: Seed 5</li>
        <li>Pool 6: Seed 6</li>
        <li>Pool 7: Seed 7</li>
        <li>Pool 8: Seed 8</li>
      </ul>
    </li>
</div>
<% end %>
