<commit_before><% content_for :title do %>
  <% "OpenSplitTime: Show lottery - #{@presenter.name}" %>
<% end %>

<header class="ost-header">
  <div class="container">
    <div class="ost-heading row">
      <div class="col">
        <div class="ost-title">
          <h1><strong><%= @presenter.name %></strong></h1>
          <ul class="breadcrumb breadcrumb-ost">
            <li class="breadcrumb-item"><%= link_to "Organizations", organizations_path %></li>
            <li class="breadcrumb-item"><%= link_to @presenter.organization.name, organization_lotteries_path(@presenter.organization) %></li>
            <li class="breadcrumb-item"><%= link_to "Lotteries", organization_lotteries_path(@presenter.organization) %></li>
            <li class="breadcrumb-item"><%= @presenter.name %></li>
          </ul>
        </div>
        <div class="ost-subtitle">
          <p><%= l(@presenter.scheduled_start_date, format: :full_with_weekday) %></p>
        </div>
      </div>
      <aside class="col-auto text-right">
        <% if current_user&.authorized_for_lotteries?(@presenter.organization) %>
          <%= link_to "Admin", setup_organization_lottery_path(@presenter.organization, @presenter.lottery), class: "btn btn-outline-secondary" %>
        <% end %>
      </aside>
    </div>
    <% if @presenter.viewable_results? %>
      <% if @presenter.display_style == "draws" %>
        <div class="mb-4">
          <%= link_to "Browse Entrants and Results", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :entrants), class: "btn btn-success btn-block font-weight-bold" %>
        </div>
      <% else %>
        <div>
          <%= link_to "View Draws", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :draws), class: "btn btn-outline-secondary btn-block text-success font-weight-bold" %>
        </div>
      <% end %>
    <% end %>
    <!-- Navigation -->
    <% unless @presenter.display_style == "draws" %>
      <ul class="nav nav-tabs nav-tabs-ost">
        <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'entrants'}" do
          link_to "Entrants", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :entrants)
        end %>
        <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'tickets'}" do
          link_to "Tickets", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :tickets)
        end %>
        <% if @presenter.viewable_results? %>
          <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'results'}" do
            link_to "Results", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :results)
          end %>
        <% end %>
      </ul>
    <% end %>
  </div>
</header>

<article class="ost-article container">
  <% case @presenter.display_style %>
  <% when "entrants" %>
    <aside class="ost-toolbar">
      <div class="container">
        <div class="row">
          <div class="col-12 col-md-6 form-inline">
            <%= render "lottery_entrants/entrant_lookup" %>
          </div>
        </div>
      </div>
    </aside>

    <% if @presenter.lottery_entrants_paginated.present? %>
      <div data-controller="infinite-scroll"
           data-infinite-scroll-next-page-url="<%= @presenter.next_page_url %>"
           data-infinite-scroll-html-template="lottery_entrants/lottery_entrant">
        <div data-infinite-scroll-target="result">
          <%= render partial: "lottery_entrants/lottery_entrant", collection: @presenter.lottery_entrants_paginated, as: :record %>
        </div>
        <hr/>

        <div class="row">
          <div class="col text-center" data-infinite-scroll-target="link">
            <% if @presenter.next_page_url.present? %>
              <%= link_to "Show More", @presenter.next_page_url, data: {action: "infinite-scroll#loadFromClick"} %>
            <% else %>
              <p>End of List</p>
            <% end %>
          </div>
        </div>
      </div>
    <% else %>
      <br/>
      <% if @presenter.params[:search].blank? %>
        <p><strong>No entrants have been added yet</strong></p>
      <% elsif @presenter.params[:search].present? && @presenter.params[:search].length < 3 %>
        <p><strong>Search parameter is too short</strong></p>
      <% else %>
        <p><strong>No lottery entrants match this search</strong></p>
      <% end %>
    <% end %>

  <% when "tickets" %>
    <% if @presenter.lottery_tickets_paginated.present? %>
      <aside class="ost-toolbar">
        <div class="container">
          <div class="row">
            <div class="col-12 col-md-6 form-inline">
              <%= render "lottery_entrants/entrant_lookup" %>
            </div>
          </div>
        </div>
      </aside>

      <div data-controller="infinite-scroll"
           data-infinite-scroll-next-page-url="<%= @presenter.next_page_url %>"
           data-infinite-scroll-html-template="lottery_tickets/lottery_ticket">
        <div data-infinite-scroll-target="result">
          <%= render partial: "lottery_tickets/lottery_ticket", collection: @presenter.lottery_tickets_paginated, as: :record %>
        </div>
        <hr/>

        <div class="row">
          <div class="col text-center" data-infinite-scroll-target="link">
            <% if @presenter.next_page_url.present? %>
              <%= link_to "Show More", @presenter.next_page_url, data: {action: "infinite-scroll#loadFromClick"} %>
            <% else %>
              <p>End of List</p>
            <% end %>
          </div>
        </div>
      </div>
    <% else %>
      <br/>
      <% if @presenter.params[:search].blank? %>
        <p><strong>No tickets have been generated yet</strong></p>
      <% elsif @presenter.params[:search].present? && @presenter.params[:search].length < 3 %>
        <p><strong>Search parameter is too short</strong></p>
      <% else %>
        <p><strong>No tickets match this search</strong></p>
      <% end %>
    <% end %>

  <% when "draws" %>
    <% if @presenter.viewable_results? %>
      <%= turbo_stream_from @presenter.lottery, :lottery_draws %>
      <% if @presenter.lottery.live? %>
        <h6 class="text-center">Live updating</h6>
        <div class="back-and-forth-path">
          <span class="back-and-forth-shape trail"></span>
        </div>
      <% end %>

      <div id="lottery_draws">
        <%= render partial: "lottery_draws/lottery_draw", collection: @presenter.lottery_draws_ordered %>
      </div>
    <% else %>
      <h6 class="text-center">This lottery is not yet live</h6>
    <% end %>

  <% when "results" %>
    <% if @presenter.viewable_results? %>
      <% if @presenter.lottery_draws.present? %>
        <% @presenter.divisions.each do |division| %>
          <div class="card">
            <h4 class="card-header font-weight-bold bg-primary text-white"><%= "#{division.name}" %></h4>
            <div class="card-body">
              <h5>Accepted</h5>
              <% if division.winning_entrants.present? %>
                <ol>
                  <% division.winning_entrants.each do |entrant| %>
                    <li><%= "#{entrant.name} (#{entrant.flexible_geolocation})" %></li>
                  <% end %><commit_msg>Turbo stream only if the lottery is live<commit_after><% content_for :title do %>
  <% "OpenSplitTime: Show lottery - #{@presenter.name}" %>
<% end %>

<header class="ost-header">
  <div class="container">
    <div class="ost-heading row">
      <div class="col">
        <div class="ost-title">
          <h1><strong><%= @presenter.name %></strong></h1>
          <ul class="breadcrumb breadcrumb-ost">
            <li class="breadcrumb-item"><%= link_to "Organizations", organizations_path %></li>
            <li class="breadcrumb-item"><%= link_to @presenter.organization.name, organization_lotteries_path(@presenter.organization) %></li>
            <li class="breadcrumb-item"><%= link_to "Lotteries", organization_lotteries_path(@presenter.organization) %></li>
            <li class="breadcrumb-item"><%= @presenter.name %></li>
          </ul>
        </div>
        <div class="ost-subtitle">
          <p><%= l(@presenter.scheduled_start_date, format: :full_with_weekday) %></p>
        </div>
      </div>
      <aside class="col-auto text-right">
        <% if current_user&.authorized_for_lotteries?(@presenter.organization) %>
          <%= link_to "Admin", setup_organization_lottery_path(@presenter.organization, @presenter.lottery), class: "btn btn-outline-secondary" %>
        <% end %>
      </aside>
    </div>
    <% if @presenter.viewable_results? %>
      <% if @presenter.display_style == "draws" %>
        <div class="mb-4">
          <%= link_to "Browse Entrants and Results", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :entrants), class: "btn btn-success btn-block font-weight-bold" %>
        </div>
      <% else %>
        <div>
          <%= link_to "View Draws", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :draws), class: "btn btn-outline-secondary btn-block text-success font-weight-bold" %>
        </div>
      <% end %>
    <% end %>
    <!-- Navigation -->
    <% unless @presenter.display_style == "draws" %>
      <ul class="nav nav-tabs nav-tabs-ost">
        <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'entrants'}" do
          link_to "Entrants", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :entrants)
        end %>
        <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'tickets'}" do
          link_to "Tickets", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :tickets)
        end %>
        <% if @presenter.viewable_results? %>
          <%= content_tag :li, class: "nav-item #{'active' if @presenter.display_style == 'results'}" do
            link_to "Results", organization_lottery_path(@presenter.organization, @presenter.lottery, display_style: :results)
          end %>
        <% end %>
      </ul>
    <% end %>
  </div>
</header>

<article class="ost-article container">
  <% case @presenter.display_style %>
  <% when "entrants" %>
    <aside class="ost-toolbar">
      <div class="container">
        <div class="row">
          <div class="col-12 col-md-6 form-inline">
            <%= render "lottery_entrants/entrant_lookup" %>
          </div>
        </div>
      </div>
    </aside>

    <% if @presenter.lottery_entrants_paginated.present? %>
      <div data-controller="infinite-scroll"
           data-infinite-scroll-next-page-url="<%= @presenter.next_page_url %>"
           data-infinite-scroll-html-template="lottery_entrants/lottery_entrant">
        <div data-infinite-scroll-target="result">
          <%= render partial: "lottery_entrants/lottery_entrant", collection: @presenter.lottery_entrants_paginated, as: :record %>
        </div>
        <hr/>

        <div class="row">
          <div class="col text-center" data-infinite-scroll-target="link">
            <% if @presenter.next_page_url.present? %>
              <%= link_to "Show More", @presenter.next_page_url, data: {action: "infinite-scroll#loadFromClick"} %>
            <% else %>
              <p>End of List</p>
            <% end %>
          </div>
        </div>
      </div>
    <% else %>
      <br/>
      <% if @presenter.params[:search].blank? %>
        <p><strong>No entrants have been added yet</strong></p>
      <% elsif @presenter.params[:search].present? && @presenter.params[:search].length < 3 %>
        <p><strong>Search parameter is too short</strong></p>
      <% else %>
        <p><strong>No lottery entrants match this search</strong></p>
      <% end %>
    <% end %>

  <% when "tickets" %>
    <% if @presenter.lottery_tickets_paginated.present? %>
      <aside class="ost-toolbar">
        <div class="container">
          <div class="row">
            <div class="col-12 col-md-6 form-inline">
              <%= render "lottery_entrants/entrant_lookup" %>
            </div>
          </div>
        </div>
      </aside>

      <div data-controller="infinite-scroll"
           data-infinite-scroll-next-page-url="<%= @presenter.next_page_url %>"
           data-infinite-scroll-html-template="lottery_tickets/lottery_ticket">
        <div data-infinite-scroll-target="result">
          <%= render partial: "lottery_tickets/lottery_ticket", collection: @presenter.lottery_tickets_paginated, as: :record %>
        </div>
        <hr/>

        <div class="row">
          <div class="col text-center" data-infinite-scroll-target="link">
            <% if @presenter.next_page_url.present? %>
              <%= link_to "Show More", @presenter.next_page_url, data: {action: "infinite-scroll#loadFromClick"} %>
            <% else %>
              <p>End of List</p>
            <% end %>
          </div>
        </div>
      </div>
    <% else %>
      <br/>
      <% if @presenter.params[:search].blank? %>
        <p><strong>No tickets have been generated yet</strong></p>
      <% elsif @presenter.params[:search].present? && @presenter.params[:search].length < 3 %>
        <p><strong>Search parameter is too short</strong></p>
      <% else %>
        <p><strong>No tickets match this search</strong></p>
      <% end %>
    <% end %>

  <% when "draws" %>
    <% if @presenter.viewable_results? %>
      <% if @presenter.lottery.live? %>
        <%= turbo_stream_from @presenter.lottery, :lottery_draws %>
        <h6 class="text-center">Live updating</h6>
        <div class="back-and-forth-path">
          <span class="back-and-forth-shape trail"></span>
        </div>
      <% end %>

      <div id="lottery_draws">
        <%= render partial: "lottery_draws/lottery_draw", collection: @presenter.lottery_draws_ordered %>
      </div>
    <% else %>
      <h6 class="text-center">This lottery is not yet live</h6>
    <% end %>

  <% when "results" %>
    <% if @presenter.viewable_results? %>
      <% if @presenter.lottery_draws.present? %>
        <% @presenter.divisions.each do |division| %>
          <div class="card">
            <h4 class="card-header font-weight-bold bg-primary text-white"><%= "#{division.name}" %></h4>
            <div class="card-body">
              <h5>Accepted</h5>
              <% if division.winning_entrants.present? %>
                <ol>
                  <% division.winning_entrants.each do |entrant| %>
                    <li><%= "#{entrant.name} (#{entrant.flexible_geolocation})" %></li>
                  <% end %>
{'fraction_non_alphanumeric': 0.16880211511083995, 'fraction_numerical': 0.0025760965358280793, 'mean_word_length': 2.5529865125240847, 'pattern_counts': {'":': 0, '<': 397, '<?xml version=': 0, '>': 393, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3289687', 'n_tokens_mistral': 4929, 'n_tokens_neox': 4570, 'n_words': 853}