<% content_for :head do %>
  <%= javascript_include_tag "index" %>
<% end %>

<% content_for(:body_class) { "map-layout" } %>

<% if current_user&.home_location? %>
  <% content_for :greeting do %>
    <%= link_to t("layouts.home"),
                "#",
                :id => "homeanchor",
                :class => "set_position dropdown-item",
                :data => { :lat => current_user.home_lat,
                           :lon => current_user.home_lon,
                           :zoom => 15 } %>
  <% end %>
<% end %>

<% content_for :header do %>
  <%= render :partial => "layouts/search", :locals => { :autofocus => false } %>
<% end %>

<% content_for :content do %>
  <div id="sidebar" class="bg-body z-1">
    <%= render :partial => "layouts/search", :locals => { :autofocus => true } %>

    <div id="flash">
      <%= render :partial => "layouts/flash" %>
    </div>

    <div id="browse_status"></div>

    <div id="sidebar_loader" class="my-3 text-center loader">
      <div class="spinner-border" role="status">
        <span class="visually-hidden"><%= t("browse.start_rjs.loading") %></span>
      </div>
    </div>

    <div id="sidebar_content" class="p-3">
      <%= yield %>
    </div>

    <% unless current_user %>
      <div class="welcome p-3" hidden>
        <%= render "sidebar_header", :title => t("layouts.intro_header") %>
        <p class="fs-6 fw-light"><%= t "layouts.intro_text" %></p>
        <p class="fs-6 fw-light"><%= t "layouts.hosting_partners_2024_html",
                                       :fastly => link_to(t("layouts.partners_fastly"), "https://www.fastly.com/"),
                                       :corpmembers => link_to(t("layouts.partners_corpmembers"), "https://osmfoundation.org/wiki/Corporate_Members"),
                                       :partners => link_to(t("layouts.partners_partners"), "https://hardware.openstreetmap.org/thanks/") %>
        </p>
        <div class="d-flex gap-2">
          <a class="btn btn-primary w-100 d-flex align-items-center justify-content-center" href="<%= about_path %>"><%= t("layouts.learn_more") %></a>
          <a class="btn btn-primary w-100 d-flex align-items-center justify-content-center" href="<%= new_user_path %>"><%= t("layouts.start_mapping") %></a>
        </div>
      </div>
    <% end %>

    <%= render :partial => "layouts/banner" %>
  </div>

  <noscript>
    <div class="mt-5 p-3">
      <p><%= t "site.index.js_1" %></p>
      <p><%= t "site.index.js_2" %></p>
    </div>
  </noscript>

  <div id="map-ui" class="bg-body z-2">
  </div>

  <div id="map" tabindex="2" class="bg-body-secondary z-0">
  </div>

  <div id="attribution" class="d-none">
    <table>
      <tr>
        <td><%= t "site.index.license.license_url" %></td>
        <td><%= t "site.index.license.project_url" %></td>
      </tr>
      <tr>
        <td colspan="2" class="attribution_notice"><%= t "site.index.license.copyright" %></td>
      </tr>
    </table>
  </div>
<% end %>

<%= render :template => "layouts/site" %>
