<ul id="sidenav-left" class="sidenav no-print <%= 'sidenav-fixed' unless defined?(locals) && locals.key?(:fixed) && !locals[:fixed] %>">
  <li class="blue">
    <%= link_to main_app.root_path, class: 'logo-container white-text' do %>
      <i class="material-icons white-text right">
        dashboard
      </i>
      <span translate="no">Notebook.ai</span>
    <% end %>
  </li>
  <li class="no-padding">
    <ul class="collapsible collapsible-accordion">
      <li class="bold waves-effect blue lighten-1 tooltipped" data-tooltip="Focus on a specific universe..." data-position="right">
        <a class="collapsible-header white-text" tabindex="0">
          <i class="material-icons white-text left">vpn_lock</i>
          <i class="material-icons chevron white-text">chevron_left</i>
          <%= @universe_scope.present? ? truncate(@universe_scope.name, length: 26) : 'All Universes' %>
        </a>
        <div class="collapsible-body blue lighten-1">
          <ul>
            <%# TODO: we should use a cache here %>
            <% (@current_user_content.fetch('Universe', []) + current_user.contributable_universes).sort_by(&:name).each do |universe| %>
              <li>
                <%= link_to "?universe=#{universe.id}", class: 'waves-effect' do %>
                  <i class="material-icons <%= Universe.text_color %>">
                    <%= Universe.icon %>
                  </i>
                  <span class="white-text">
                    <%= truncate(universe.name, length: 26) %>
                  </span>
                <% end %>
              </li>
            <% end %>
            <li class="divider blue"></li>
              <li class="blue lighten-2">
                <%= link_to "?universe=all", class: 'waves-effect white-text' do %>
                  <i class="material-icons <%= Universe.text_color %>">
                    <%= Universe.icon %>
                  </i>
                   All universes
                <% end %>
              </li>
          </ul>
        </div>
      </li>
      <li class="bold waves-effect <%= 'active' if @sidenav_expansion == 'worldbuilding' %>">
        <a class="collapsible-header" tabindex="0">
          Worldbuilding
          <i class="material-icons chevron">chevron_right</i>
        </a>
        <div class="collapsible-body" style="">
          <ul>
            <%
              @activated_content_types.each do |content_type|
            %>
              <% content_type_klass = content_class_from_name(content_type) %>
              <li>
                <%#
                  todo define missing colors using the "Custom colors" section article
                  https://materializecss.com/waves.html#!
                %>
                <%= link_to main_app.polymorphic_path(content_type_klass), class: "waves-effect waves-#{content_type_klass.color.split(' ').last}" do %>
                  <i class="material-icons <%= content_type_klass.text_color %>">
                    <%= content_type_klass.icon %>
                  </i>
                  <%= content_type.pluralize %>
                  <span class="badge">
                    <%= @current_user_content.fetch(content_type, []).count %>
                    <%#
                      pluralized_name = content_type.downcase.pluralize
                      if content_type_klass != Universe && @universe_scope
                        @universe_scope.send(pluralized_name).count
                      else
                        (
                          @current_user_content.fetch(content_type, []) +
                          current_user.send("contributable_#{pluralized_name}") +
                          (content_type_klass == Universe ? [] : content_type_klass.where(universe_id: current_user.universes.pluck(:id)))
                        ).uniq.count
                      end
                    %>
                  </span>
                <% end %>
              </li>
            <% end %>
            <li>
              <%= link_to main_app.customization_content_types_path, class: 'waves-effect' do %>
                <i class="material-icons black-text">add</i>
                <!-- <span class="new badge <%= Lore.color %> black-text"></span> -->
                Add more...
              <% end %>
            </li>
          </ul>
        </div>
      </li>
      <li class="bold waves-effect <%= 'active' if @sidenav_expansion == 'writing' %>">
        <a class="collapsible-header" tabindex="0">
          Writing
          <i class="material-icons chevron">chevron_right</i>
        </a>
        <div class="collapsible-body" style="">
          <ul>
            <li>
              <%= link_to main_app.prompts_path, class: 'waves-effect' do %>
                <i class="material-icons left orange-text">lightbulb_outline</i>
                Prompts
              <% end %>
            </li>
            <li>
              <%= link_to main_app.timelines_path, class: 'waves-effect' do %>
                <i class="material-icons left <%= Timeline.text_color %>"><%= Timeline.icon %></i>
                Timelines
                <span class="badge">
                  <%= @current_user_content.fetch('Timeline', []).count %>
                </span>
              <% end %>
            </li>
            <li>
              <%= link_to main_app.documents_path, class: 'waves-effect' do %>
                <i class="material-icons <%= Document.color %>-text">
                  <%= Document.icon %>
                </i>
                Documents
                <span class="badge">
                  <%= @current_user_content.fetch('Document', []).count %>
                </span>
              <% end %>
            </li>
          </ul>
        </div>
      </li>
      <% if current_user.community_features_enabled? %>
        <li class="bold waves-effect <%= 'active' if @sidenav_expansion == 'community' %>">
          <a class="collapsible-header" tabindex="0">
            Community
            <i class="material-icons chevron">chevron_right</i>
          </a>
          <div class="collapsible-body">
            <ul>
              <li>
                <%= link_to main_app.stream_path, class: 'waves-effect' do %>
                  <i class="material-icons left <%= ContentPageShare.text_color %>"><%= ContentPageShare.icon %></i>
                  Stream
                <% end %>
              </li>
              <!--
              <li>
                <%= link_to main_app.stream_community_path, class: 'waves-effect' do %>
                  <i class="material-icons left red-text">whatshot</i>
                  What's new
                <% end %>
              </li>
              -->
              <li>
                <%= link_to main_app.page_collections_path, class: 'waves-effect' do %>
                  <i class="material-icons left <%= PageCollection.text_color %>"><%= PageCollection.icon %></i>
                  <!--<span class="new badge <%= PageCollection.color %> white-text"></span>-->
                  Collections
                <% end %>
              </li>
              <li>
                <%= link_to main_app.thredded_path, class: 'waves-effect' do %>
                  <i class="material-icons blue-text">
                    forum
                  </i>
                  Discussions
                  <% if @unread_threads > 0 || @unread_private_messages > 0 %>
                    <span class="badge <%= 'blue white-text' if @unread_private_messages > 0 %>">
                      <%= @unread_threads %><%= "/#{@unread_private_messages}" if @unread_private_messages > 0 %>
                    </span>
                  <% end %>
                <% end %>
              </li>
              <% unless current_user.private_profile? %>
                <li>
                  <%= link_to current_user.profile_url, class: 'waves-effect' do %>
                    <i class="material-icons left <%= User.text_color %>"><%= User.icon %></i>
                    Profile
                  <% end %>
                </li>
              <% end %>
            </ul>
          </div>
        </li>
      <% end %>
      <li class="bold waves-effect <%= 'active' if @sidenav_expansion == 'my account' %>">
        <a class="collapsible-header" tabindex="0">
          My Account
          <i class="material-icons chevron">chevron_right</i>
        </a>
        <div class="collapsible-body">
          <ul>
            <li>
              <%= link_to main_app.edit_user_registration_path, class: 'waves-effect' do %>
                <i class="material-icons left black-text">settings</i>
                Settings
              <% end %>
            </li>
            <li>
              <%= link_to main_app.subscription_path, class: 'waves-effect' do %>
                <i class="material-icons left blue-text">credit_card</i>
                Billing
                <span class="badge right"><%= current_user.on_premium_plan? ? 'Premium' : 'Starter' %></span>
              <% end %>
            </li>
            <li>
              <%= link_to main_app.data_vault_path, class: 'waves-effect' do %>
                <i class="material-icons left brown-text">lock</i>
                Data vault
              <% end %>
            </li>
            <li>
              <%= link_to main_app.help_center_path, class: 'waves-effect' do %>
                <i class="material-icons left pink-text text-lighten-3">help</i>
                Help center
              <% end %>
            </li>
            <li class="divider"></li>
            <li>
              <%= link_to main_app.destroy_user_session_path, class: 'waves-effect' do %>
                <i class="material-icons left">power_settings_new</i>
                Sign out
              <% end %>
            </li>
          </ul>
        </div>
      </li>
    </ul>
  </li>
</ul>