{% load pygments_highlights %}
<div class="accordion" id="host_facts">
  <div class="card">
    <div class="card-header" id="host_facts_card">
      <button class="btn btn-lg" style="font-size:1.2em;" type="button" data-toggle="collapse" data-target="#collapse_host_facts" aria-expanded="true" aria-controls="collapse_host_facts">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16">
          <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
          <path d="M8.93 6.588l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
        </svg>
        Host facts: {{ host.name }}
      </button>
    </div>
    <div id="collapse_host_facts" class="collapse show" aria-labelledby="host_facts_card" data-parent="#host_facts" style="overflow-y: auto;">
      <div class="card-body">
        {% if host.facts.items %}
        <div class="table-responsive">
          <table class="table table-sm table-hover">
            <thead>
            <tr>
              <th style="width:20%;">Fact</th>
              <th style="width:80%;">Value</th>
            </tr>
            </thead>
            <tbody>
            {% for fact, value in host.facts.items %}
              <tr>
                <td id="{{ fact }}" data-label="{{ fact }}">
                  <a href="#{{ fact }}">{{ fact }}</a>
                </td>
                {# Some facts are VERY LONG uninterrupted single lines (looking at you ansible_ssh_host_key_rsa_public) #}
                <td data-label="Value" style="max-width:400px;">
                  {{ value | format_data | safe }}
                </td>
              </tr>
            {% endfor %}
            </tbody>
          </table>
        </div>
        {% else %}
        <p>No recorded host facts found.</p>
        <p>Host facts are saved automatically when the <code>setup</code> module is used or when <code>gather_facts: true</code> is set.</p>
        {% endif %}
      </div>
    </div>
  </div>
</div>
