<%# Signing form: review, certificate, re-authentication, confirm. Locals: entry, url, cancel_path. %>

<%= t(".sign_this_entry") %>

<%= t(".review_the_entry_your_signature_html", link: (link_to t(".how_signing_works"), records_help_path, class: "link", target: "_blank")) %>

<%= render "logbook_entries/content", entry: entry %> <%= render "logbook_entries/draft_batch", entry: entry %> <% if @signing_error %> <% end %> <% if @certificates.empty? %>

<%= t(".to_sign_add_your_certificate_html", link: (link_to t(".your_profile"), edit_profile_path(anchor: "certificates"), class: "link")) %>

<% else %> <%= form_with url: url, method: :post, class: "space-y-4" do %>
<%= t(".sign_with") %> <% @certificates.each_with_index do |c, i| %> <% problems = entry.signing_problems(c) %> <% end %>
<% if Sso.password_login? || !current_user.sso_uid? %>
<%= label_tag :password, t(".your_password"), class: "label" %> <%= password_field_tag :password, nil, class: "input", autocomplete: "current-password" %>

<%= t(".proves_it_s_you_signing_html", sso_uid: (t(".or_sign_in_again_with_2", so: Sso.label) if Sso.enabled? && current_user.sso_uid?)) %>

<% if current_user.otp_enabled? %>
<%= label_tag :otp_code, t(".authenticator_code"), class: "label" %> <%= text_field_tag :otp_code, nil, class: "input w-32 tracking-widest", autocomplete: "one-time-code", inputmode: "numeric", maxlength: 20 %>
<% end %> <% end %> <% if Sso.enabled? && current_user.sso_uid? %> <% fresh = session[:reauthenticated_at] && Time.zone.at(session[:reauthenticated_at]) > EntrySigner::REAUTH_WINDOW.ago %>

<%= fresh ? t(".signed_in_again_with_you", so: Sso.label) : t(".or_sign_in_again_with", so: Sso.label) %>

<% end %>
<%= submit_tag t(".sign_entry"), class: "btn-primary" %><%= link_to t(".cancel"), cancel_path, class: "btn-secondary" %>
<% end %> <% if Sso.enabled? && current_user.sso_uid? %> <%= button_to t(".sign_in_again_with", so: Sso.label), "/auth/#{Sso::PROVIDER}", params: { prompt: "login" }, class: "btn-secondary btn-sm", data: { turbo: false } %> <% end %> <% end %>