<% if (typeof profileSection !== "undefined" && profileSection) { %>
  <% const birthday = getBirthday(user.id); %>
  <form method="post" action="/plugins/birthday/profile" class="form-grid">
    <div class="field">
      <label>Birthday</label>
      <input name="birthday" value="<%= birthday ? (birthday.year ? birthday.year + '/' : '') + String(birthday.month).padStart(2, '0') + '/' + String(birthday.day).padStart(2, '0') : '' %>" placeholder="YYYY/MM/DD or MM/DD" />
      <p class="hint">Use YYYY/MM/DD or MM/DD. Year is optional.</p>
    </div>
    <div class="field">
      <label>Privacy</label>
      <select name="privacy">
        <% ["public", "limited", "private"].forEach((option) => { %>
        <option value="<%= option %>" <%= (birthday?.privacy || "limited") === option ? "selected" : "" %>><%= option %></option>
        <% }) %>
      </select>
    </div>
    <% if (birthday) { %>
    <p class="hint full">Stored birthday: <%= formatBirthday(birthday) %>.</p>
    <% } %>
    <div class="field full profile-actions">
      <button type="submit" class="button subtle">Save birthday</button>
    </div>
  </form>
  <% if (birthday) { %>
  <form method="post" action="/plugins/birthday/profile/unset" data-confirm-mode="modal" data-confirm-title="Remove birthday" data-confirm-text="Remove your saved birthday?" data-confirm-label="Remove birthday">
    <button type="submit" class="button danger">Remove birthday</button>
  </form>
  <% } %>
<% } else { %>
  <%- include("../../../src/web/views/partials/layout-top", { title }) %>
  <section class="card">
    <div class="section-header">
      <div>
        <h1><%= target.internal_username %></h1>
        <p class="command-subtitle">Birthday profile</p>
      </div>
    </div>
    <% if (canView && birthday) { %>
    <p><strong>Birthday:</strong> <%= formatBirthdayDateOnly(birthday) %></p>
    <% } else { %>
    <p>This user's birthday is not visible to you.</p>
    <% } %>
  </section>
  <%- include("../../../src/web/views/partials/layout-bottom") %>
<% } %>
