<div class="space-x-4">
  <div class="inline-block">
    <table class="aligned-vertical">
      <% if ip_info[:country].present? %>
        <tr>
          <th>Location</th>
          <td>
            <% if ip_info[:city] %>
              <%= ip_info[:city] %>,
            <% end %>
            <% if ip_info[:region].present? %>
              <%= ip_info[:region] %>,
            <% end %>
            <%= ip_info[:country] %>
          </td>
        </tr>
      <% end %>

      <% if ip_info[:network].present? %>
        <tr>
          <th>Network</th>
          <td>
            <%= link_to ip_info[:network], ip_addresses_path(search: { ip_addr: ip_info[:network] }) %>
            (<%= link_to "info", "https://ipinfo.io/AS#{ip_info[:asn]}/#{ip_info[:network]}"  %>)
          </td>
        </tr>
      <% end %>

      <tr>
        <th>Proxy?</th>
        <td><%= ip_address.ip_addr.is_proxy? ? "Yes" : "No" %></td>
      </tr>

      <% if ip_address.ip_addr.is_tor? %>
        <tr>
          <th>Tor?</th>
          <td>Yes</td>
        </tr>
      <% end %>

      <tr>
        <th>IP Banned?</th>
        <td>
          <% if IpBan.ip_matches(ip_address.ip_addr.to_s).exists? %>
            Yes (<%= link_to "info", ip_bans_path(search: { ip_addr: ip_address.ip_addr.to_s }) %>)
          <% else %>
            No
          <% end %>
        </td>
      </tr>

      <% if ip_info[:asn].present? %>
        <tr>
          <th>ASN</th>
          <td>
            <%= link_to "AS#{ip_info[:asn]}", "https://ipinfo.io/AS#{ip_info[:asn]}" %>
          </td>
        </tr>
      <% end %>

      <% if ip_info[:organization].present? %>
        <tr>
          <th>Organization</th>
          <td>
            <%= ip_info[:organization] %>
          </td>
        </tr>
      <% end %>

      <% if ip_info[:carrier].present? %>
        <tr>
          <th>Mobile Carrier</th>
          <td><%= ip_info[:carrier] %></td>
        </tr>
      <% end %>

      <tr>
        <th>Details</th>
        <td>
          <details>
            <pre><%= JSON.pretty_generate(ip_address.lookup.response) %></pre>
          </details>
        </td>
      </tr>
    </table>
  </div>

  <div class="inline-block align-top">
    <% if ip_info[:latitude].present? && ip_info[:longitude].present? %>
      <%= embedded_map(ip_info[:latitude], ip_info[:longitude], 300, 200) %>
    <% end %>
  </div>
</div>
