{% extends "base.html" %}
{% load static %}
{% block content %}
  <script>
    // tabbed browsing for the modal
    function initTabs() {
    TABS.forEach((tab) => {
      tab.addEventListener('click', (e) => {
        let selected = tab.getAttribute('data-tab');
        updateActiveTab(tab);
        updateActiveContent(selected);
      })
    })
  }

  function updateActiveTab(selected) {
    TABS.forEach((tab) => {
      if (tab && tab.classList.contains(ACTIVE_CLASS)) {
        tab.classList.remove(ACTIVE_CLASS);
      }
    });
    selected.classList.add(ACTIVE_CLASS);
  }

  function updateActiveContent(selected) {
    CONTENT.forEach((item) => {
      if (item && item.classList.contains(ACTIVE_CLASS)) {
        item.classList.remove(ACTIVE_CLASS);
      }
      let data = item.getAttribute('data-content');
      if (data === selected) {
        item.classList.add(ACTIVE_CLASS);
      }
    });
  }
  </script>
  <style>
    .icon { border-bottom: 0px !important;}
  </style>
  <div class="tile is-ancestor">
    <div class="tile is-vertical is-9">
      <div class="tile">
        <div class="tile is-parent is-vertical">
          <article class="tile is-child box">
            <form method="POST">
              {% csrf_token %}
              <div class="field">
                <label class="label">Search</label>
                <div class="field-body">
                  <div class="field">
                    <div class="control is-expanded has-icons-left">
                      <input id="query" name="query" class="input" type="text" placeholder="nickname">
                      <span class="icon is-small is-left">
                        <i class="fas fa-magnifying-glass"></i>
                      </span>
                    </div>
                  </div>
                </div>
              </div>
              <div class="field">
                <div class="control">
                  <button
                    class="button is-primary is-fullwidth"
                    hx-post="{% url 'search_insights' %}"
                    hx-trigger="click"
                    hx-target="#info"
                    hx-swap="outerHTML">
                    Search
                  </button>
                </div>
              </div>
            </form>
          </article>

        </div>
        <div class="tile is-parent">
          <article class="tile is-child box">
            <h5 class="subtitle is-5">Nicks</h5>
            <div id="nicks"></div>
          </article>
        </div>
      </div>
      <div class="tile">
        <div class="tile is-parent is-vertical">
          <article class="tile is-child box">
            <h5 class="subtitle is-5">Info</h5>
            <div id="info"></div>
          </article>

        </div>
        <div class="tile is-parent">
          <article class="tile is-child box">
            <h5 class="subtitle is-5">Meta</h5>
            <div id="meta"></div>
          </article>
        </div>
      </div>
    </div>
    <div class="tile is-parent">
      <article class="tile is-child box">
        <h5 class="subtitle is-5">Channels</h5>
        <div id="channels"></div>
      </article>
    </div>
  </div>
  <div id="modals-here"></div>
{% endblock %}